Exemple #1
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("请输入存款金额");
            }
        }
Exemple #2
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("还款金额不能为空!");
            }
        }
Exemple #3
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);
                }
            }
        }
Exemple #4
0
        public double getBalance()
        {
            string sql1 = "Select * from debitcardinfo where 手机号='" + phonenumber + "'";

            DB.MySqlDataBase mdb = new DB.MySqlDataBase();
            MySqlDataReader  rd  = mdb.read(sql1);

            rd.Read();
            string a = rd["活期存款余额"].ToString();

            rd.Close();
            Balance = double.Parse(a);

            return(Balance);
        }
Exemple #5
0
        public double getUsable()
        {
            //………… get "可用额度" from DB
            string sql2 = "Select * from creditcardinfo where 手机号='" + phonenumber + "'";

            DB.MySqlDataBase db = new DB.MySqlDataBase();
            MySqlDataReader  dr = db.read(sql2);

            dr.Read();
            string b = dr["可用额度"].ToString();

            dr.Close();
            usableCrd = Convert.ToDouble(b);

            return(usableCrd);
        }
Exemple #6
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();
                    }
                }
            }
        }
Exemple #7
0
        string phonenumber = Login.Getphonenum();       //获取本次登录账户的手机号
        public TimeDeposit()
        {
            InitializeComponent();

            /*cardBalance.Text = Balance.ToString();
             * string planDis = "" ;
             * int index = 0;
             * foreach(string num in Num)
             * {
             *  planDis = planDis.Insert(0,num+"元    "+Year[index]+"年    ");
             *  index++;
             * }
             * holdPlan.Text = planDis; //
             */
            //根据本次登录账户的手机号查询timedeposit表信息
            string sql = "Select * from timedeposit where 手机号='" + phonenumber + "'";

            DB.MySqlDataBase mdb = new DB.MySqlDataBase();
            MySqlDataReader  rd  = mdb.read(sql);

            //将timedeposit表信息“额度”“存期”读取到dataGridView中显示
            while (rd.Read())
            {
                string a, b, c, d;
                a = rd["额度"].ToString();
                b = rd["存期"].ToString();
                c = rd["购买日期"].ToString();
                d = rd["到期时间"].ToString();
                string[] str = { a, b, c, d };
                dataGridView1.Rows.Add(str);
            }
            rd.Close();                             //关闭连接

            //根据手机号查询debitcardinfo表,获取此账户目前的储蓄卡余额
            string sql2 = "Select * from debitcardinfo where 手机号='" + phonenumber + "'";

            DB.MySqlDataBase db  = new DB.MySqlDataBase();
            MySqlDataReader  mdr = db.read(sql2);

            mdr.Read();
            string Balance = mdr["活期存款余额"].ToString();      //用户的储蓄卡余额

            cardBalance.Text = Balance;
            mdr.Close();                                          //关闭连接
        }
Exemple #8
0
        public double getUsed()
        {
            //………… get "已用额度" from DB
            string sql1 = "Select * from creditcardinfo where 手机号='" + phonenumber + "'";

            DB.MySqlDataBase mdb = new DB.MySqlDataBase();
            MySqlDataReader  rd  = mdb.read(sql1);

            rd.Read();
            string a = rd["已用额度"].ToString();

            rd.Close();
            usedCrd = Convert.ToDouble(a);



            return(usedCrd);
        }
Exemple #9
0
        public static string Getname()
        {
            string phonenumber = Getphonenum();
            string sql         = "Select * from userinfo where 手机号='" + phonenumber + "'";

            DB.MySqlDataBase mdb = new DB.MySqlDataBase();
            MySqlDataReader  rd  = mdb.read(sql);

            if (rd.Read())
            {
                string name = rd["姓名"].ToString();
                rd.Close();                             //关闭连接
                return(name);
            }
            else
            {
                return("亲爱的用户");
            }
        }
