Esempio n. 1
0
        private void Dbutton1_Click(object sender, EventArgs e)
        {
            hidePanel();
            double          plus   = Convert.ToDouble(DtextBox.Text);
            string          constr = "server=localhost;User Id=root;password=919881;Database=atm";
            MySqlConnection mycon  = new MySqlConnection(constr);

            mycon.Open();
            MySqlCommand    mycmd  = new MySqlCommand("SELECT Abalance FROM account WHERE Anum = '" + Number + "'", mycon);
            MySqlDataReader reader = mycmd.ExecuteReader();

            if (reader.Read())
            {
                if (reader.HasRows)
                {
                    plus = (double)reader["Abalance"] + plus;
                }
            }
            reader.Close();
            mycmd = new MySqlCommand("UPDATE account SET Abalance = '" + plus + "'WHERE Anum = '" + Number + "'", mycon);
            mycmd.ExecuteNonQuery();

            mycon.Close();

            Qpanel.Show();
            QLabel.Text = "存款成功";
        }
Esempio n. 2
0
 public void hidePanel()
 {
     Qpanel.Hide();
     Tpanel.Hide();
     Cpanel.Hide();
     Dpanel.Hide();
     Wpanel.Hide();
 }
Esempio n. 3
0
        private void Tbutton1_Click(object sender, EventArgs e)
        {
            hidePanel();
            string          toID     = TtextBox1.Text;
            double          reduce   = Convert.ToDouble(TtextBox2.Text);
            double          balance1 = 0;
            double          balance2 = 0;
            string          constr   = "server=localhost;User Id=root;password=919881;Database=atm";
            MySqlConnection mycon    = new MySqlConnection(constr);

            mycon.Open();
            MySqlCommand    mycmd  = new MySqlCommand("SELECT Abalance FROM account WHERE Anum = '" + Number + "'", mycon);
            MySqlDataReader reader = mycmd.ExecuteReader();

            if (reader.Read())
            {
                if (reader.HasRows)
                {
                    balance1 = (double)reader["Abalance"] - reduce;
                }
            }
            if (balance1 < 0)
            {
                reader.Close();
                mycon.Close();
                Qpanel.Show();
                QLabel.Text = "余额不足";
            }
            else
            {
                reader.Close();
                mycmd = new MySqlCommand("UPDATE account SET Abalance = '" + balance1 + "'WHERE Anum = '" + Number + "'", mycon);
                mycmd.ExecuteNonQuery();

                mycmd  = new MySqlCommand("SELECT Abalance FROM account WHERE Anum = '" + toID + "'", mycon);
                reader = mycmd.ExecuteReader();
                if (reader.Read())
                {
                    if (reader.HasRows)
                    {
                        balance2 = (double)reader["Abalance"] + reduce;
                    }
                }
                reader.Close();
                mycmd = new MySqlCommand("UPDATE account SET Abalance = '" + balance2 + "'WHERE Anum = '" + toID + "'", mycon);
                mycmd.ExecuteNonQuery();
                mycon.Close();
                Qpanel.Show();
                QLabel.Text = "转账成功";
            }
        }
Esempio n. 4
0
        private void PButton1_Click(object sender, EventArgs e)
        {
            hidePanel();
            string newPIN = CtextBox.Text;

            string          constr = "server=localhost;User Id=root;password=919881;Database=atm";
            MySqlConnection mycon  = new MySqlConnection(constr);

            mycon.Open();
            MySqlCommand mycmd = new MySqlCommand("UPDATE account SET Apin = '" + newPIN + "'WHERE Anum = '" + Number + "'", mycon);

            mycmd.ExecuteNonQuery();
            mycon.Close();

            Qpanel.Show();
            QLabel.Text = "修改成功";
        }
Esempio n. 5
0
        private void queryButton_Click(object sender, EventArgs e)      //查询余额
        {
            double temp;

            Qpanel.Show();
            hideButton();
            string          constr = "server=localhost;User Id=root;password=919881;Database=atm";
            MySqlConnection mycon  = new MySqlConnection(constr);

            mycon.Open();
            MySqlCommand    mycmd  = new MySqlCommand("SELECT  Abalance FROM account WHERE account.Anum = " + Number, mycon);
            MySqlDataReader reader = mycmd.ExecuteReader();

            if (reader.Read())
            {
                if (reader.HasRows)
                {
                    temp        = (double)reader["Abalance"];
                    QLabel.Text = "余额:" + temp;
                }
            }
            reader.Close();
            mycon.Close();
        }