【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《c#编程修改密码的代码》,欢迎阅读!
C#修改密码的代码
public FrmXiuGaiMiMa() {
InitializeComponent(); }
private bool JudgeNewPwd() {
string newPwd1 = this.txtNewPwd1.Text; string newPwd2 = this.txtNewPwd2.Text; if (newPwd1.Equals(newPwd2)) return true; else
MessageBox.Show("两次输入的新密码不相等,请重新输入!","系统提示"); return false; }
private bool Confirmation() {
if (this.txtName.Text != string.Empty && this.txtOldPwd.Text !=
string.Empty&&this .txtNewPwd1 .Text !=string .Empty &&this .txtNewPwd2 .Text !=string .Empty ) return true; else
MessageBox.Show("用户名和密码不能为空!", "系统提示");
return false; }
private void Form4_Load(object sender, EventArgs e) {
}
private void button2_Click(object sender, EventArgs e) {
this.Close(); }
private void button1_Click(object sender, EventArgs
e) {
if (Confirmation()) {
if (JudgeNewPwd()) {
string oldPwd = this.txtOldPwd.Text; string uname = this.txtName.Text; string newPwd1 = this.txtNewPwd1.Text.ToString ();
string sql = string.Format("update _UserInfo set UPassWord='{0}' where UPassWord='{1} 'and UName='{2}'",newPwd1 ,oldPwd ,uname );
if (DataAccess.UpdataDataTable(sql))
MessageBox.Show("修改成功!", "系统提示"); else
MessageBox.Show("修改失败!","系统提示"); } }
}
本文来源:https://www.wddqxz.cn/c4692fedf8c75fbfc77db27c.html