Exemple #10
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "")
            {
                MessageBox.Show("输入不完整,请检查", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                string           phonenumber = textBox1.Text.Trim();
                string           password    = textBox2.Text;
                DB.MySqlDataBase mdb         = new DB.MySqlDataBase();      //实例化MySqlDataBase的一个对象mdb
                string           sql         = "Select * from userinfo where 手机号='" + phonenumber + "'";
                MySqlDataReader  rd          = mdb.read(sql);

                if (rd.Read())
                {
                    var savedpasswd = rd["密码"].ToString();
                    if (BCrypt.Net.BCrypt.Verify(password, savedpasswd))
                    {
                        MessageBox.Show("登录成功!");
                        UserCenter insert = new UserCenter();
                        insert.Show();          //显示这个窗体
                        this.Hide();            //隐藏这个窗体

                        //更新BCrypt加密
                        string sql1 = "UPDATE `userinfo` SET `密码` = '" + BCrypt.Net.BCrypt.HashPassword(password) + "' WHERE `手机号` = '" + phonenumber + "'";
                        mdb.read(sql1);

                        rd.Close();
                    }
                    else
                    {
                        MessageBox.Show("密码错误");
                        rd.Close();
                    };
                }
                else
                {
                    MessageBox.Show("手机号不存在");
                    rd.Close();
                }
            }
        }
Exemple #11
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("支取金额不能为空!");
            }
        }
Exemple #12
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("请输入购买金额");
                }
            }
        }
Exemple #13
0
        private void currencyChoose_SelectedIndexChanged(object sender, EventArgs e)
        {
            double    sellprice2, buyprice2;
            String    excKey = currencyChoose.Text;
            string    url    = @"https://www.boc.cn/sourcedb/whpj/";
            WebClient client = new WebClient();

            client.Encoding = Encoding.UTF8;
            string pagehtml = client.DownloadString(url);

            pagehtml = pagehtml.Replace("\t", "");
            pagehtml = pagehtml.Replace("\t", "");
            string [] words = pagehtml.Split('\n');
            int       count = 0;

            foreach (string word in words)
            {
                string pattern = "<td></td>$";
                pattern = pattern.Insert(4, excKey);
                Regex rx = new Regex(pattern);
                Match m  = rx.Match(word);
                if (m.Success)
                {
                    break;
                }
                count++;
            }
            string pricePattern = "[0-9.]+";
            Regex  rx1          = new Regex(pricePattern);
            Match  m1           = rx1.Match(words[count + 1]);

            if (m1.Success)
            {
                sellPrice.Text = m1.Value;
            }
            Regex rx2 = new Regex(pricePattern);
            Match m2  = rx1.Match(words[count + 3]);

            if (m2.Success)
            {
                buyPrice.Text = m2.Value;
            }

            if (excNum.Text != "")
            {
                if (rmbToExcBtn.Checked)
                {
                    try
                    {
                        double exc = double.Parse(excNum.Text);
                        double buy = double.Parse(buyPrice.Text);
                        textBox1.Text = (exc / 100 * buy).ToString("0.00");
                    }
                    catch
                    {
                        MessageBox.Show("请输入数字");;
                    }
                }
                else if (excToRmbBtn.Checked)
                {
                    try
                    {
                        double exc  = double.Parse(excNum.Text);
                        double sale = double.Parse(sellPrice.Text);
                        textBox1.Text = (exc / 100 * sale).ToString("0.00");
                    }
                    catch
                    {
                        MessageBox.Show("请输入数字");;
                    }
                }
            }
            sellprice2 = double.Parse(sellPrice.Text);
            buyprice2  = double.Parse(buyPrice.Text);

            string sql = "Select * from foreignexchange where 手机号='" + phonenumber + "'AND 货币种类='" + excKey + "'";

            DB.MySqlDataBase mdb = new DB.MySqlDataBase();
            MySqlDataReader  rd  = mdb.read(sql);

            rd.Read();

            string a;

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

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


            //int nowexc = 0;         //需要数据库提供数据(当前币种拥有的货币量)(币种:excKey)
            holdExc.Text = nowExc.ToString();
        }
Exemple #14
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("请选择交易类型");
            }
        }