Esempio n. 1
0
        void BuyProduct(int buytings, decimal allcoast, string id, string mname)
        {
            MySqlConnection dbon = new MySqlConnection(ConnectStr);

            dbon.Open();
            string  bala    = Bankcard.GetBalance(id);
            string  cost    = this.labelProductBuyMoney.Text;
            decimal costnum = Convert.ToDecimal(cost);

            if (Convert.ToDecimal(bala) < costnum)
            {
                MessageBox.Show("余额不足!");
            }
            else
            {
                try
                {
                    string       text = "update product set POwn = POwn + " + buytings + " where account_id = '" + id + "' AND Pname = '" + mname + "';";
                    MySqlCommand cmd  = new MySqlCommand(text, dbon);
                    cmd.ExecuteNonQuery();
                    string       text0 = "update account set balance = balance - " + allcoast + " where account_id = '" + id + "';";
                    MySqlCommand cmd1  = new MySqlCommand(text0, dbon);
                    cmd1.ExecuteNonQuery();
                    string text2 = "insert into transinfo(account_id, transtype, transmoney, name) values ('" + id + "', '购买 " + mname + "'," + allcoast + ",'" + CurUserName + "');";
                    cmd1 = new MySqlCommand(text2, dbon);
                    cmd1.ExecuteNonQuery();
                    MessageBox.Show("购买 " + buytings.ToString() + " 百元份" + mname + "成功,共花费" + allcoast.ToString() + "元人民币");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }
Esempio n. 2
0
        private void buttonTransferTransfer_Click(object sender, EventArgs e)
        {
            string card_from = this.comboBoxTransferOut.SelectedItem.ToString();

            if (card_from.Length == 0)
            {
                MessageBox.Show("请选择卡号!"); return;
            }
            string card_from_balance = Bankcard.GetBalance(card_from);
            string money             = this.textBoxTransferMoney.Text;

            //输入金额格式非法
            if (!User.IsMoney(money))
            {
                MessageBox.Show("请注意金额格式!"); this.textBoxTransferMoney.Text = ""; return;
            }
            decimal money_number = Convert.ToDecimal(money);

            //余额不足
            if (Convert.ToDecimal(card_from_balance) < money_number)
            {
                MessageBox.Show("余额不足!"); return;
            }
            string card_to = this.textBox1.Text;

            //目的卡片不存在
            if (Bankcard.GetBalance(card_to) == "NULL")
            {
                MessageBox.Show("目的卡号不存在,请检查并重试!"); return;
            }
            //一般情况
            try
            {
                int flag = User.Transfer(CurUserName, card_from, card_to, money_number);
                if (flag == 0)
                {
                    MessageBox.Show("转账成功!");
                }
            }
            //其他非法情况
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            ShowCardInfo();
            ShowOperations();
        }
Esempio n. 3
0
        //取钱按钮
        private void buttonTakeTake_Click(object sender, EventArgs e)
        {
            string card = this.comboBoxTake.SelectedItem.ToString();

            if (card.Length == 0)
            {
                MessageBox.Show("请选择卡号!"); return;
            }
            string card_balance = Bankcard.GetBalance(card);
            string money        = this.textBoxTakeMoney.Text;

            if (!User.IsMoney(money))
            {
                MessageBox.Show("请注意金额格式!"); this.textBoxTakeMoney.Text = ""; return;
            }
            decimal money_number = Convert.ToDecimal(money);

            if (Convert.ToDecimal(card_balance) < money_number)
            {
                MessageBox.Show("余额不足!"); return;
            }
            //decimal money_number = Convert.ToDecimal(money);
            try
            {
                int flag = User.WithDraw(CurUserName, card, money_number);
                if (flag == 0)
                {
                    MessageBox.Show("取钱成功!");
                }
                else if (flag == 1)
                {
                    MessageBox.Show("余额不足,请更换卡号!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            ShowCardInfo();
            ShowOperations();
        }