www.pudn.com > HttpProxy.rar > AddUser.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using HttpProxy.Component;
namespace HttpProxy.UI
{
///
/// AddUser 类
///
public class AddUser : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblTitle;
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Label lblName;
private System.Windows.Forms.TextBox txtName;
private System.Windows.Forms.Label lblPwd1;
private System.Windows.Forms.Label lblPwd2;
private System.Windows.Forms.Label lblDescription;
private System.Windows.Forms.TextBox txtPwd1;
private System.Windows.Forms.TextBox txtPwd2;
private System.Windows.Forms.TextBox txtDescription;
///
/// 必需的设计器变量。
///
private System.ComponentModel.Container components = null;
///
/// Initializes a new instance of the class.
///
public AddUser()
{
//
// 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.lblTitle = new System.Windows.Forms.Label();
this.lblName = 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.txtName = new System.Windows.Forms.TextBox();
this.btnOk = new System.Windows.Forms.Button();
this.txtPwd1 = new System.Windows.Forms.TextBox();
this.txtPwd2 = new System.Windows.Forms.TextBox();
this.txtDescription = new System.Windows.Forms.TextBox();
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 = 0;
this.lblTitle.Text = "添 加 用 户";
//
// lblName
//
this.lblName.Location = new System.Drawing.Point(16, 64);
this.lblName.Name = "lblName";
this.lblName.Size = new System.Drawing.Size(56, 24);
this.lblName.TabIndex = 1;
this.lblName.Text = "用户名:";
//
// lblPwd1
//
this.lblPwd1.Location = new System.Drawing.Point(16, 104);
this.lblPwd1.Name = "lblPwd1";
this.lblPwd1.Size = new System.Drawing.Size(56, 24);
this.lblPwd1.TabIndex = 1;
this.lblPwd1.Text = "密 码:";
//
// lblPwd2
//
this.lblPwd2.Location = new System.Drawing.Point(16, 144);
this.lblPwd2.Name = "lblPwd2";
this.lblPwd2.Size = new System.Drawing.Size(64, 24);
this.lblPwd2.TabIndex = 1;
this.lblPwd2.Text = "确认密码:";
//
// lblDescription
//
this.lblDescription.Location = new System.Drawing.Point(16, 184);
this.lblDescription.Name = "lblDescription";
this.lblDescription.Size = new System.Drawing.Size(56, 24);
this.lblDescription.TabIndex = 1;
this.lblDescription.Text = "简介:";
//
// txtName
//
this.txtName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtName.Location = new System.Drawing.Point(104, 64);
this.txtName.MaxLength = 10;
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(104, 21);
this.txtName.TabIndex = 2;
this.txtName.Text = "";
//
// btnOk
//
this.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOk.Location = new System.Drawing.Point(112, 256);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(64, 23);
this.btnOk.TabIndex = 3;
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(104, 104);
this.txtPwd1.MaxLength = 10;
this.txtPwd1.Name = "txtPwd1";
this.txtPwd1.PasswordChar = '*';
this.txtPwd1.Size = new System.Drawing.Size(104, 21);
this.txtPwd1.TabIndex = 2;
this.txtPwd1.Text = "";
//
// txtPwd2
//
this.txtPwd2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtPwd2.Location = new System.Drawing.Point(104, 144);
this.txtPwd2.MaxLength = 10;
this.txtPwd2.Name = "txtPwd2";
this.txtPwd2.PasswordChar = '*';
this.txtPwd2.Size = new System.Drawing.Size(104, 21);
this.txtPwd2.TabIndex = 2;
this.txtPwd2.Text = "";
//
// txtDescription
//
this.txtDescription.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtDescription.Location = new System.Drawing.Point(104, 176);
this.txtDescription.MaxLength = 300;
this.txtDescription.Multiline = true;
this.txtDescription.Name = "txtDescription";
this.txtDescription.Size = new System.Drawing.Size(176, 56);
this.txtDescription.TabIndex = 2;
this.txtDescription.Text = "";
//
// AddUser
//
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.txtName);
this.Controls.Add(this.txtPwd1);
this.Controls.Add(this.txtPwd2);
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 = "AddUser";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "添加用户";
this.Closing += new System.ComponentModel.CancelEventHandler(this.AddUser_Closing);
this.Load += new System.EventHandler(this.AddUser_Load);
this.Activated += new System.EventHandler(this.AddUser_Activated);
this.ResumeLayout(false);
}
#endregion
///
/// Handles the Load event of the AddUser control.
///
/// The source of the event.
/// The instance containing the event data.
private void AddUser_Load(object sender, System.EventArgs e)
{
ProxyMain.sbpGlobal.Text="请填写信息添加用户...";
}
private void AddUser_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
ProxyMain.AddUserOpen=false;
}
private void AddUser_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(this.txtName.Text.Trim().Length>0 && this.txtPwd1.Text.Trim().Length>0 && this.txtPwd2.Text.Trim().Length>0 )
{
if(this.txtPwd1.Text.Trim()==this.txtPwd2.Text.Trim())
{
User user=new User();
user.Name=this.txtName.Text.Trim();
user.Password=this.txtPwd1.Text.Trim();
user.Description=this.txtDescription.Text.Trim();
if(user.Create()==true)
{
this.txtName.Text=string.Empty;
this.txtPwd1.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);
}
}
}
}