改密碼sql
1. dal cardinfo changePwdthis
public bool changePwd(string CardID, string oldPwd, string newPwd)事件
{ip
string sql = "update cardinfo set pass='"+ newPwd + "' where cardID='" + CardID + "' and pass='"+oldPwd+ "' and IsReportLoss=0";string
int n = DbHelperSQL.ExecuteSql(sql);登錄
if (n >= 1)object
{date
return true;密碼
}di
else
{ return false; }
}
2. bll- cardinfo changePwd
public bool changePwd(string CardID, string oldPwd, string newPwd)
{
return dal.changePwd(CardID, oldPwd,newPwd);
}
3. winf- ChangePWD
!)增長卡號字段
public string CardID;
2)編寫按鈕點擊事件
private void button1_Click(object sender, EventArgs e)
{
label4.Text = "";
if (textBox2.Text != textBox3.Text)
{ label4.Text = "兩次新密碼不一致,請重輸!"; }
else
{
BLL.cardinfo bll = new BLL.cardinfo();
bool isOK= bll.changePwd(CardID, textBox1.Text, textBox3.Text);
if (isOK) {
MessageBox.Show("密碼修改爲功,請從新登陸!","成功");
this.DialogResult = DialogResult.OK;
}
else { label4.Text = "密碼修改失敗,請重試!"; }
}
}
4. winf-main-菜單
private void 改密碼ToolStripMenuItem_Click(object sender, EventArgs e)
{
ChangePWD cp = new ChangePWD();
cp.CardID = CardID;
DialogResult OK=cp.ShowDialog();
if (OK == DialogResult.OK) {
退出帳戶toolStripMenuItem_Click(null, null);
}
}