Example #1
0
        private void btnaddfood_Click(object sender, EventArgs e)
        {
            if (lsvBill.Tag == null)
            {
                MessageBox.Show("Hãy chọn bàn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            lsvBill.Items.Clear();
            TableDTO table = lsvBill.Tag as TableDTO;                   //mục đích: lấy id của bàn đang được chọn để thêm

            int idbill = BillDAO.GetUncheckedBillIDByTableID(table.ID); //từ id bàn => lấy được id của hóa đơn
            int idfood = (cbThucAn.SelectedItem as FoodDTO).Id;
            int count  = (int)nmfoodcount.Value;

            if (idbill == -1)//case: chưa có hóa đơn, bàn còn trống
            {
                BillDAO.InsertBill(table.ID);
                //tham số idhoadon: hoa don them sau cung => co id la lon nhat
                //tham số id thức ăn: lấy từ combobox
                //tham số số lượng thức ăn lấy từ nmfoodcount
                BillInfoDAO.InsertBillInfo(BillDAO.GetMaxIdBill(), idfood, count);
            }
            else//case: hóa đơn đã tồn tại => sẽ thêm món mới hoặc cập nhật thêm số lượng món
                //kiểm tra món đã tồn tại hay chưa ta xử lí bên dưới server
            {
                BillInfoDAO.InsertBillInfo(idbill, idfood, count);
            }

            nmfoodcount.Value = 1;
            Showbill(table.ID);
            LoadTable();
        }
Example #2
0
 public bool InsertBillInfo(BillInfo dto)
 {
     return(dao.InsertBillInfo(dto));
 }