Exemple #1
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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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("请选择交易类型");
            }
        }