📄 changepwd.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using GzglClient.BLL;
using Jinrm.Data;
namespace GzglClient.Froms
{
/// <summary>
/// ChangePwd 的摘要说明。
/// </summary>
public class ChangePwd : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button btnCanel;
private System.Windows.Forms.Button btnAccept;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.TextBox txtUserName;
private System.Windows.Forms.TextBox txtUserPwd;
private System.Windows.Forms.TextBox txtNewPwd;
private System.Windows.Forms.TextBox txtNewPwd2;
public ChangePwd()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// 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.groupBox1 = new System.Windows.Forms.GroupBox();
this.txtNewPwd2 = new System.Windows.Forms.TextBox();
this.txtNewPwd = new System.Windows.Forms.TextBox();
this.txtUserPwd = new System.Windows.Forms.TextBox();
this.txtUserName = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.btnAccept = new System.Windows.Forms.Button();
this.btnCanel = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.txtNewPwd2);
this.groupBox1.Controls.Add(this.txtNewPwd);
this.groupBox1.Controls.Add(this.txtUserPwd);
this.groupBox1.Controls.Add(this.txtUserName);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(8, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(320, 136);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "密码修改";
//
// txtNewPwd2
//
this.txtNewPwd2.Location = new System.Drawing.Point(96, 96);
this.txtNewPwd2.Name = "txtNewPwd2";
this.txtNewPwd2.Size = new System.Drawing.Size(184, 21);
this.txtNewPwd2.TabIndex = 7;
this.txtNewPwd2.Text = "";
//
// txtNewPwd
//
this.txtNewPwd.Location = new System.Drawing.Point(96, 72);
this.txtNewPwd.Name = "txtNewPwd";
this.txtNewPwd.Size = new System.Drawing.Size(184, 21);
this.txtNewPwd.TabIndex = 6;
this.txtNewPwd.Text = "";
//
// txtUserPwd
//
this.txtUserPwd.Location = new System.Drawing.Point(96, 48);
this.txtUserPwd.Name = "txtUserPwd";
this.txtUserPwd.Size = new System.Drawing.Size(184, 21);
this.txtUserPwd.TabIndex = 5;
this.txtUserPwd.Text = "";
//
// txtUserName
//
this.txtUserName.Enabled = false;
this.txtUserName.Location = new System.Drawing.Point(96, 24);
this.txtUserName.Name = "txtUserName";
this.txtUserName.Size = new System.Drawing.Size(184, 21);
this.txtUserName.TabIndex = 4;
this.txtUserName.Text = "";
//
// label4
//
this.label4.Location = new System.Drawing.Point(24, 96);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(70, 15);
this.label4.TabIndex = 3;
this.label4.Text = "确认密码:";
//
// label3
//
this.label3.Location = new System.Drawing.Point(24, 72);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(70, 15);
this.label3.TabIndex = 2;
this.label3.Text = "新密码:";
//
// label2
//
this.label2.Location = new System.Drawing.Point(24, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(70, 15);
this.label2.TabIndex = 1;
this.label2.Text = "原密码:";
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(70, 15);
this.label1.TabIndex = 0;
this.label1.Text = "用户名:";
//
// btnAccept
//
this.btnAccept.Location = new System.Drawing.Point(152, 152);
this.btnAccept.Name = "btnAccept";
this.btnAccept.TabIndex = 1;
this.btnAccept.Text = "确定";
this.btnAccept.Click += new System.EventHandler(this.btnAccept_Click);
//
// btnCanel
//
this.btnCanel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCanel.Location = new System.Drawing.Point(240, 152);
this.btnCanel.Name = "btnCanel";
this.btnCanel.TabIndex = 2;
this.btnCanel.Text = "取消";
this.btnCanel.Click += new System.EventHandler(this.btnCanel_Click);
//
// ChangePwd
//
this.AcceptButton = this.btnAccept;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.CancelButton = this.btnCanel;
this.ClientSize = new System.Drawing.Size(336, 186);
this.Controls.Add(this.btnCanel);
this.Controls.Add(this.btnAccept);
this.Controls.Add(this.groupBox1);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(344, 220);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(344, 220);
this.Name = "ChangePwd";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "密码修改";
this.Load += new System.EventHandler(this.ChangePwd_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void btnCanel_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void btnAccept_Click(object sender, System.EventArgs e)
{
if(txtNewPwd.Text == txtNewPwd2.Text)
{
DoAccess conn = new DoAccess("Data\\DataAcc.mdb");
if(conn.GetTableCount("UserInfo","UserName = '管理员' and UserPwd = '"+ txtUserPwd.Text +"' ") == 1)
{
conn.ExecUpdate("UserInfo","UserPwd = '"+ txtNewPwd.Text +"' ","UserId = '1' ");
this.DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show("原密码不正确!");
}
}
else
{
MessageBox.Show("新密码两次输入不一样!");
}
}
private void ChangePwd_Load(object sender, System.EventArgs e)
{
txtUserName.Text = AllStr.UserName;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -