c#编程修改密码的代码

时间:2022-07-13 23:14:19 阅读: 最新文章 文档下载
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。
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.wddqw.com/doc/c4692fedf8c75fbfc77db27c.html