📄 frmupdate.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace prjClass
{
/// <summary>
/// frmUpdate 的摘要说明。
/// </summary>
///
public delegate void UpdatHandler();
public class frmUpdate : System.Windows.Forms.Form
{
public event UpdatHandler UpdateEvent;
private string user;
private System.Windows.Forms.ComboBox cbopur;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.TextBox txtPwd1;
private System.Windows.Forms.TextBox txtPwd;
private System.Windows.Forms.TextBox txtName;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Label label1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public frmUpdate(string user)
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
this.user=user;
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.cbopur = new System.Windows.Forms.ComboBox();
this.label4 = new System.Windows.Forms.Label();
this.btnCancel = new System.Windows.Forms.Button();
this.txtPwd1 = new System.Windows.Forms.TextBox();
this.txtPwd = new System.Windows.Forms.TextBox();
this.txtName = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.btnOK = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// cbopur
//
this.cbopur.Location = new System.Drawing.Point(112, 215);
this.cbopur.Name = "cbopur";
this.cbopur.Size = new System.Drawing.Size(176, 20);
this.cbopur.TabIndex = 17;
this.cbopur.Text = "comboBox1";
//
// label4
//
this.label4.Location = new System.Drawing.Point(40, 215);
this.label4.Name = "label4";
this.label4.TabIndex = 16;
this.label4.Text = "权限";
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(208, 271);
this.btnCancel.Name = "btnCancel";
this.btnCancel.TabIndex = 15;
this.btnCancel.Text = "取消";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// txtPwd1
//
this.txtPwd1.Location = new System.Drawing.Point(112, 154);
this.txtPwd1.Name = "txtPwd1";
this.txtPwd1.PasswordChar = '*';
this.txtPwd1.Size = new System.Drawing.Size(176, 21);
this.txtPwd1.TabIndex = 12;
this.txtPwd1.Text = "";
//
// txtPwd
//
this.txtPwd.Location = new System.Drawing.Point(112, 95);
this.txtPwd.Name = "txtPwd";
this.txtPwd.PasswordChar = '*';
this.txtPwd.Size = new System.Drawing.Size(176, 21);
this.txtPwd.TabIndex = 10;
this.txtPwd.Text = "";
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(112, 39);
this.txtName.Name = "txtName";
this.txtName.ReadOnly = true;
this.txtName.Size = new System.Drawing.Size(176, 21);
this.txtName.TabIndex = 9;
this.txtName.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(40, 154);
this.label3.Name = "label3";
this.label3.TabIndex = 14;
this.label3.Text = "密码确认";
//
// label2
//
this.label2.Location = new System.Drawing.Point(40, 95);
this.label2.Name = "label2";
this.label2.TabIndex = 11;
this.label2.Text = "密码";
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(56, 271);
this.btnOK.Name = "btnOK";
this.btnOK.TabIndex = 13;
this.btnOK.Text = "确认";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(40, 39);
this.label1.Name = "label1";
this.label1.TabIndex = 8;
this.label1.Text = "用户名";
//
// frmUpdate
//
this.AcceptButton = this.btnOK;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(328, 333);
this.Controls.Add(this.cbopur);
this.Controls.Add(this.label4);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.txtPwd1);
this.Controls.Add(this.txtPwd);
this.Controls.Add(this.txtName);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.Name = "frmUpdate";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "frmUpdate";
this.Load += new System.EventHandler(this.frmUpdate_Load);
this.ResumeLayout(false);
}
#endregion
private void frmUpdate_Load(object sender, System.EventArgs e)
{
this.txtName.Text=this.user;
this.cbopur.Items.Add("超级用户");
this.cbopur.Items.Add("普通用户");
this.cbopur.SelectedIndex=0;
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void btnOK_Click(object sender, System.EventArgs e)
{
Class1 c = new Class1();
string Sql = "update Class..UserInfo set userPwd = '"+this.txtPwd.Text+"', userPur = '"+this.cbopur.SelectedItem.ToString()+"' where UserID = '"+this.txtName.Text+"'";
if(this.txtPwd.Text!=this.txtPwd1.Text)
{
MessageBox.Show("两次输入密码不一致","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
}
else if(this.txtPwd.Text=="")
{
MessageBox.Show("密码不能为空","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
}
else
{
if(this.UpdateEvent!=null)
{
c.EditData(Sql);
this.UpdateEvent();
this.Close();
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -