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


using System; 
using System.Drawing; 
using System.Collections; 
using System.ComponentModel; 
using System.Windows.Forms; 
using HttpProxy.Component; 
 
namespace HttpProxy.UI 
{ 
	///  
	/// MaintenUser 类 
	///  
	public class MaintenUser : System.Windows.Forms.Form 
	{ 
		private System.Windows.Forms.Button btnOk; 
		private System.Windows.Forms.Label lblName; 
		private System.Windows.Forms.Label lblTitle; 
		private System.Windows.Forms.Label lblPwd1; 
		private System.Windows.Forms.Label lblPwd2; 
		private System.Windows.Forms.Label lblDescription; 
		private System.Windows.Forms.TextBox txtDescription; 
		private System.Windows.Forms.TextBox txtPwd1; 
		private System.Windows.Forms.TextBox txtPwd2; 
		private System.Windows.Forms.TextBox txtPwd3; 
		///  
		/// 必需的设计器变量。 
		///  
		private System.ComponentModel.Container components = null; 
 
		public MaintenUser() 
		{ 
			// 
			// Windows 窗体设计器支持所必需的 
			// 
			InitializeComponent(); 
 
			this.Icon=null; 
		} 
 
		///  
		/// 清理所有正在使用的资源。 
		///  
		protected override void Dispose( bool disposing ) 
		{ 
			if( disposing ) 
			{ 
				if(components != null) 
				{ 
					components.Dispose(); 
				} 
			} 
			base.Dispose( disposing ); 
		} 
 
		#region Windows 窗体设计器生成的代码 
		///  
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改 
		/// 此方法的内容。 
		///  
		private void InitializeComponent() 
		{ 
			this.btnOk = new System.Windows.Forms.Button(); 
			this.txtPwd1 = new System.Windows.Forms.TextBox(); 
			this.lblName = new System.Windows.Forms.Label(); 
			this.lblTitle = new System.Windows.Forms.Label(); 
			this.lblPwd1 = new System.Windows.Forms.Label(); 
			this.lblPwd2 = new System.Windows.Forms.Label(); 
			this.lblDescription = new System.Windows.Forms.Label(); 
			this.txtPwd2 = new System.Windows.Forms.TextBox(); 
			this.txtPwd3 = new System.Windows.Forms.TextBox(); 
			this.txtDescription = new System.Windows.Forms.TextBox(); 
			this.SuspendLayout(); 
			//  
			// btnOk 
			//  
			this.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 
			this.btnOk.Location = new System.Drawing.Point(113, 253); 
			this.btnOk.Name = "btnOk"; 
			this.btnOk.Size = new System.Drawing.Size(64, 23); 
			this.btnOk.TabIndex = 15; 
			this.btnOk.Text = "确 认"; 
			this.btnOk.Click += new System.EventHandler(this.btnOk_Click); 
			//  
			// txtPwd1 
			//  
			this.txtPwd1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 
			this.txtPwd1.Location = new System.Drawing.Point(105, 61); 
			this.txtPwd1.MaxLength = 10; 
			this.txtPwd1.Name = "txtPwd1"; 
			this.txtPwd1.PasswordChar = '*'; 
			this.txtPwd1.Size = new System.Drawing.Size(104, 21); 
			this.txtPwd1.TabIndex = 11; 
			this.txtPwd1.Text = ""; 
			//  
			// lblName 
			//  
			this.lblName.Location = new System.Drawing.Point(17, 61); 
			this.lblName.Name = "lblName"; 
			this.lblName.Size = new System.Drawing.Size(56, 24); 
			this.lblName.TabIndex = 8; 
			this.lblName.Text = "密码:"; 
			//  
			// 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(96, 21); 
			this.lblTitle.Name = "lblTitle"; 
			this.lblTitle.Size = new System.Drawing.Size(111, 23); 
			this.lblTitle.TabIndex = 4; 
			this.lblTitle.Text = "用户信息维护"; 
			//  
			// lblPwd1 
			//  
			this.lblPwd1.Location = new System.Drawing.Point(17, 101); 
			this.lblPwd1.Name = "lblPwd1"; 
			this.lblPwd1.Size = new System.Drawing.Size(56, 24); 
			this.lblPwd1.TabIndex = 5; 
			this.lblPwd1.Text = "新密 码:"; 
			//  
			// lblPwd2 
			//  
			this.lblPwd2.Location = new System.Drawing.Point(17, 141); 
			this.lblPwd2.Name = "lblPwd2"; 
			this.lblPwd2.Size = new System.Drawing.Size(64, 24); 
			this.lblPwd2.TabIndex = 7; 
			this.lblPwd2.Text = "确认密码:"; 
			//  
			// lblDescription 
			//  
			this.lblDescription.Location = new System.Drawing.Point(17, 181); 
			this.lblDescription.Name = "lblDescription"; 
			this.lblDescription.Size = new System.Drawing.Size(56, 24); 
			this.lblDescription.TabIndex = 6; 
			this.lblDescription.Text = "简介:"; 
			//  
			// txtPwd2 
			//  
			this.txtPwd2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 
			this.txtPwd2.Location = new System.Drawing.Point(105, 101); 
			this.txtPwd2.MaxLength = 10; 
			this.txtPwd2.Name = "txtPwd2"; 
			this.txtPwd2.PasswordChar = '*'; 
			this.txtPwd2.Size = new System.Drawing.Size(104, 21); 
			this.txtPwd2.TabIndex = 12; 
			this.txtPwd2.Text = ""; 
			//  
			// txtPwd3 
			//  
			this.txtPwd3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 
			this.txtPwd3.Location = new System.Drawing.Point(105, 141); 
			this.txtPwd3.MaxLength = 10; 
			this.txtPwd3.Name = "txtPwd3"; 
			this.txtPwd3.PasswordChar = '*'; 
			this.txtPwd3.Size = new System.Drawing.Size(104, 21); 
			this.txtPwd3.TabIndex = 13; 
			this.txtPwd3.Text = ""; 
			//  
			// txtDescription 
			//  
			this.txtDescription.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 
			this.txtDescription.Location = new System.Drawing.Point(105, 173); 
			this.txtDescription.MaxLength = 300; 
			this.txtDescription.Multiline = true; 
			this.txtDescription.Name = "txtDescription"; 
			this.txtDescription.Size = new System.Drawing.Size(176, 56); 
			this.txtDescription.TabIndex = 14; 
			this.txtDescription.Text = ""; 
			//  
			// MaintenUser 
			//  
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); 
			this.ClientSize = new System.Drawing.Size(298, 296); 
			this.Controls.Add(this.btnOk); 
			this.Controls.Add(this.txtPwd1); 
			this.Controls.Add(this.txtPwd2); 
			this.Controls.Add(this.txtPwd3); 
			this.Controls.Add(this.txtDescription); 
			this.Controls.Add(this.lblName); 
			this.Controls.Add(this.lblTitle); 
			this.Controls.Add(this.lblPwd1); 
			this.Controls.Add(this.lblPwd2); 
			this.Controls.Add(this.lblDescription); 
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 
			this.MaximizeBox = false; 
			this.Name = "MaintenUser"; 
			this.ShowInTaskbar = false; 
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 
			this.Text = "用户信息维护"; 
			this.Closing += new System.ComponentModel.CancelEventHandler(this.MaintenUser_Closing); 
			this.Load += new System.EventHandler(this.MaintenUser_Load); 
			this.Activated += new System.EventHandler(this.MaintenUser_Activated); 
			this.ResumeLayout(false); 
 
		} 
		#endregion 
 
