Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            FormMenu fm = new FormMenu();

            fm.label2.Text = label1.Text;
            fm.Show();
            this.Hide();
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string        connstr = "server=NUBIA\\SQLEXPRESS;database=BankSavingSystem;Integrated Security=SSPI";
            SqlConnection conn    = new SqlConnection(connstr);

            conn.Open();
            SqlCommand    selectuser = new SqlCommand(("select * from Card where id = " + textBox3.Text), conn);
            SqlDataReader result     = selectuser.ExecuteReader();

            if (result.Read())
            {
                MessageBox.Show("与已有卡号重复,请重新输入卡号!");
                conn.Close();
            }
            else
            {
                conn.Close();
                conn.Open();
                SqlCommand check_pw = new SqlCommand(("select password from Yonghu where no = " + textBox1.Text), conn);
                result = check_pw.ExecuteReader();
                if (result.Read() && result.GetString(result.GetOrdinal("password")).Equals(textBox4.Text.ToString()))
                {
                    conn.Close();
                    conn.Open();
                    SqlCommand insert_card = new SqlCommand();
                    insert_card.Connection = conn;
                    string str = "INSERT INTO Card (id,balance,phone,no,rate,state)VALUES('";
                    str = str + textBox3.Text + "','";
                    str = str + textBox5.Text + "','";
                    str = str + textBox6.Text + "','";
                    str = str + textBox1.Text + "',";
                    str = str + "0.003,0)";
                    //MessageBox.Show(str);
                    insert_card.CommandText = str;
                    if (insert_card.ExecuteNonQuery() == 1)
                    {
                        if (MessageBox.Show("开户成功!", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                        {
                            FormMenu fm = new FormMenu();
                            fm.label2.Text = fm.label2.Text + textBox1.Text;
                            fm.Show();
                            this.Hide();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("密码错误!请重新输入", "提示");
                }
            }
            conn.Close();
        }
Esempio n. 3
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (label5.Text.Remove(0, 3).Equals("正常"))
     {
         string        connstr = "server=NUBIA\\SQLEXPRESS;database=BankSavingSystem;Integrated Security=SSPI";
         SqlConnection conn    = new SqlConnection(connstr);
         conn.Open();
         SqlCommand    selectuser = new SqlCommand(("select password from Yonghu where no = " + label1.Text.Remove(0, 3)), conn);
         SqlDataReader result     = selectuser.ExecuteReader();
         if (result.Read() && result.GetString(result.GetOrdinal("password")).Equals(textBox1.Text.ToString()))
         {
             if (textBox2.Text.Length < 6)
             {
                 MessageBox.Show("新密码位数不够6位!", "提示");
             }
             else if (textBox2.Text.Equals(textBox3.Text))
             {
                 conn.Close();
                 conn.Open();
                 SqlCommand deposit = new SqlCommand();
                 deposit.Connection  = conn;
                 deposit.CommandText = "update Yonghu set password = "******"where no =" + label1.Text.Remove(0, 3);
                 if (deposit.ExecuteNonQuery() == 1)
                 {
                     MessageBox.Show("修改密码成功!", "提示");
                     FormMenu fm = new FormMenu();
                     fm.label2.Text = label1.Text;
                     fm.Show();
                     this.Hide();
                     this.Close();
                 }
             }
             else
             {
                 MessageBox.Show("密码不一致!", "提示");
             }
         }
         else
         {
             MessageBox.Show("旧密码错误!", "提示");
         }
         conn.Close();
     }
     else
     {
         MessageBox.Show("账户已冻结!无法操作!", "提示");
     }
 }
Esempio n. 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            string        connstr = "server=NUBIA\\SQLEXPRESS;database=BankSavingSystem;Integrated Security=SSPI";
            SqlConnection conn    = new SqlConnection(connstr);

            conn.Open();
            SqlCommand    selectpw = new SqlCommand(("select password from Yonghu where no =" + label2.Text.Remove(0, 3)), conn);
            SqlDataReader result   = selectpw.ExecuteReader();

            if (result.Read() && result.GetString(result.GetOrdinal("password")).Equals(textBox1.Text))
            {
                conn.Close();
                conn.Open();
                SqlCommand selectbalance = new SqlCommand(("select balance from Card where no =" + label2.Text.Remove(0, 3)), conn);
                result = selectbalance.ExecuteReader();
                if (result.Read() && (double)result.GetDecimal(result.GetOrdinal("balance")) > (double)0)
                {
                    MessageBox.Show("此账号余额:" + ((double)result.GetDecimal(result.GetOrdinal("balance"))).ToString("G") + ",请取出!", "提示");
                    conn.Close();
                    this.Close();
                }
                else
                {
                    conn.Close();
                    conn.Open();
                    SqlCommand del_card = new SqlCommand();
                    del_card.Connection  = conn;
                    del_card.CommandText = "delect from Card where no =" + label2.Text.Remove(0, 3);
                    if (del_card.ExecuteNonQuery() == 1)
                    {
                        conn.Close();
                        MessageBox.Show("销户成功!", "提示");
                        FormMenu fm = new FormMenu();
                        fm.label2.Text = label2.Text;
                        fm.Show();
                        this.Hide();
                    }
                }
            }
            else
            {
                MessageBox.Show("密码错误!", "提示");
            }
        }
Esempio n. 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            int           login   = 0;
            string        connstr = "server=NUBIA\\SQLEXPRESS;database=BankSavingSystem;Integrated Security=SSPI";
            SqlConnection conn    = new SqlConnection(connstr);

            conn.Open( );

            if (textBox2.Text.Length < 6)
            {
                label4.Text = "提示:密码只能为6位!";
            }
            else
            {
                //string sql = "select password from Yonghu where no = " + textBox1.Text;
                SqlCommand    selectuser = new SqlCommand(("select password from Yonghu where no = " + textBox1.Text), conn);
                SqlDataReader result     = selectuser.ExecuteReader();
                while (result.Read())
                {
                    if (result.GetString(result.GetOrdinal("password")).Equals(textBox2.Text.ToString()))
                    {
                        login = 1;
                    }
                }
                if (login == 1)
                {
                    MessageBox.Show("登录成功!", "提示");
                    FormMenu fm = new FormMenu();
                    fm.label2.Text = fm.label2.Text + textBox1.Text;
                    fm.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("账号或密码错误!", "提示");
                }
            }
            conn.Close();
        }
