示例#1
0
        }//Remove from shopping cart

        private void btnSettlePayment_Click(object sender, EventArgs e)
        {
            if (checkisEmptyshoppingCart() == true)
            {
                MessageBox.Show("The shopping car has no item!");
            }
            else
            {
                FormChashier frmChashier = new FormChashier(shoppingcart, this, SalesRecordID);
                if (frmChashier.ShowDialog(this) == DialogResult.OK)
                {
                    DateTime now = DateTime.Now;
                    updateDatabase_SalesRecord(SalesRecordID, StaffUI.staff.getStaffID(), now.ToString("yyyy-MM-dd HH:mm:ss"));
                    foreach (SalesItem item in shoppingcart)
                    {
                        String  productid     = item.productid;
                        String  salesrecordid = SalesRecordID;
                        int     quantity      = item.amount;
                        int     discount      = item.discount;
                        decimal unitprice     = item.price;
                        decimal total         = item.calTotal();
                        String  productname   = item.productname;
                        updataDatabase_SalesItem(productid, salesrecordid, productname, quantity, discount, total, unitprice);
                        updateDatabase_product_amount(quantity, productid);
                    }
                    MessageBox.Show("Success!");
                    //create receipt
                    FormReceipt frmReceipt = new FormReceipt(shoppingcart, SalesRecordID, cashTendered);
                    frmReceipt.ShowDialog();
                    //callback method
                    frmCSM.OnPaymentSettled();

                    this.Close();
                }
            }
        }//button SettlePayment