Пример #1
0
        private void PayBtn_Click(object sender, EventArgs e)
        {
            //double pay = System.Convert.ToDouble(PayTBox.Text);
            try
            {
                double pay = System.Convert.ToDouble(PayTBox.Text);

                if (pay > getBalance())
                {
                    MessageBox.Show("储蓄卡余额不足");
                }

                else if (pay <= 0)
                {
                    MessageBox.Show("还款金额应大于0!");
                    PayTBox.Text = "";
                }

                else
                {
                    if (pay <= getUsed())
                    {
                        UsedCrdTBox.Text   = (getUsed() - pay).ToString();   // Update "已用额度" text
                        UsableCrdTBox.Text = (getUsable() + pay).ToString(); // Update "可用额度" text
                                                                             //Update DB

                        double newBalance = getBalance() - pay;              //使用储蓄卡还款信用卡后,储蓄卡的余额

                        string           sql3 = "UPDATE creditcardinfo SET 已用额度 = '" + UsedCrdTBox.Text + "', 可用额度 = '" + UsableCrdTBox.Text + "' where 手机号='" + phonenumber + "'";
                        string           sql4 = "UPDATE debitcardinfo SET 活期存款余额 = '" + newBalance + "' where 手机号='" + phonenumber + "'";
                        DB.MySqlDataBase db3  = new DB.MySqlDataBase();
                        int ext3 = db3.Excute(sql3);
                        int ext4 = db3.Excute(sql4);
                        if (ext3 > 0)
                        {
                            MessageBox.Show("还款成功!");
                            //CreditCard insert = new CreditCard();
                            //this.Close();
                            DrawTbox.Text = "";
                            PayTBox.Text  = "";
                        }
                    }
                    else
                    {
                        MessageBox.Show("超出需还额度!");
                    }
                }
            }
            catch
            {
                MessageBox.Show("还款金额不能为空!");
            }
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                double depositacc = System.Convert.ToDouble(textBox2.Text);
                if (depositacc <= 0)
                {
                    MessageBox.Show("存款金额应大于0!");
                    textBox2.Text = "";
                }
                else
                {
                    double newBalance = getBalance() + depositacc;
                    //Update Balance to DB
                    //把新的余额的值写入数据库

                    string           sql3 = "UPDATE debitcardinfo SET 活期存款余额 = '" + newBalance + "' where 手机号='" + phonenumber + "'";
                    DB.MySqlDataBase db3  = new DB.MySqlDataBase();
                    int ext3 = db3.Excute(sql3);
                    if (ext3 > 0)
                    {
                        MessageBox.Show("存款成功!");
                        textBox2.Text = "";
                        textBox1.Text = getBalance().ToString();
                    }
                }
            }
            catch
            {
                MessageBox.Show("请输入存款金额");
            }
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string oldpwd = textBox4.Text;
            string newpwd = textBox2.Text;
            string cfpwd  = textBox1.Text;

            if (textBox1.Text == "" || textBox2.Text == "" || textBox4.Text == "")
            {
                MessageBox.Show("输入不完整,请检查", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                string           phonenumber = Login.Getphonenum();
                string           sql         = "Select * from userinfo where 手机号='" + phonenumber + "'";
                DB.MySqlDataBase mdb         = new DB.MySqlDataBase();
                MySqlDataReader  rd          = mdb.read(sql);
                rd.Read();
                string pwd = rd["密码"].ToString();
                if (!BCrypt.Net.BCrypt.Verify(oldpwd, pwd))
                {
                    MessageBox.Show("旧密码输入错误");
                }
                else if (newpwd == oldpwd)
                {
                    MessageBox.Show("新密码不能和旧密码相同");
                }
                else if (cfpwd != newpwd)
                {
                    MessageBox.Show("两次密码输入不一致");
                }
                else
                {
                    string           sql2 = "UPDATE userinfo SET 密码 = '" + BCrypt.Net.BCrypt.HashPassword(newpwd) + "' where 手机号='" + phonenumber + "'";
                    DB.MySqlDataBase db   = new DB.MySqlDataBase();
                    int ext = db.Excute(sql2);
                    if (ext > 0)
                    {
                        MessageBox.Show("修改成功!");
                        Login insert = new Login();
                        insert.Show();
                        this.Close();
                    }
                }
            }
        }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "")
            {
                MessageBox.Show("输入不完整,请检查", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                string name        = textBox1.Text.Trim();
                string phonenumber = textBox4.Text.Trim();
                string password    = textBox2.Text;
                string cfpwd       = textBox3.Text;
                string sql         = "INSERT INTO userinfo VALUES('" + name + "','" + phonenumber + "','" + BCrypt.Net.BCrypt.HashPassword(password) + "')";
                string sql2        = "INSERT INTO creditcardinfo VALUES('" + phonenumber + "','3000','0', '3000')";
                string sql3        = "INSERT INTO debitcardinfo VALUES('" + phonenumber + "', '0')";
                string sql4        = "INSERT INTO foreignexchange VALUES('" + phonenumber + "','美元','0')";
                string sql5        = "INSERT INTO foreignexchange VALUES('" + phonenumber + "','日元','0')";
                string sql6        = "INSERT INTO foreignexchange VALUES('" + phonenumber + "','港币','0')";
                if (cfpwd == password)
                {
                    try
                    {
                        DB.MySqlDataBase mdb = new DB.MySqlDataBase();
                        int ext  = mdb.Excute(sql);
                        int ext2 = mdb.Excute(sql2);
                        int ext3 = mdb.Excute(sql3);
                        int ext4 = mdb.Excute(sql4);
                        int ext5 = mdb.Excute(sql5);
                        int ext6 = mdb.Excute(sql6);
                        if (ext > 0)
                        {
                            MessageBox.Show("注册成功!");
                            Welcome insert = new Welcome();
                            insert.Show();
                            //this.Hide();
                            this.Close();
                        }
                    }

                    catch
                    {
                        MessageBox.Show("该手机号已被注册");
                    }
                }
                else
                {
                    MessageBox.Show("两次密码输入不一致", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Пример #5
0
        private void DrawBtn_Click(object sender, EventArgs e)
        {
            try
            {
                double draw = System.Convert.ToDouble(DrawTbox.Text);

                if (draw <= 0)
                {
                    MessageBox.Show("支取金额应大于0!");
                    DrawTbox.Text = "";
                }

                else if (draw <= getUsable())
                {
                    UsedCrdTBox.Text   = (getUsed() + draw).ToString();   // Update "已用额度" text
                    UsableCrdTBox.Text = (getUsable() - draw).ToString(); // Update "可用额度" text
                                                                          //Update DB
                    string           sql4 = "UPDATE creditcardinfo SET 已用额度 = '" + UsedCrdTBox.Text + "', 可用额度 = '" + UsableCrdTBox.Text + "' where 手机号='" + phonenumber + "'";
                    DB.MySqlDataBase db4  = new DB.MySqlDataBase();
                    int ext4 = db4.Excute(sql4);
                    if (ext4 > 0)
                    {
                        MessageBox.Show("支取成功!");
                        //CreditCard insert = new CreditCard();
                        //this.Close();
                        DrawTbox.Text = "";
                        PayTBox.Text  = "";
                    }
                }
                else
                {
                    MessageBox.Show("超出可用额度!");
                }
            }
            catch
            {
                MessageBox.Show("支取金额不能为空!");
            }
        }
Пример #6
0
        private void buyBtn_Click(object sender, EventArgs e)
        {
            //string[] save;      //数据库更新字符数组
            //string save;
            string   plan     = (String)planChoose.SelectedItem;    //存放用户选择的存期方案
            double   buyPlan  = 0;                                  //存放用户输入的购买金额
            double   debitsum = double.Parse(cardBalance.Text);     //存放当前储蓄卡余额
            DateTime endtime;                                       //定义存款结束时间
            string   str_endtime;                                   //将存款结束日期转换成string型
            double   newdebitsum;                                   //支取或还款后的储蓄卡余额



            if (plan == null)
            {
                MessageBox.Show("请选择您的存款方案");
            }
            else
            {
                try
                {
                    buyPlan = double.Parse(buyNum.Text);
                    if (buyPlan > debitsum)
                    {
                        MessageBox.Show("您的可用余额不足");
                    }

                    else if (buyPlan <= 0)
                    {
                        MessageBox.Show("购买金额应大于0!");
                        buyNum.Text = "";
                    }

                    else if (plan == "3个月/年利率1.4%")
                    {
                        endtime     = DateTime.Now.AddMonths(3); //3个月后的日期
                        str_endtime = endtime.ToString("yyyy-MM-dd");

                        //向数据库更新购买信息(额度,方案以及储蓄卡余额)
                        //界面转场
                        //newdebitsum存放支付后储蓄卡的余额
                        newdebitsum = debitsum - buyPlan;
                        //向timedeposit表插入本次购买方案
                        //向debitcardinfo表进行储蓄卡余额更新
                        string           sql3 = "INSERT INTO timedeposit VALUES('" + phonenumber + "','" + buyNum.Text + "','" + plan + "','" + datetoday + "', '" + str_endtime + "')";
                        string           sql4 = "UPDATE debitcardinfo SET 活期存款余额 = '" + newdebitsum + "' where 手机号='" + phonenumber + "'";
                        DB.MySqlDataBase db3  = new DB.MySqlDataBase();
                        int ext3 = db3.Excute(sql3);
                        int ext4 = db3.Excute(sql4);
                        if (ext4 > 0)
                        {
                            MessageBox.Show("购买成功!");
                            TimeDeposit insert = new TimeDeposit();
                            insert.Show();

                            this.Close();
                            //更新此窗口
                        }
                    }
                    else if (plan == "6个月/年利率1.65%")
                    {
                        endtime     = DateTime.Now.AddMonths(6); //6个月后的日期
                        str_endtime = endtime.ToString("yyyy-MM-dd");
                        //newdebitsum存放支付后储蓄卡的余额
                        newdebitsum = debitsum - buyPlan;
                        //向timedeposit表插入本次购买方案
                        //向debitcardinfo表进行储蓄卡余额更新
                        string           sql3 = "INSERT INTO timedeposit VALUES('" + phonenumber + "','" + buyNum.Text + "','" + plan + "','" + datetoday + "', '" + str_endtime + "')";
                        string           sql4 = "UPDATE debitcardinfo SET 活期存款余额 = '" + newdebitsum + "' where 手机号='" + phonenumber + "'";
                        DB.MySqlDataBase db3  = new DB.MySqlDataBase();
                        int ext3 = db3.Excute(sql3);
                        int ext4 = db3.Excute(sql4);
                        if (ext4 > 0)
                        {
                            MessageBox.Show("购买成功!");
                            TimeDeposit insert = new TimeDeposit();
                            insert.Show();

                            this.Close();
                            //更新此窗口
                        }
                    }
                    else if (plan == "1年/年利率1.95%")
                    {
                        endtime     = DateTime.Now.AddYears(1); //1年后日期
                        str_endtime = endtime.ToString("yyyy-MM-dd");
                        //newdebitsum存放支付后储蓄卡的余额
                        newdebitsum = debitsum - buyPlan;
                        //向timedeposit表插入本次购买方案
                        //向debitcardinfo表进行储蓄卡余额更新
                        string           sql3 = "INSERT INTO timedeposit VALUES('" + phonenumber + "','" + buyNum.Text + "','" + plan + "','" + datetoday + "', '" + str_endtime + "')";
                        string           sql4 = "UPDATE debitcardinfo SET 活期存款余额 = '" + newdebitsum + "' where 手机号='" + phonenumber + "'";
                        DB.MySqlDataBase db3  = new DB.MySqlDataBase();
                        int ext3 = db3.Excute(sql3);
                        int ext4 = db3.Excute(sql4);
                        if (ext4 > 0)
                        {
                            MessageBox.Show("购买成功!");
                            TimeDeposit insert = new TimeDeposit();
                            insert.Show();

                            this.Close();
                            //更新此窗口
                        }
                    }

                    else if (plan == "2年/年利率2.4%")
                    {
                        endtime     = DateTime.Now.AddYears(2); //2年后日期
                        str_endtime = endtime.ToString("yyyy-MM-dd");
                        //newdebitsum存放支付后储蓄卡的余额
                        newdebitsum = debitsum - buyPlan;
                        //向timedeposit表插入本次购买方案
                        //向debitcardinfo表进行储蓄卡余额更新
                        string           sql3 = "INSERT INTO timedeposit VALUES('" + phonenumber + "','" + buyNum.Text + "','" + plan + "','" + datetoday + "', '" + str_endtime + "')";
                        string           sql4 = "UPDATE debitcardinfo SET 活期存款余额 = '" + newdebitsum + "' where 手机号='" + phonenumber + "'";
                        DB.MySqlDataBase db3  = new DB.MySqlDataBase();
                        int ext3 = db3.Excute(sql3);
                        int ext4 = db3.Excute(sql4);
                        if (ext4 > 0)
                        {
                            MessageBox.Show("购买成功!");
                            TimeDeposit insert = new TimeDeposit();
                            insert.Show();

                            this.Close();
                            //更新此窗口
                        }
                    }

                    else if (plan == "3年/年利率3%")
                    {
                        endtime     = DateTime.Now.AddYears(3); //3年后日期
                        str_endtime = endtime.ToString("yyyy-MM-dd");
                        //newdebitsum存放支付后储蓄卡的余额
                        newdebitsum = debitsum - buyPlan;
                        //向timedeposit表插入本次购买方案
                        //向debitcardinfo表进行储蓄卡余额更新
                        string           sql3 = "INSERT INTO timedeposit VALUES('" + phonenumber + "','" + buyNum.Text + "','" + plan + "','" + datetoday + "', '" + str_endtime + "')";
                        string           sql4 = "UPDATE debitcardinfo SET 活期存款余额 = '" + newdebitsum + "' where 手机号='" + phonenumber + "'";
                        DB.MySqlDataBase db3  = new DB.MySqlDataBase();
                        int ext3 = db3.Excute(sql3);
                        int ext4 = db3.Excute(sql4);
                        if (ext4 > 0)
                        {
                            MessageBox.Show("购买成功!");
                            TimeDeposit insert = new TimeDeposit();
                            insert.Show();

                            this.Close();
                            //更新此窗口
                        }
                    }

                    else if (plan == "5年/年利率3%")
                    {
                        endtime     = DateTime.Now.AddYears(5); //5年后日期
                        str_endtime = endtime.ToString("yyyy-MM-dd");
                        //newdebitsum存放支付后储蓄卡的余额
                        newdebitsum = debitsum - buyPlan;
                        //向timedeposit表插入本次购买方案
                        //向debitcardinfo表进行储蓄卡余额更新
                        string           sql3 = "INSERT INTO timedeposit VALUES('" + phonenumber + "','" + buyNum.Text + "','" + plan + "','" + datetoday + "', '" + str_endtime + "')";
                        string           sql4 = "UPDATE debitcardinfo SET 活期存款余额 = '" + newdebitsum + "' where 手机号='" + phonenumber + "'";
                        DB.MySqlDataBase db3  = new DB.MySqlDataBase();
                        int ext3 = db3.Excute(sql3);
                        int ext4 = db3.Excute(sql4);
                        if (ext4 > 0)
                        {
                            MessageBox.Show("购买成功!");
                            TimeDeposit insert = new TimeDeposit();
                            insert.Show();

                            this.Close();
                            //更新此窗口
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("请输入购买金额");
                }
            }
        }
Пример #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (excToRmbBtn.Checked)
            {
                double excToRmb;
                try
                {
                    excToRmb = double.Parse(excNum.Text);
                    double sellprice3 = double.Parse(sellPrice.Text);
                    //double exc_excToRmb = (excToRmb / sellprice3) * 100;
                    //因为用户输入的是人民币,这里把人民币换成对应货币在比较是否会发生"您拥有的货币量不足"

                    string excKey = currencyChoose.Text;
                    //int nowexc = 0;         //需要数据库提供数据(当前币种拥有的货币量)(币种:excKey)

                    double           nowrmb;
                    string           sql  = "Select * from foreignexchange where 手机号='" + phonenumber + "'AND 货币种类='" + excKey + "'";
                    string           sql2 = "Select * from debitcardinfo where 手机号='" + phonenumber + "'";
                    DB.MySqlDataBase mdb  = new DB.MySqlDataBase();
                    MySqlDataReader  rd   = mdb.read(sql);
                    MySqlDataReader  rd2  = mdb.read(sql2);

                    rd.Read();

                    string a;
                    a      = rd["货币持有量"].ToString();
                    nowExc = double.Parse(a);

                    rd2.Read();

                    string b;
                    b      = rd2["活期存款余额"].ToString();  //读出此时储蓄卡的余额到string型变量b
                    nowrmb = double.Parse(b);

                    rd.Close();                             //关闭连接
                    rd2.Close();

                    if (excToRmb > nowExc)
                    {
                        MessageBox.Show("您拥有的货币量不足");
                    }

                    else if (excToRmb <= 0)
                    {
                        MessageBox.Show("兑换数量应大于0!");
                        excNum.Text = "";
                    }

                    else
                    {
                        //更新数据库(减少该种货币量以及增加人民币储蓄)
                        //返回上一界面

                        double newexc, newrmb;   //兑换后的外币和人民币
                        //double sellprice3 = double.Parse(sellPrice.Text);
                        //计算公式
                        newexc = nowExc - excToRmb;
                        newrmb = nowrmb + double.Parse(textBox1.Text);
                        string           sql3 = "UPDATE debitcardinfo SET 活期存款余额 = '" + newrmb + "' where 手机号='" + phonenumber + "'";
                        string           sql4 = "UPDATE foreignexchange SET 货币持有量 = '" + newexc + "' where 手机号='" + phonenumber + "'AND 货币种类='" + excKey + "'";
                        DB.MySqlDataBase db3  = new DB.MySqlDataBase();
                        int ext3 = mdb.Excute(sql3);
                        int ext4 = mdb.Excute(sql4);
                        if (ext4 > 0)
                        {
                            MessageBox.Show("兑换成功!");
                            ForeignExchange insert = new ForeignExchange();
                            insert.Show();
                            this.Close();
                            //更新界面
                        }

                        //更新数据库(减少该种货币量以及增加人民币储蓄)
                    }
                }
                catch
                {
                    if (currencyChoose.Text == "")
                    {
                        MessageBox.Show("未选择交易币种");
                    }
                    else
                    {
                        MessageBox.Show("请输入兑换金额");
                    }
                }
            }

            else if (rmbToExcBtn.Checked)
            {
                double rmbToExc;
                try
                {
                    rmbToExc = double.Parse(textBox1.Text);

                    //int rmbToExc = int.Parse(excNum.Text);
                    string excKey = currencyChoose.Text;
                    //int nowrmb = 0;     //需要数据库提供数据(人民币储蓄)(币种:excKey)

                    double           nowrmb;
                    string           sql  = "Select * from foreignexchange where 手机号='" + phonenumber + "'AND 货币种类='" + excKey + "'";
                    string           sql2 = "Select * from debitcardinfo where 手机号='" + phonenumber + "'";
                    DB.MySqlDataBase mdb  = new DB.MySqlDataBase();
                    MySqlDataReader  rd   = mdb.read(sql);
                    MySqlDataReader  rd2  = mdb.read(sql2);

                    rd.Read();
                    string a;
                    a      = rd["货币持有量"].ToString();
                    nowExc = double.Parse(a);

                    rd2.Read();
                    string b;
                    b      = rd2["活期存款余额"].ToString();  //读出此时储蓄卡的余额到string型变量b
                    nowrmb = double.Parse(b);

                    rd.Close();                             //关闭连接


                    if (rmbToExc > nowrmb)
                    {
                        MessageBox.Show("您的人民币储蓄不足");
                    }

                    else if (rmbToExc <= 0)
                    {
                        MessageBox.Show("兑换数量应大于0!");
                        excNum.Text = "";
                    }

                    else
                    {
                        //更新数据库(减少人民币储蓄以及增加该种货币量)(币种:excKey)
                        //返回上一界面

                        double newexc, newrmb;   //兑换后的外币和人民币
                        double buyprice4 = double.Parse(buyPrice.Text);
                        //计算公式
                        newexc = nowExc + double.Parse(excNum.Text);
                        newrmb = nowrmb - double.Parse(textBox1.Text);
                        string sql3 = "UPDATE debitcardinfo SET 活期存款余额 = '" + newrmb + "' where 手机号='" + phonenumber + "'";
                        string sql4 = "UPDATE foreignexchange SET 货币持有量 = '" + newexc + "' where 手机号='" + phonenumber + "'AND 货币种类='" + excKey + "'";
                        //更新数据库(减少人民币储蓄以及增加该种货币量)(币种:excKey)

                        DB.MySqlDataBase db3 = new DB.MySqlDataBase();
                        int ext3             = mdb.Excute(sql3);
                        int ext4             = mdb.Excute(sql4);
                        if (ext4 > 0)
                        {
                            MessageBox.Show("兑换成功!");
                            ForeignExchange insert = new ForeignExchange();
                            insert.Show();
                            this.Close();
                            //更新此界面
                        }
                    }
                }
                catch
                {
                    if (currencyChoose.Text == "")
                    {
                        MessageBox.Show("未选择交易币种");
                    }
                    else
                    {
                        MessageBox.Show("请输入兑换金额");
                    }
                }
            }

            else
            {
                MessageBox.Show("请选择交易类型");
            }
        }