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 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.º 4
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           = "";
                    }
                }
            }
        }