Exemple #1
0
 private void shuaXinButton_Click(object sender, EventArgs e)
 {
     myDataGridView.DataSource = SqlManage.goodsBrowse().Tables[0];
     for (int i = 0; i < myDataGridView.Rows.Count; i++)
     {
         int store   = int.Parse(myDataGridView.Rows[i].Cells[4].Value.ToString());
         int goodsId = int.Parse(myDataGridView.Rows[i].Cells[0].Value.ToString());
         if (store < SqlManage.goodsQuery(goodsId).MinStorage)
         {
             myDataGridView.Rows[i].Cells[0].Style.BackColor = Color.Red;
         }
     }
 }
Exemple #2
0
 private void GoodsStatisticForm_Load(object sender, EventArgs e)
 {
     myDataGridView.DataSource = SqlManage.goodsBrowse().Tables[0];
     for (int i = 0; i < myDataGridView.Rows.Count - 1; i++)
     {
         int store   = int.Parse(myDataGridView.Rows[i].Cells[4].Value.ToString());
         int goodsId = int.Parse(myDataGridView.Rows[i].Cells[0].Value.ToString());
         if (store < SqlManage.goodsQuery(goodsId).MinStorage)
         {
             for (int j = 0; j < myDataGridView.ColumnCount; j++)
             {
                 myDataGridView.Rows[i].Cells[j].Style.BackColor = Color.Red;
             }
         }
     }
 }
        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("已超出最大赊购限额!");
            }
        }