		private void MaintenUser_Load(object sender, System.EventArgs e) 
		{ 
			ProxyMain.sbpGlobal.Text = " 请进行当前用户信息维护..."; 
		} 
 
		private void MaintenUser_Activated(object sender, System.EventArgs e) 
		{ 
			ProxyMain.sbpGlobal.Text = " 请进行当前用户信息维护..."; 
		} 
 
		private void MaintenUser_Closing(object sender, System.ComponentModel.CancelEventArgs e) 
		{ 
			ProxyMain.MaintenUserOpen=false; 
		} 
 
		private void btnOk_Click(object sender, System.EventArgs e) 
		{ 
			if(this.txtPwd3.Text.Trim().Length>0 && this.txtPwd1.Text.Trim().Length>0 && this.txtPwd2.Text.Trim().Length>0 && this.txtDescription.Text.Trim().Length>0) 
			{				 
				if(ProxyMain.ProxyUser.Password==this.txtPwd1.Text.Trim() && this.txtPwd2.Text.Trim()==this.txtPwd2.Text.Trim()) 
				{ 
					ProxyMain.ProxyUser.Password=this.txtPwd2.Text.Trim(); 
					ProxyMain.ProxyUser.Description=this.txtDescription.Text.Trim(); 
					if(ProxyMain.ProxyUser.Update()==true) 
					{						 
						this.txtPwd1.Text=string.Empty; 
						this.txtPwd3.Text=string.Empty; 
						this.txtPwd2.Text=string.Empty; 
						this.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); 
			} 
		} 
	} 
}