📄 changepassword.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
namespace Eboer.MIS.MF.WinForm
{
/// <summary>
/// ChangePassword 的摘要说明。
/// </summary>
public class ChangePassword : 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.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TextBox rp;
private System.Windows.Forms.TextBox np;
private System.Windows.Forms.TextBox op;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public ChangePassword()
{
//
// 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.rp = new System.Windows.Forms.TextBox();
this.np = new System.Windows.Forms.TextBox();
this.op = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.rp);
this.groupBox1.Controls.Add(this.np);
this.groupBox1.Controls.Add(this.op);
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(272, 112);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
//
// rp
//
this.rp.Location = new System.Drawing.Point(72, 72);
this.rp.Name = "rp";
this.rp.PasswordChar = '*';
this.rp.Size = new System.Drawing.Size(184, 21);
this.rp.TabIndex = 5;
this.rp.Text = "";
//
// np
//
this.np.Location = new System.Drawing.Point(72, 48);
this.np.Name = "np";
this.np.PasswordChar = '*';
this.np.Size = new System.Drawing.Size(184, 21);
this.np.TabIndex = 4;
this.np.Text = "";
//
// op
//
this.op.Location = new System.Drawing.Point(72, 24);
this.op.Name = "op";
this.op.PasswordChar = '*';
this.op.Size = new System.Drawing.Size(184, 21);
this.op.TabIndex = 3;
this.op.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(16, 80);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(64, 16);
this.label3.TabIndex = 2;
this.label3.Text = "确认密码";
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 56);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 16);
this.label2.TabIndex = 1;
this.label2.Text = "新 密 码";
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(64, 16);
this.label1.TabIndex = 0;
this.label1.Text = "原 密 码";
//
// button1
//
this.button1.Location = new System.Drawing.Point(144, 128);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(72, 23);
this.button1.TabIndex = 1;
this.button1.Text = "确认修改";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(216, 128);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(64, 23);
this.button2.TabIndex = 2;
this.button2.Text = "取 消";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// ChangePassword
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(290, 167);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ChangePassword";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "修改密码";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 确认修改
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, System.EventArgs e) {
if(this.op.Text.Trim() != Public.passCH){
MessageBox.Show("原密码有误!");
return;
}
if(this.np.Text.Trim() == ""){
MessageBox.Show("登录密码不能为空!");
return;
}
if(this.np.Text != this.rp.Text){
MessageBox.Show("确认密码与新密码不一致,请重新输入!");
return;
}
try{
Public.CloseConn();
Public.conn.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = "UPDATE SInfo set pwd='"+ this.np.Text +"' where username='"+ Public.userID +"'";
cmd.Connection = Public.conn;
cmd.ExecuteNonQuery();
Public.conn.Close();
Public.passCH = this.np.Text.Trim();
MessageBox.Show("修改成功!");
this.Close();
}catch(Exception ex){
MessageBox.Show(ex.Message.ToString());
return;
}
}
/// <summary>
/// 取消
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, System.EventArgs e) {
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -