Exemplo n.º 1
0
        private void btnAddFood_Click(object sender, EventArgs e)
        {
            DTO.Table table = lsvBill.Tag as DTO.Table;

            if (table == null)
            {
                MessageBox.Show("Hãy Chọn Bàn");
                return;
            }

            int idBill = DAO.BillDAO.Instance.GetuncheckBillByTable(table.ID);
            int foodID = (cbFood.SelectedItem as DTO.Food).ID;
            int count  = (int)nmFoodCount.Value;

            if (idBill == -1)
            {
                DAO.BillDAO.Instance.InsertBill(table.ID);
                DAO.BillInfoDAO.Instance.InsertBillInfo(DAO.BillDAO.Instance.GetMaxIDBill(), foodID, count);
            }
            else
            {
                DAO.BillInfoDAO.Instance.InsertBillInfo(idBill, foodID, count);
            }
            ShowBill(table.ID);
            LoadTable();
        }
Exemplo n.º 2
0
        private void btnCheckOut_Click(object sender, EventArgs e)
        {
            DTO.Table table = lsvBill.Tag as DTO.Table;

            int idBill   = DAO.BillDAO.Instance.GetuncheckBillByTable(table.ID);
            int discount = (int)nmDiscount.Value;

            double totalPrice      = Convert.ToDouble(txtTotalPrice.Text);
            double finalTotalPrice = totalPrice - (totalPrice / 100) * discount;

            if (idBill != -1)
            {
                if (MessageBox.Show(string.Format("Bạn có chắc thanh toán hóa đơn cho bàn {0}\n Tổng tiền - (Tổng tiền / 100) x Giảm giá = {1} - ({1} / 100) x{2} = {3}", table.Name, totalPrice, discount, finalTotalPrice), "Thông Báo", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                {
                    DAO.BillDAO.Instance.Checkout(idBill, discount, (float)finalTotalPrice);
                    ShowBill(table.ID);

                    LoadTable();
                }
            }
        }