C#三层ATM-10.改密码

改密码

1. dal cardinfo changePwd

public bool changePwd(string CardID, string oldPwd, string newPwd)

        {

string sql = "update  cardinfo set  pass='"+ newPwd + "' where cardID='" + CardID + "' and pass='"+oldPwd+ "'  and IsReportLoss=0";

int n = DbHelperSQL.ExecuteSql(sql);

if (n >= 1)

            {

return true;

            }

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);

            }

        }

原文地址:https://www.cnblogs.com/lingr/p/5563569.html