Ejemplo n.º 1
0
        private TableDTO CreateAddBillByIDTable(DrinkDTO drink)
        {
            TableDTO table = lstBill.Tag as TableDTO;


            int idBill = BillBUS.GetIDBillNoPaymentByIDTable(table.ID);//lấy lên cái mã id của hóa đơn

            // int idDrink = (cbDrink. SelectedItem as DrinkDTO).ID;//thêm vào 1 gridview để hiển thị
            int idDrink  = drink.ID;
            int quantity = 1;

            //kiểm tra hóa đơn có chưa hay
            if (idBill == -1)//nếu chưa thì tạo 1 hóa đơn mới với mã hóa đơn
            {
                quantity = DetailBillBUS.GetQuantityDrink(idBill, idDrink);
                // sau khi tạo xong 1 hóa đơn mới thì thêm vào bảng chi tiết hóa đơn với các trường tương ứng
                DetailBillBUS.InsertDetailBill(BillBUS.GetIDBillMax(), idDrink, quantity + 1);
            }
            else//nếu đã có thì thêm nó vào cái cá bảng chi tiêt hóa đơn với các trường là mã hóa đơn, mã thức uống và số lượng
            {
                quantity = DetailBillBUS.GetQuantityDrink(idBill, idDrink);
                DetailBillBUS.InsertDetailBill(idBill, idDrink, quantity + 1);
            }
            return(table);
        }
Ejemplo n.º 2
0
        private void AddProductToCart(ProductDTO Product, int billId)
        {
            int idProduct = Product.ID;

            var quantity = DetailBillBUS.GetQuantityProduct(billId, idProduct);

            DetailBillBUS.InsertDetailBill(billId, idProduct, quantity + 1);
        }
