c#ATM之找回密码篇

接上面一篇:c#ATM之登录篇

在这里插入图片描述
1.先添加一行命名空间,如果没有这一行代码,下面的代码绝对会出错

using System.Data.SqlClient;`
		public Form2()
        {
            InitializeComponent();
        }

        Form1 f01;
        public Form2(Form1 f1)//隐藏父窗体,然后通过but2 show出来
        {
            InitializeComponent();
            f01 = f1;
        }

2.为textBox3设置密码掩字符

private void textBox3_TextChanged(object sender, EventArgs e)
        {
            textBox3.PasswordChar = '*';
        }

3.验证卡号与凭证是否匹配

private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" & textBox2.Text == "" & textBox3.Text == "")
            {
                MessageBox.Show("不能留空哦");
            }
            else
            {
                string count = "SERVER=.;DATABASE=OX;USER=SA;PWD=1;";
                //string sql= "update  server set pwd='" + textBox3.Text.Trim() + "'where sno='"+textBox1.Text+"'where sfz='"+textBox2.Text+"'";
                string sql = "update USERR set pwd='" + textBox3.Text + "'where  ID='" + textBox1.Text.Trim() + "'AND ID IN(SELECT ID FROM DATA WHERE SFZ='"+textBox2.Text+"')";
                //UPDATE USERR SET PWD='12' WHERE ID='123' AND  ID IN(SELECT ID FROM DATA WHERE SFZ='9876')
                SqlConnection con = new SqlConnection(count);//创建连接对象
                con.Open();
                SqlCommand cmd = new SqlCommand(sql, con);//创建操作对象
                if (cmd.ExecuteNonQuery()>0)
                {
                    MessageBox.Show("修改成功");
                    Form1 f1 = new Form1();
                    this.button1.Visible = true;
                    //this.button2.Visible = true;
                    this.textBox1.Visible = true;
                    this.textBox2.Visible = true;
                    this.label1.Visible = true;
                    this.label2.Visible = true;
                    this.label3.Visible = true;
                    f01.Hide();
                    f1.Show();
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
            }
        }

这是上篇c#ATM之登录篇 https://blog.csdn.net/I_TenKai/article/details/84558647

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Izrj

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值