Example #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            TimeDeposit insert = new TimeDeposit();

            insert.Show();
            this.Hide();
        }
Example #2
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("请输入购买金额");
                }
            }
        }