private void btnqd_Click(object sender, EventArgs e) { if (txtpwd.Text.Trim() == "" || txttpwd.Text.Trim() == "" || txtoldpwd.Text.Trim() == "") { txtpwd.Text = ""; txttpwd.Text = ""; txtoldpwd.Text = ""; MessageBox.Show("输入的密码不能为空!"); return; } if (txtpwd.Text.Trim() != txttpwd.Text.Trim()) { txtpwd.Text = ""; txttpwd.Text = ""; txtoldpwd.Text = ""; MessageBox.Show("新输入的2次密码不一样,请重新输入!"); return; } string oldpwd = UserPublicClass.MD5(txtoldpwd.Text.Trim()); if (UserPublicClass.PWDValue != oldpwd) { txtpwd.Text = ""; txttpwd.Text = ""; txtoldpwd.Text = ""; MessageBox.Show("原密码错误,请重新输入!"); return; } string newpwd = UserPublicClass.MD5(txtpwd.Text.Trim()); if (UserPublicClass.PWDValue == newpwd) { txtpwd.Text = ""; txttpwd.Text = ""; txtoldpwd.Text = ""; MessageBox.Show("新旧密码一样,请重新输入!"); return; } if (db.UpdatePWD(UserPublicClass.LoginValue, newpwd) == 0) { MessageBox.Show("修改错误!"); } else { MessageBox.Show("修改成功!"); this.Hide(); } }
void BtnLogin() { if (db.strCon() == "") { MessageBox.Show("数据库连接错误!请检查!"); } string UserLogin = txtlogin.Text.Trim(); string UserPwd = UserPublicClass.MD5(txtpwd.Text.Trim()); string ErrorMsg = CheckVaile(UserLogin, UserPwd); if (ErrorMsg != "") { MessageBox.Show(ErrorMsg); } else { HZLMain m = new HZLMain(); m.Show(); this.Hide(); } }