コード例 #1
0
 private void okButton_Click(object sender, EventArgs e)
 {
     if (depositTextBox.Text != "")
     {
         customer.Balance += float.Parse(depositTextBox.Text);
         SqlManage.updateCustomer(customer);
         this.showCurrentBalanceLabel.Text = customer.Balance.ToString();
     }
 }
コード例 #2
0
        private void dealButton_Click(object sender, EventArgs e)
        {
            float    amount     = SqlManage.amountQuery(orderId);
            Order    order      = SqlManage.orderQuery(orderId);
            int      customerId = order.CustomerId;
            Customer customer   = SqlManage.customerQuery(customerId);

            order.IsDealed = true;
            if (amount < customer.Balance + customer.CustomerCreditLimit)
            {
                Bill     bill          = null;
                DateTime payDate       = DateTime.Now;
                float    amountPayable = amount;
                float    payAmount;
                int      billId = SqlManage.queryMaxBillId() + 1;
                if (customer.Balance < amount)
                {
                    payAmount = customer.Balance;
                }
                else
                {
                    payAmount = amount;
                }
                bill = new Bill(billId, orderId, amountPayable, payDate, payAmount);
                SqlManage.insertBill(bill);

                customer.Balance -= amount;
                if (SqlManage.updateCustomer(customer) &&
                    SqlManage.updateOrder(order))
                {
                    //更新库存
                    for (int i = 0; i < myDataGridView.RowCount - 1; i++)
                    {
                        int   goodsId  = Convert.ToInt32(myDataGridView[0, i].Value);
                        Goods goods    = SqlManage.goodsQuery(goodsId);
                        int   goodsNum = Convert.ToInt32(myDataGridView[1, i].Value);
                        goods.ActualStorage -= goodsNum;
                        SqlManage.updateGoods(goods);
                    }
                    MessageBox.Show("支付成功!");
                }
            }
            else
            {
                MessageBox.Show("已超出最大赊购限额!");
            }
        }
コード例 #3
0
 private void okButton_Click(object sender, EventArgs e)
 {
     if (customer.Password == oldPasswordTextBox.Text)
     {
         if (newPasswordTextBox.Text == "")
         {
             MessageBox.Show("新密码不能为空!");
         }
         else if (newPasswordTextBox.Text == confirmTextBox.Text)
         {
             customer.Password = newPasswordTextBox.Text;
             SqlManage.updateCustomer(customer);
             MessageBox.Show("修改成功!");
         }
         else
         {
             MessageBox.Show("确认密码与新密码不一致!");
         }
     }
     else
     {
         MessageBox.Show("原密码输入不正确!");
     }
 }