📄 frmpwd.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace prjClass
{
/// <summary>
/// frmPwd 的摘要说明。
/// </summary>
public class frmPwd : System.Windows.Forms.Form
{
private string user;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtpwd;
private System.Windows.Forms.TextBox txtpwd1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtpwd2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancle;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public frmPwd(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.label1 = new System.Windows.Forms.Label();
this.txtpwd = new System.Windows.Forms.TextBox();
this.txtpwd1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.txtpwd2 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.btnOK = new System.Windows.Forms.Button();
this.btnCancle = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 48);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "原始密码";
//
// txtpwd
//
this.txtpwd.Location = new System.Drawing.Point(96, 48);
this.txtpwd.Name = "txtpwd";
this.txtpwd.PasswordChar = '*';
this.txtpwd.Size = new System.Drawing.Size(168, 21);
this.txtpwd.TabIndex = 1;
this.txtpwd.Text = "";
//
// txtpwd1
//
this.txtpwd1.Location = new System.Drawing.Point(96, 120);
this.txtpwd1.Name = "txtpwd1";
this.txtpwd1.PasswordChar = '*';
this.txtpwd1.Size = new System.Drawing.Size(168, 21);
this.txtpwd1.TabIndex = 3;
this.txtpwd1.Text = "";
//
// label2
//
this.label2.Location = new System.Drawing.Point(32, 120);
this.label2.Name = "label2";
this.label2.TabIndex = 2;
this.label2.Text = "新密码";
//
// txtpwd2
//
this.txtpwd2.Location = new System.Drawing.Point(96, 200);
this.txtpwd2.Name = "txtpwd2";
this.txtpwd2.PasswordChar = '*';
this.txtpwd2.Size = new System.Drawing.Size(168, 21);
this.txtpwd2.TabIndex = 5;
this.txtpwd2.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(32, 200);
this.label3.Name = "label3";
this.label3.TabIndex = 4;
this.label3.Text = "密码确认";
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(40, 272);
this.btnOK.Name = "btnOK";
this.btnOK.TabIndex = 6;
this.btnOK.Text = "确认";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnCancle
//
this.btnCancle.Location = new System.Drawing.Point(192, 272);
this.btnCancle.Name = "btnCancle";
this.btnCancle.TabIndex = 7;
this.btnCancle.Text = "取消";
this.btnCancle.Click += new System.EventHandler(this.btnCancle_Click);
//
// frmPwd
//
this.AcceptButton = this.btnOK;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(328, 333);
this.Controls.Add(this.btnCancle);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.txtpwd2);
this.Controls.Add(this.txtpwd1);
this.Controls.Add(this.txtpwd);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.Name = "frmPwd";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "密码修改";
this.ResumeLayout(false);
}
#endregion
private void btnCancle_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void btnOK_Click(object sender, System.EventArgs e)
{
string Sql = "select * from Class..UserInfo where UserID = '"+this.user+"' and UserPwd = '"+this.txtpwd.Text+"'";
string SqlUpdate = "update Class..UserInfo set userPwd = '"+this.txtpwd1.Text+"' where userID = '"+this.user+"'";
Class1 c = new Class1();
if(c.IsExits(Sql)==false)
{
MessageBox.Show("原始密码输入有误","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
}
else if(this.txtpwd1.Text!=this.txtpwd2.Text)
{
MessageBox.Show("两次密码输入不一致","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
}
else
{
c.EditData(SqlUpdate);
if(MessageBox.Show("密码修改成功!","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Information)==DialogResult.OK)
{
this.Close();
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -