using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace OAM { public partial class frmChangePWD : Form { public frmChangePWD() { InitializeComponent(); } private void cmdOK_Click(object sender, EventArgs e) { if (txtOldPwd.Text.Length > 20 || txtNewPwd.Text.Length > 20 || txtCheckPwd.Text.Length > 20) { MessageBox.Show("密码长度太长,不能多于20位"); return; } if(txtNewPwd.Text!=txtCheckPwd.Text) { MessageBox.Show("验证码和新密码不匹配"); return; } if (CheckPassword(txtOldPwd.Text) == false) { MessageBox.Show("你的老密码不正确,请重新输入"); return; } //if (UpdatePassword(txtOldPwd.Text, txtNewPwd.Text) == true) //{ // MessageBox.Show("密码已修改"); //} DAL.ClsUser oUser = new DAL.ClsUser(); oUser.UserCode = DBUtility.ClsPub.CurUserName; oUser.Psd = DBUtility.ClsPub.StrToPsd(txtNewPwd.Text.Trim()); if (oUser.ChangePsd()) { MessageBox.Show("修改完毕!", "提示"); this.Close(); } else { MessageBox.Show("修改失败!", "提示"); } } public bool UpdatePassword(string OldPwd, string NewPwd) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); oCn.RunProc("Update Gy_Czygl Set czmm='" + NewPwd + "' where czymc='" + DBUtility.ClsPub.CurUserName + "'"); return true; } public bool CheckPassword(string OldPwd) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet Ds; Ds = oCn.RunProcReturn("Select * from Gy_Czygl where czmm='" +DBUtility.ClsPub.StrToPsd(OldPwd) + "' and czymc='" + DBUtility.ClsPub.CurUserName + "'", "Gy_Czygl"); if (Ds == null || Ds.Tables[0].Rows.Count == 0) { return false; } return true; } private void frmChangePWD_Load(object sender, EventArgs e) { txtCheckPwd.Text = ""; txtNewPwd.Text = ""; txtOldPwd.Text = ""; } private void cmdCancel_Click(object sender, EventArgs e) { this.Close(); } } }