void LoadBill() { var bill = (from b in db.Bills where b.DateOut != null select b).ToList(); List <BillDAO> listbd = new List <BillDAO>(); foreach (var item in bill) { BillDAO bd = new BillDAO(); var tablename = (from t in db.TableFoods where t.id == item.idTable select t).SingleOrDefault(); bd.Table = tablename.Name; bd.Id = item.id; bd.Checkin = item.DateIn; bd.Checkout = item.DateOut; bd.Username = item.userName; var tongtien = (from b in db.BillDetails where b.idBill == item.id select b).ToList(); double tong = 0; foreach (var item2 in tongtien) { var food = (from f in db.Foods where f.id == item2.idFood select f.Price).SingleOrDefault(); tong = tong + (food * item2.COUNT); } bd.Tongtien = tong; listbd.Add(bd); } dtgvDoanhThu.DataSource = listbd; }
private void btnPay_Click(object sender, EventArgs e) { Table table = lsvDetailBill.Tag as Table; int idBill = BillDAO.GetBillByTable(table.ID); if (idBill != -1) { if (MessageBox.Show("Bạn có chắc thanh toán hóa đơn cho bàn " + table.Name, "Thông báo", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { BillDAO.CheckOut(idBill); ShowBill(table.ID); LoadTable(); } } }
private void btnAddDrink_Click(object sender, EventArgs e) { Table table = lsvDetailBill.Tag as Table; int idBill = BillDAO.GetBillByTable(table.ID); int idDrink = (cbDrink.SelectedItem as Drink).ID; int count = (int)nmCount.Value; if (idBill == -1) { BillDAO.InsertBill(table.ID); BillInfoDAO.InsertBillInFo(BillDAO.GetMaxBill(), idDrink, count); } else { BillInfoDAO.InsertBillInFo(idBill, idDrink, count); } ShowBill(table.ID); LoadTable(); }