Esempio n. 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            System.DateTime currentTime = new System.DateTime();
            currentTime = System.DateTime.Now;
            //取当前年
            int 年 = currentTime.Year;
            //取当前月
            int 月 = currentTime.Month;
            //取当前日
            int 日 = currentTime.Day;
            // 取当前时
            int 时 = currentTime.Hour;
            //取当前分
            int 分 = currentTime.Minute;
            //取当前秒
            int    秒  = currentTime.Second;
            string no = "" + 年 + 月 + 日 + 时 + 分 + 秒;

            if (((textBox1.Text.Equals(""))))
            {
                MessageBox.Show("请输入取款金额", "提示");
            }
            else if ((Convert.ToDouble(textBox1.Text) > Convert.ToDouble(label4.Text.Remove(0, 3))) && (Convert.ToDouble(textBox1.Text) > 0))
            {
                MessageBox.Show("余额不足,请重新输入", "提示");
            }
            else
            {
                if (label5.Text.Remove(0, 3).Equals("正常"))
                {
                    string        connstr = "server=NUBIA\\SQLEXPRESS;database=BankSavingSystem;Integrated Security=SSPI";
                    SqlConnection conn    = new SqlConnection(connstr);
                    conn.Open();
                    SqlCommand note = new SqlCommand();
                    note.Connection  = conn;
                    note.CommandText = "insert into Action (no,time,id,money,type)values('" + no + "','" + System.DateTime.Now.ToString() + "','" + label2.Text.Remove(0, 3) + "','" + textBox1.Text + "','0')";
                    if (note.ExecuteNonQuery() == 1)
                    {
                        conn.Close();
                        conn.Open();
                        SqlCommand deposit = new SqlCommand();
                        deposit.Connection  = conn;
                        deposit.CommandText = "update Card set balance = balance -" + textBox1.Text + "where no =" + label1.Text.Remove(0, 3);
                        if (deposit.ExecuteNonQuery() == 1)
                        {
                            conn.Close();
                            conn.Open();
                            SqlCommand    check_balance = new SqlCommand(("select * from Card where no = " + label1.Text.Remove(0, 3)), conn);
                            SqlDataReader result        = check_balance.ExecuteReader();
                            if (result.Read())
                            {
                                MessageBox.Show("取款成功!\n当前余额:" + ((double)result.GetDecimal(result.GetOrdinal("balance"))).ToString("G"), "提示");
                                FormMenu fm = new FormMenu();
                                fm.label2.Text = label1.Text;
                                fm.Show();
                                this.Hide();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("记录无法保存,取款失败!", "提示");
                    }
                }
                else
                {
                    MessageBox.Show("账户状态冻结,取款失败!", "提示");
                }
            }
        }