Ejemplo n.º 3
0
 private void btnDeDrink_Click(object sender, EventArgs e)
 {
     try
     {
         if (lstDrink.SelectedItems != null)
         {
             ListViewItem lvw    = lstDrink.SelectedItems[0];
             DrinkDTO     sp     = (DrinkDTO)lvw.Tag;
             frm_XacNhan  frm_XN = new frm_XacNhan("Xóa một sản phẩm rất quan trọng. Bạn vui lòng nhập mật khẩu để xác nhận thao tác này!", Program.sAccount);
             if (frm_XN.ShowDialog() == DialogResult.OK)
             {
                 if (AccountBUS.IsLogin(Program.sAccount.ID, frm_XN.txtXacNhap.Text))
                 {
                     if (DetailBillBUS.IsExistDrink(sp.ID) == -1)
                     {
                         if (lstDrink.SelectedItems.Count > 0)
                         {
                             if (DrinkBUS.DeleteDrink(sp) == true)
                             {
                                 MessageBox.Show("Bạn đã xóa thành công sản phẩm SP00" + sp.ID + " khỏi hệ thống!", "Thông báo", MessageBoxButtons.OK);
                                 ShowDrink();
                                 DeleteTextDrink();
                                 btnEditDrink.Visible = false;
                                 btnAdddrink.Visible  = true;
                             }
                             else
                             {
                                 MessageBox.Show("Xóa sản phẩm thất bại, vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK);
                             }
                         }
                         else
                         {
                             MessageBox.Show("Chưa chọn thức uống", "Thông báo", MessageBoxButtons.OK);
                         }
                     }
                     else
                     {
                         MessageBox.Show("Thức uống này đã được người dùng chọn hoặc mua trong thời gian trước đó, bạn không thể xóa sản phẩm này!", "Thông báo", MessageBoxButtons.OK);
                     }
                 }
                 else
                 {
                     MessageBox.Show("Bạn nhập sai mật khẩu, vui lòng nhập lại!", "Thông báo", MessageBoxButtons.OK);
                 }
             }
         }
         else
         {
             MessageBox.Show("Bạn vui lòng chọn sản phẩm trước khi thực hiện chức năng này!", "Thông báo", MessageBoxButtons.OK);
         }
     }
     catch
     {
         MessageBox.Show("Hệ thống đang bảo trì chức năng này, vui lòng quay lại sau nhé!", "Thông báo", MessageBoxButtons.OK);
     }
 }
Ejemplo n.º 4
0
        private void lstBill_MouseClick(object sender, MouseEventArgs e)
        {
            TableDTO table = ((Button)objTable).Tag as TableDTO;

            int idBill = BillBUS.GetIDBillNoPaymentByIDTable(table.ID);

            if (lstBill.SelectedItems.Count > 0)
            {
                MenuDTO order = (MenuDTO)lstBill.SelectedItems[0].Tag as MenuDTO;

                frm_ThongTinChiTietSanPham de = new frm_ThongTinChiTietSanPham(table.ID, idBill, order.IdDrink, Convert.ToInt32(order.Quantity) + 1);
                de.lblDrinkName.Text = order.NameDrink;
                if (order.PriceBasic == 0)
                {
                    de.lblPrice.Text = "Miễn phí";
                }
                else
                {
                    de.lblPrice.Text = String.Format("{0:0,0}", order.PriceBasic);
                }
                de.cbQuantity.SelectedIndex = Convert.ToInt32(order.Quantity) - 1;
                if (order.TotalPrice == 0)
                {
                    de.lblTotal.Text = "Miễn phí";
                }
                else
                {
                    de.lblTotal.Text = String.Format("{0:0,0}", order.TotalPrice);
                }
                DialogResult kq = de.ShowDialog();
                if (kq == DialogResult.OK)
                {
                    DetailBillBUS.InsertDetailBill(idBill, order.ID, de.cbQuantity.SelectedIndex + 1);
                    ShowBill(table.ID);
                }
                else if (kq == DialogResult.Yes)
                {
                    ShowBill(table.ID);
                    Button btnTable = ((Button)objTable);
                    btnTable.Text = table.NameTable + Environment.NewLine + "Trống";
                    if (!BUS.DetailBillBUS.IsEmpty(idBill))
                    {
                        btnTamTinh.Enabled   = false;
                        btnThanhToan.Enabled = false;
                        txttotalPrice.Text   = "";
                        txtHD.Text           = "";
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult kq = MessageBox.Show("Bạn có muốn xóa sản phẩm này không?", "Thông báo", MessageBoxButtons.OKCancel);

            if (kq != DialogResult.Cancel)
            {
                DetailBillBUS.DeleteOneProduct(idBill, idProduct);

                if (DetailBillBUS.IsEmpty(idBill))
                {
                    return;
                }

                BillBUS.DeleteBill(idBill);
            }
        }
Ejemplo n.º 6
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult kq = MessageBox.Show("Bạn có muốn xóa sản phẩm này không?", "Thông báo", MessageBoxButtons.OKCancel);

            if (kq != DialogResult.Cancel)
            {
                DetailBillBUS.DeleteOneDrink(idBill, idDrink);
                // Xóa sản phẩm trong detail bill thông qua ma hóa đơn.
                // Nếu trong hóa đơn đó không còn sản phẩm thì xóa hóa đơn ===>> cập nhật lại trạng thái bàn.
                if (!BUS.DetailBillBUS.IsEmpty(idBill))
                {
                    BUS.BillBUS.DeleteBill(idBill);
                    TableBUS.UpdateStatusTable(0, idTable);
                }
                //Ngược lại không làm gì cả.....
            }
        }
Ejemplo n.º 7
0
        private void lstProductCart_MouseClick(object sender, MouseEventArgs e)
        {
            if (lstProductCart.SelectedItems.Count > 0)
            {
                MenuDTO order = lstProductCart.SelectedItems[0].Tag as MenuDTO;

                frm_ThongTinChiTietSanPham de = new frm_ThongTinChiTietSanPham(currentBillId, order.IdProduct, Convert.ToInt32(order.Quantity) + 1);
                de.lblProductName.Text = order.NameProduct;
                if (order.PriceBasic == 0)
                {
                    de.lblPrice.Text = "Miễn phí";
                }
                else
                {
                    de.lblPrice.Text = String.Format("{0:0,0}", order.PriceBasic);
                }
                de.cbQuantity.SelectedIndex = Convert.ToInt32(order.Quantity) - 1;
                if (order.TotalPrice == 0)
                {
                    de.lblTotal.Text = "Miễn phí";
                }
                else
                {
                    de.lblTotal.Text = String.Format("{0:0,0}", order.TotalPrice);
                }
                DialogResult kq = de.ShowDialog();
                if (kq == DialogResult.OK)
                {
                    DetailBillBUS.InsertDetailBill(currentBillId, order.ID, de.cbQuantity.SelectedIndex + 1);
                    LoadListOrder(currentBillId);
                }
                else if (kq == DialogResult.Yes)
                {
                    LoadListOrder(currentBillId);
                    if (!DetailBillBUS.IsEmpty(currentBillId))
                    {
                        btnTamTinh.Enabled   = false;
                        btnThanhToan.Enabled = false;
                        txttotalPrice.Text   = "";
                        txtHD.Text           = "";
                    }
                }
            }
        }