📄 chgpsw.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
namespace StudentManagementsystem
{
/// <summary>
/// ChgPsw 的摘要说明。
/// </summary>
public class ChgPsw : System.Windows.Forms.Form
{
private System.Windows.Forms.Button ChgPswCanl;
private System.Windows.Forms.Button ChgPswOk;
private System.Windows.Forms.TextBox ConfPsw;
private System.Windows.Forms.TextBox NewPsw;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
///
private string PswStrCon;
private SqlConnection PswConn;
private String PswStrComd;
private SqlCommand PswComd;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.ComponentModel.Container components = null;
public ChgPsw()
{
//
// 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.ChgPswCanl = new System.Windows.Forms.Button();
this.ChgPswOk = new System.Windows.Forms.Button();
this.ConfPsw = new System.Windows.Forms.TextBox();
this.NewPsw = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.SuspendLayout();
//
// ChgPswCanl
//
this.ChgPswCanl.Location = new System.Drawing.Point(112, 96);
this.ChgPswCanl.Name = "ChgPswCanl";
this.ChgPswCanl.Size = new System.Drawing.Size(80, 24);
this.ChgPswCanl.TabIndex = 15;
this.ChgPswCanl.Text = "取消";
this.ChgPswCanl.Click += new System.EventHandler(this.ChgPswCanl_Click);
//
// ChgPswOk
//
this.ChgPswOk.Location = new System.Drawing.Point(16, 96);
this.ChgPswOk.Name = "ChgPswOk";
this.ChgPswOk.Size = new System.Drawing.Size(80, 24);
this.ChgPswOk.TabIndex = 14;
this.ChgPswOk.Text = "确认";
this.ChgPswOk.Click += new System.EventHandler(this.ChgPswOk_Click);
//
// ConfPsw
//
this.ConfPsw.Location = new System.Drawing.Point(96, 48);
this.ConfPsw.Name = "ConfPsw";
this.ConfPsw.Size = new System.Drawing.Size(96, 21);
this.ConfPsw.TabIndex = 13;
this.ConfPsw.Text = "";
//
// NewPsw
//
this.NewPsw.Location = new System.Drawing.Point(96, 24);
this.NewPsw.Name = "NewPsw";
this.NewPsw.Size = new System.Drawing.Size(96, 21);
this.NewPsw.TabIndex = 12;
this.NewPsw.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(32, 48);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 16);
this.label3.TabIndex = 10;
this.label3.Text = "确认密码:";
//
// label2
//
this.label2.Location = new System.Drawing.Point(32, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 16);
this.label2.TabIndex = 9;
this.label2.Text = "新密码:";
//
// groupBox1
//
this.groupBox1.Location = new System.Drawing.Point(8, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(192, 80);
this.groupBox1.TabIndex = 16;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "信息";
//
// groupBox2
//
this.groupBox2.Location = new System.Drawing.Point(8, 80);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(192, 48);
this.groupBox2.TabIndex = 17;
this.groupBox2.TabStop = false;
//
// ChgPsw
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(208, 141);
this.Controls.Add(this.ChgPswCanl);
this.Controls.Add(this.ChgPswOk);
this.Controls.Add(this.ConfPsw);
this.Controls.Add(this.NewPsw);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox2);
this.Name = "ChgPsw";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "密码修改";
this.ResumeLayout(false);
}
#endregion
private void ChgPswCanl_Click(object sender, System.EventArgs e)
{
if(MessageBox.Show("您确认要退出?","确认",MessageBoxButtons.YesNo)==DialogResult.Yes)
this.Close();
}
private void ChgPswOk_Click(object sender, System.EventArgs e)
{
if(NewPsw.Text.ToString().Trim()==ConfPsw.Text.ToString().Trim())
{
PswStrCon="workstation id=localhost;Integrated Security=SSPI;database=StuMagSys";
PswStrComd="update Syuser set Password="+"'"+NewPsw.Text.ToString().Trim()+"'"+" where Use_name="+"'"+Login.Username+"'";
PswConn=new SqlConnection(PswStrCon);
PswConn.Open();
PswComd=new SqlCommand(PswStrComd,PswConn);
int Succnum=PswComd.ExecuteNonQuery();
if(Succnum>0) MessageBox.Show("密码修改成功");
}
else
{
MessageBox.Show("密码不一致,请重新输入","确认",MessageBoxButtons.OK);
NewPsw.Text="";
ConfPsw.Text="";
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -