www.pudn.com > HttpProxy.rar > DeleteUser.cs


using System; 
using System.Drawing; 
using System.Collections; 
using System.ComponentModel; 
using System.Windows.Forms; 
using HttpProxy.Component; 
 
namespace HttpProxy.UI 
{ 
	///  
	/// DeleteUser 类 
	///  
	public class DeleteUser : System.Windows.Forms.Form 
	{ 
		private System.Windows.Forms.Label lblTitle; 
		private System.Windows.Forms.Button btnOk; 
		internal static System.Windows.Forms.TextBox txtName; 
		private System.Windows.Forms.Label lblName; 
		private System.Windows.Forms.Label lblDescription; 
		internal static System.Windows.Forms.TextBox txtDescription; 
 
		internal static int Id=0; 
		///  
		/// 必需的设计器变量。 
		///  
		private System.ComponentModel.Container components = null; 
 
		public DeleteUser() 
		{ 
			// 
			// Windows 窗体设计器支持所必需的 
			// 
			InitializeComponent(); 
 
			this.Icon=null; 
 
			txtName = new System.Windows.Forms.TextBox(); 
			txtDescription = new System.Windows.Forms.TextBox(); 
			//  
			// txtName 
			//  
			txtName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 
			txtName.Location = new System.Drawing.Point(105, 64); 
			txtName.MaxLength = 10; 
			txtName.Name = "txtName"; 
			txtName.Size = new System.Drawing.Size(104, 21); 
			txtName.TabIndex = 10; 
			txtName.Text = ""; 
			txtName.KeyDown += new System.Windows.Forms.KeyEventHandler(txtName_KeyDown); 
			txtName.DoubleClick += new System.EventHandler(txtName_DoubleClick); 
			//  
			// txtDescription 
			//  
			txtDescription.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 
			txtDescription.Enabled = false; 
			txtDescription.Location = new System.Drawing.Point(105, 112); 
			txtDescription.MaxLength = 300; 
			txtDescription.Multiline = true; 
			txtDescription.Name = "txtDescription"; 
			txtDescription.Size = new System.Drawing.Size(176, 56); 
			txtDescription.TabIndex = 11; 
			txtDescription.Text = ""; 
 
			this.Controls.Add(txtName); 
			this.Controls.Add(txtDescription); 
		} 
 
		///  
		/// 清理所有正在使用的资源。 
		///  
		protected override void Dispose( bool disposing ) 
		{ 
			if( disposing ) 
			{ 
				if(components != null) 
				{ 
					components.Dispose(); 
				} 
			} 
			base.Dispose( disposing ); 
		} 
 
		#region Windows 窗体设计器生成的代码 
		///  
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改 
		/// 此方法的内容。 
		///  
		private void InitializeComponent() 
		{ 
			this.lblTitle = new System.Windows.Forms.Label(); 
			this.btnOk = new System.Windows.Forms.Button(); 
			this.lblName = new System.Windows.Forms.Label(); 
			this.lblDescription = new System.Windows.Forms.Label(); 
			this.SuspendLayout(); 
			//  
			// lblTitle 
			//  
			this.lblTitle.Font = new System.Drawing.Font("华文行楷", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134))); 
			this.lblTitle.Location = new System.Drawing.Point(104, 24); 
			this.lblTitle.Name = "lblTitle"; 
			this.lblTitle.Size = new System.Drawing.Size(88, 23); 
			this.lblTitle.TabIndex = 1; 
			this.lblTitle.Text = "删 除 用 户"; 
			//  
			// btnOk 
			//  
			this.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 
			this.btnOk.Location = new System.Drawing.Point(113, 192); 
			this.btnOk.Name = "btnOk"; 
			this.btnOk.Size = new System.Drawing.Size(64, 25); 
			this.btnOk.TabIndex = 12; 
			this.btnOk.Text = "删 除"; 
			this.btnOk.Click += new System.EventHandler(this.btnOk_Click); 
			//  
			// lblName 
			//  
			this.lblName.Location = new System.Drawing.Point(17, 64); 
			this.lblName.Name = "lblName"; 
			this.lblName.Size = new System.Drawing.Size(56, 24); 
			this.lblName.TabIndex = 7; 
			this.lblName.Text = "用户名:"; 
			//  
			// lblDescription 
			//  
			this.lblDescription.Location = new System.Drawing.Point(17, 120); 
			this.lblDescription.Name = "lblDescription"; 
			this.lblDescription.Size = new System.Drawing.Size(56, 24); 
			this.lblDescription.TabIndex = 6; 
			this.lblDescription.Text = "简介:"; 
			//  
			// DeleteUser 
			//  
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); 
			this.ClientSize = new System.Drawing.Size(298, 232); 
			this.Controls.Add(this.btnOk); 
			this.Controls.Add(this.lblName); 
			this.Controls.Add(this.lblDescription); 
			this.Controls.Add(this.lblTitle); 
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 
			this.MaximizeBox = false; 
			this.Name = "DeleteUser"; 
			this.ShowInTaskbar = false; 
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 
			this.Text = "删除用户"; 
			this.Closing += new System.ComponentModel.CancelEventHandler(this.DeleteUser_Closing); 
			this.Load += new System.EventHandler(this.DeleteUser_Load); 
			this.Activated += new System.EventHandler(this.DeleteUser_Activated); 
			this.ResumeLayout(false); 
 
		} 
		#endregion 
 
		///  
		/// Handles the DoubleClick event of the txtName control. 
		///  
		/// The source of the event. 
		/// The  instance containing the event data. 
		private void txtName_DoubleClick(object sender, System.EventArgs e) 
		{ 
			UserList child=new UserList(); 
			child.ShowDialog(); 
		} 
 
		///  
		/// Handles the Load event of the DeleteUser control. 
		///  
		/// The source of the event. 
		/// The  instance containing the event data. 
		private void DeleteUser_Load(object sender, System.EventArgs e) 
		{ 
			ProxyMain.sbpGlobal.Text="请填写或双击文本框进行用户选择..."; 
		} 
 
		///  
		/// Handles the Closing event of the DeleteUser control. 
		///  
		/// The source of the event. 
		/// The  instance containing the event data. 
		private void DeleteUser_Closing(object sender, System.ComponentModel.CancelEventArgs e) 
		{ 
			ProxyMain.DeleteUserOpen=false; 
		} 
 
		///  
		/// Handles the Activated event of the DeleteUser control. 
		///  
		/// The source of the event. 
		/// The  instance containing the event data. 
		private void DeleteUser_Activated(object sender, System.EventArgs e) 
		{ 
			ProxyMain.sbpGlobal.Text="请填写或双击文本框进行用户选择..."; 
		} 
 
		///  
		/// Handles the Click event of the btnOk control. 
		///  
		/// The source of the event. 
		/// The  instance containing the event data. 
		private void btnOk_Click(object sender, System.EventArgs e) 
		{ 
			if(txtName.Text.Trim().Length>0) 
			{ 
				if(txtName.Text.Trim()!=ProxyMain.ProxyUser.Name) 
				{ 
					if(ProxyMain.ProxyUser.Delete(Id)==true) 
					{ 
						txtName.Text=string.Empty; 
						txtDescription.Text=string.Empty; 
 
						MessageBox.Show("删除用户完毕!","HttpProxy",MessageBoxButtons.OK,MessageBoxIcon.Information); 
					} 
					else 
						MessageBox.Show("未能删除该用户!","HttpProxy",MessageBoxButtons.OK,MessageBoxIcon.Information); 
				} 
				else 
					MessageBox.Show("不可删除但前用户!","HttpProxy",MessageBoxButtons.OK,MessageBoxIcon.Information); 
			} 
			else 
				MessageBox.Show("请完整用户名!","HttpProxy",MessageBoxButtons.OK,MessageBoxIcon.Information); 
		} 
 
		///  
		/// Handles the KeyDown event of the txtName control. 
		///  
		/// The source of the event. 
		/// The  instance containing the event data. 
		private void txtName_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) 
		{ 
			if(e.KeyCode!=Keys.Enter) 
			{ 
				UserList child=new UserList(); 
				child.ShowDialog(); 
			} 
		} 
 
	} 
}