private void btnSwitchTable_Click(object sender, EventArgs e) { Tablecoffe table = lsvBill.Tag as Tablecoffe; int idbill = UncheckBill(table.id); int tableswitch = int.Parse(cbSwitchTable.SelectedValue.ToString()); int idbillswitch = UncheckBill(tableswitch); List <BillInfo> listbillinfo = db.BillInfoes.Where(c => c.idBill == idbill).ToList(); if (idbillswitch == -1) { insertBill(tableswitch); foreach (BillInfo item in listbillinfo) { insertBillInfo(MaxIdBill(), item.idDrinks, item.CountItem); } } else { foreach (BillInfo item in listbillinfo) { insertBillInfo(idbillswitch, item.idDrinks, item.CountItem); } } Bill bill = db.Bills.Where(c => c.id == idbill).SingleOrDefault(); bill.status = 0; db.SaveChanges(); showbill(table.id); loadtable(); }
private void btTableDelete_Click(object sender, EventArgs e) { int a = Convert.ToInt32(tbTableID.Text); Tablecoffe table = db.Tablecoffes.Where(c => c.id == a).SingleOrDefault(); db.Tablecoffes.Remove(table); db.SaveChanges(); MessageBox.Show("Xoá thành công"); loadtable(); }
private void dtgTable_CellClick(object sender, DataGridViewCellEventArgs e) { tbTableID.Text = dtgTable.CurrentRow.Cells[0].Value.ToString(); tbTableName.Text = dtgTable.CurrentRow.Cells[1].Value.ToString(); int a = Convert.ToInt32(tbTableID.Text); Tablecoffe table = db.Tablecoffes.Where(c => c.id == a).SingleOrDefault(); if (table.status == 1) { rdbtYes.Checked = true; } else { rdbtNo.Checked = true; } }
private void btTableEdit_Click(object sender, EventArgs e) { int a = Convert.ToInt32(tbTableID.Text); Tablecoffe table = db.Tablecoffes.Where(c => c.id == a).SingleOrDefault(); table.name = tbTableName.Text; if (rdbtYes.Checked) { table.status = 1; } else { table.status = 0; } db.SaveChanges(); MessageBox.Show("sửa thành công"); loadtable(); }
private void btTableAdd_Click(object sender, EventArgs e) { Tablecoffe table = new Tablecoffe(); table.name = tbTableName.Text; if (rdbtYes.Checked) { table.status = 1; } else { table.status = 0; } db.Tablecoffes.Add(table); db.SaveChanges(); MessageBox.Show("Thêm thành công"); loadtable(); }
private void btnAddFood_Click(object sender, EventArgs e)//thêm item { Tablecoffe table = lsvBill.Tag as Tablecoffe; int idBill = UncheckBill(table.id); int drinksID = (cbDrinks.SelectedItem as Drink).id; int count = (int)nmDrinksCount.Value; if (idBill == -1)//nếu bàn chưa có người thì add vào { insertBill(table.id); insertBillInfo(MaxIdBill(), drinksID, count); table.status = 1; db.SaveChanges(); } else//thêm item vào bàn có người { insertBillInfo(idBill, drinksID, count); } showbill(table.id); loadtable(); }
private void btnCheckOut_Click(object sender, EventArgs e)//tính tiền { Tablecoffe table = lsvBill.Tag as Tablecoffe; int idbill = UncheckBill(table.id); double totalprice = Convert.ToDouble(txbTotalPrice.Text.Split(',')[0]); if (idbill != -1) { if (MessageBox.Show(string.Format("Bạn có muốn thanh toán hoá đơn cho {0}\nTổng tiền là {1},000", table.name, totalprice), "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK) { Bill bill = db.Bills.Where(c => c.id == idbill).SingleOrDefault(); bill.status = 0; bill.DateCheckOut = DateTime.Now; bill.totalprice = (int)totalprice; table.status = 1; db.SaveChanges(); showbill(table.id); loadtable(); } } }