private void btnAddTable_Click(object sender, EventArgs e) { if (txtTableName.Text == "") { MessageBox.Show("Xin nhập đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK); } else { TableFood t = new TableFood(); var trung = (from f in db.TableFoods where f.Name == txtTableName.Text && f.idStatusDelete == 0 select f).SingleOrDefault(); if (trung != null) { MessageBox.Show("trùng tên bàn!!"); return; } t.Name = txtTableName.Text; t.stat = "Trống"; t.idStatusDelete = 0; db.TableFoods.Add(t); db.SaveChanges(); MessageBox.Show("Thêm bàn thành công", "Thông báo", MessageBoxButtons.OK); dtgvTable.DataSource = (from f in db.TableFoods where f.idStatusDelete == 0 select f).ToList(); } }
private void btnThemMon_Click(object sender, EventArgs e) { TableFood table = lsvBill.Tag as TableFood; if (table == null) { MessageBox.Show("Hãy chọn bàn!!"); return; } int idBill = GetUnCheckBilbyIdTable(table.id); int foodId = (cbFood.SelectedItem as Food).id; int count = (int)nmFoodCount.Value; if (idBill == -1) { if ((int)nmFoodCount.Value <= (int)0) { return; } InserBill(table.id); InserBillDetails(GetMaxIdBill(), foodId, count); UpdateTableWhenOder(table.id); } else { InserBillDetails(idBill, foodId, count); } ShowBill(table.id); }
void UpdateTableWhenOder(int id) { foreach (var item in lstButton) { TableFood tb = item.Tag as TableFood; if (tb.id == id) { var tablefromdb = (from t in db.TableFoods where t.id == tb.id select t).SingleOrDefault(); item.BackColor = Color.Pink; tablefromdb.stat = "Có người"; db.SaveChanges(); item.Text = tablefromdb.Name + Environment.NewLine + tablefromdb.stat; } } }
private void btnThanhToan_Click(object sender, EventArgs e) { TableFood table = lsvBill.Tag as TableFood; if (table == null) { return; } int idBill = GetUnCheckBilbyIdTable(table.id); if (idBill != -1) { if (MessageBox.Show("Thanh toán cho " + table.Name, "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK) { CheckOut(idBill); UpdateTableWhenPay(table.id); ShowBill(table.id); } } }
void LoadTableStatus(int idTable) { TableFood table = DAL_TableFood.Instance.LoadTableStatusByID(idTable); UpdateTableStatus(btnTable[idTable], table.Name, table.Status); }