📄 form_grzhgl.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace bizdb
{
/// <summary>
/// Form_grzhgl 的摘要说明。
/// </summary>
public class Form_grzhgl : System.Windows.Forms.Form
{
private System.Windows.Forms.Label yhm;
private System.Windows.Forms.Label lbl_jmm;
private System.Windows.Forms.Label lbl_xmm;
private System.Windows.Forms.Label lbl_qrxmm;
private System.Windows.Forms.TextBox txt_yhm;
private System.Windows.Forms.TextBox txt_jmm;
private System.Windows.Forms.TextBox txt_xmm;
private System.Windows.Forms.TextBox txt_qrxmm;
private System.Windows.Forms.Button btn_qd;
private System.Windows.Forms.Button btn_qx;
private common c = new common();
private dbAccess db = new dbAccess();
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form_grzhgl()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.yhm = new System.Windows.Forms.Label();
this.lbl_jmm = new System.Windows.Forms.Label();
this.lbl_xmm = new System.Windows.Forms.Label();
this.lbl_qrxmm = new System.Windows.Forms.Label();
this.txt_yhm = new System.Windows.Forms.TextBox();
this.txt_jmm = new System.Windows.Forms.TextBox();
this.txt_xmm = new System.Windows.Forms.TextBox();
this.txt_qrxmm = new System.Windows.Forms.TextBox();
this.btn_qd = new System.Windows.Forms.Button();
this.btn_qx = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// yhm
//
this.yhm.Location = new System.Drawing.Point(272, 144);
this.yhm.Name = "yhm";
this.yhm.TabIndex = 0;
this.yhm.Text = "用户名";
//
// lbl_jmm
//
this.lbl_jmm.Location = new System.Drawing.Point(272, 192);
this.lbl_jmm.Name = "lbl_jmm";
this.lbl_jmm.TabIndex = 1;
this.lbl_jmm.Text = "旧密码";
//
// lbl_xmm
//
this.lbl_xmm.Location = new System.Drawing.Point(272, 240);
this.lbl_xmm.Name = "lbl_xmm";
this.lbl_xmm.TabIndex = 2;
this.lbl_xmm.Text = "新密码";
//
// lbl_qrxmm
//
this.lbl_qrxmm.Location = new System.Drawing.Point(272, 288);
this.lbl_qrxmm.Name = "lbl_qrxmm";
this.lbl_qrxmm.TabIndex = 3;
this.lbl_qrxmm.Text = "确认新密码";
//
// txt_yhm
//
this.txt_yhm.Enabled = false;
this.txt_yhm.Location = new System.Drawing.Point(384, 144);
this.txt_yhm.Name = "txt_yhm";
this.txt_yhm.TabIndex = 4;
this.txt_yhm.Text = "";
//
// txt_jmm
//
this.txt_jmm.Location = new System.Drawing.Point(384, 192);
this.txt_jmm.Name = "txt_jmm";
this.txt_jmm.PasswordChar = '*';
this.txt_jmm.TabIndex = 5;
this.txt_jmm.Text = "";
//
// txt_xmm
//
this.txt_xmm.Location = new System.Drawing.Point(384, 240);
this.txt_xmm.Name = "txt_xmm";
this.txt_xmm.PasswordChar = '*';
this.txt_xmm.TabIndex = 6;
this.txt_xmm.Text = "";
//
// txt_qrxmm
//
this.txt_qrxmm.Location = new System.Drawing.Point(384, 288);
this.txt_qrxmm.Name = "txt_qrxmm";
this.txt_qrxmm.PasswordChar = '*';
this.txt_qrxmm.TabIndex = 7;
this.txt_qrxmm.Text = "";
//
// btn_qd
//
this.btn_qd.Location = new System.Drawing.Point(272, 336);
this.btn_qd.Name = "btn_qd";
this.btn_qd.TabIndex = 8;
this.btn_qd.Text = "确定";
this.btn_qd.Click += new System.EventHandler(this.btn_qd_Click);
//
// btn_qx
//
this.btn_qx.Location = new System.Drawing.Point(408, 336);
this.btn_qx.Name = "btn_qx";
this.btn_qx.TabIndex = 9;
this.btn_qx.Text = "取消";
this.btn_qx.Click += new System.EventHandler(this.btn_qx_Click);
//
// Form_grzhgl
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(792, 573);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btn_qx,
this.btn_qd,
this.txt_qrxmm,
this.txt_xmm,
this.txt_jmm,
this.txt_yhm,
this.lbl_qrxmm,
this.lbl_xmm,
this.lbl_jmm,
this.yhm});
this.Name = "Form_grzhgl";
this.Text = "个人帐号管理";
this.Load += new System.EventHandler(this.grzhgl_Load);
this.ResumeLayout(false);
}
#endregion
private void grzhgl_Load(object sender, System.EventArgs e)
{
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.ControlBox = false;
txt_yhm.Text = c.emplid;
}
private void btn_qd_Click(object sender, System.EventArgs e)
{
SqlConnection myConn = new SqlConnection();
myConn.ConnectionString = db.connStr;
string strCom = "SELECT empd_password FROM employeeDictionary WHERE emp_id='" + c.emplid +"'";
System.Data.SqlClient.SqlCommand comm;
comm = myConn.CreateCommand();
comm.CommandText = strCom;
SqlDataAdapter mydataA= new SqlDataAdapter();
mydataA.SelectCommand = comm;
DataSet myDataSet = new DataSet ( ) ;
myConn.Open( );
mydataA.Fill(myDataSet,"employeedictionary");
myConn.Close ( ) ;
string str=myDataSet.Tables["employeedictionary"].Rows[0]["empd_password"].ToString();
if(txt_jmm.Text == str)
{
if(txt_xmm.Text == txt_qrxmm.Text)
{
try
{
strCom = "UPDATE employeeDictionary SET empd_password = @pass WHERE emp_id = @id";
comm = myConn.CreateCommand();
comm.CommandText = strCom;
comm.Parameters.Add("@pass",System.Data.SqlDbType.VarChar);
comm.Parameters["@pass"].Value = this.txt_xmm.Text;
comm.Parameters.Add("@id",System.Data.SqlDbType.Char);
comm.Parameters["@id"].Value = c.emplid;
//mydataA.UpdateCommand = comm;
myConn.Open();
int i =comm.ExecuteNonQuery();
//mydataA.Update(myDataSet,"employeedictionary");
myConn.Close();
if(i==1)
{
MessageBox.Show("密码修改成功");
txt_jmm.Text = "";
txt_xmm.Text = "";
txt_qrxmm.Text = "";
}
}
catch(System.Exception mass)
{
MessageBox.Show(mass.Message);
}
}
else
{
MessageBox.Show("输入的新密码不匹配,请确认");
}
}
else
{
MessageBox.Show("旧密码错误");
}
}
private void btn_qx_Click(object sender, System.EventArgs e)
{
txt_jmm.Text = "";
txt_xmm.Text = "";
txt_qrxmm.Text = "";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -