public void loadInfoOrder(BillSell billSell) { fORDER f1 = Application.OpenForms.OfType <fORDER>().FirstOrDefault(); if (f1 != null) { if (billSell == null) { f1.lbCount.Text = 0.ToString(); f1.lbTotal.Text = String.Format("{0:0,00} VNĐ", 0.0); return; } DetailBillSellService detailBillSellService = new DetailBillSellService(new CoffeShopContext()); f1.lbCount.Text = detailBillSellService.GetCountDetail(billSell).ToString(); BillSellService bsService = new BillSellService(new CoffeShopContext()); var detail = detailBillSellService.GetDetailBillSell(billSell); if (detail.Count == 0) { f1.lbCount.Text = detailBillSellService.GetCountDetail(billSell).ToString(); f1.lbTotal.Text = String.Format("{0:0,00} VNĐ", 0.0); return; } bsService.SetTotal(detail, billSell); f1.lbTotal.Text = String.Format("{0:0,00} VNĐ", bsService.GetTotal(billSell)); } }
public bool DeleteDetailBillSellAll(BillSell billSell) { var list = GetDetailBillSell(billSell); _context.DetailBillSells.RemoveRange(list); return(true); }
private void btnFinish_Click(object sender, EventArgs e) { bool check = true; fORDER f1 = Application.OpenForms.OfType <fORDER>().FirstOrDefault(); if (f1 != null) { try { BillSell billSell = f1.getBillSellofTable(); DetailBillSellService detailBillSellService = new DetailBillSellService(new CoffeShopContext()); int number = Convert.ToInt32(cbbNumber.SelectedItem); var DetailBillSell = detailBillSellService.CreateDetailBillSell(billSell, _product, number); var DetailBill = detailBillSellService.GetDetailBill(DetailBillSell); f1.addProductToListOrder(DetailBill); f1.lbCount.Text = detailBillSellService.GetCountDetail(billSell).ToString(); BillSellService bsService = new BillSellService(new CoffeShopContext()); bsService.SetTotal(detailBillSellService.GetDetailBillSell(billSell), billSell); f1.lbTotal.Text = String.Format("{0:0,00} VNĐ", bsService.GetTotal(billSell)); } catch (Exception) { cbbNumber.Refresh(); check = false; } } if (check) { this.Dispose(); } }
public BillSell CreateBillSell(Employe employe, Customer customer = null, Tables table = null) { if (customer == null && !table.status) { CustomerService cust = new CustomerService(_context); var _customer = cust.GetCustomer(Constants.Constants.customerDefault); BillSell billSell = new BillSell() { createDate = DateTime.Now, totalMoney = 0, status = false, }; UserService userService = new UserService(_context); billSell.Employe = userService.GetUser(employe); TableService tableService = new TableService(_context); billSell.Table = tableService.GetTables(table); _context.Entry(billSell); _context.BillSells.Attach(billSell); _context.BillSells.Add(billSell); _context.SaveChanges(); tableService.SetStatusTable(table, true); return(billSell); } return(null); }
public bool setStatus(bool status, BillSell billSell) { var bill = _context.BillSells.Where(x => x.Id == billSell.Id).Include(x => x.Employe).Include(x => x.DetailBillSells).Include(x => x.Table).SingleOrDefault(); bill.status = status; _context.SaveChanges(); return(true); }
private void uc_Table_Load(object sender, EventArgs e) { BillSellService billSellService = new BillSellService(new CoffeShopContext()); label1.Text = index.ToString(); if (table.status) { label1.BackColor = Color.Yellow; Name = billSellService.GetBillSell(table).Id.ToString(); _billSell = billSellService.GetBillSell(table); } }
//public bool DeleteBill() public bool DeleteBillSell(BillSell billSell) { var bil = _context.BillSells.FirstOrDefault(x => x.Id == billSell.Id); if (bil != null) { _context.BillSells.Remove(bil); _context.SaveChanges(); return(true); } return(false); }
public bool SetTotal(List <DetailBillSell> detailBillSells, BillSell billSell) { decimal total = 0; foreach (var item in detailBillSells) { total += item.Total; } var bill = _context.BillSells.Where(x => x.Id == billSell.Id).Include(x => x.Employe).Include(x => x.DetailBillSells).Include(x => x.Table).SingleOrDefault(); bill.totalMoney = total; _context.SaveChanges(); return(true); }
public DetailBillSell CreateDetailBillSell(BillSell billSell, Product product, int number) { DetailBillSell detailBillSell = new DetailBillSell { Quantum = number, Total = product.priceProduct * number, }; ProductService productService = new ProductService(_context); detailBillSell.Product = productService.GetProduct(product); BillSellService billSellService = new BillSellService(_context); detailBillSell.BillSells = new List <BillSell>() { billSellService.GetBillWithId(billSell.Id) }; _context.DetailBillSells.Add(detailBillSell); _context.SaveChanges(); return(detailBillSell); }
private void orderProduct_Click(object sender, EventArgs e) { fORDER.checkStatus = false; BillSellService billSellService = new BillSellService(new CoffeShopContext()); if (!table.status) { _billSell = billSellService.CreateBillSell(employe, null, table); Name = _billSell.Id.ToString(); label1.BackColor = Color.Yellow; } else { Guid Id = new Guid(Name); _billSell = billSellService.GetBillWithId(Id); } if (_billSell != null) { reloadProducts(); } checkOrderd = true; fORDER.staticBill = _billSell; fORDER.staticTable = table; }
public void orderProducts(BillSell billSell) { _billSell = billSell; uc_PanelOrderProducts.Instance.BillSell = billSell; myControls.Instance.addCotrolTableToOrder(uc_PanelOrderProducts.Instance, pnlControl); }
public List <DetailBillSell> GetDetailBillSell(BillSell billSell) { var bill = _context.DetailBillSells.Where(x => x.BillSells.Any(r => r.Id == billSell.Id)).Include(x => x.Product).Include(x => x.BillSells).ToList <DetailBillSell>(); return(bill); }
public int GetCountDetail(BillSell billSell) { return(_context.DetailBillSells.Where(x => x.BillSells.Any(r => r.Id == billSell.Id)).Include(x => x.Product).Include(x => x.BillSells).ToList().Sum(x => x.Quantum)); }
public decimal GetTotal(BillSell billSell) { var bill = _context.BillSells.Where(x => x.Id == billSell.Id).Include(x => x.Employe).Include(x => x.DetailBillSells).Include(x => x.Table).SingleOrDefault(); return(bill.totalMoney); }
public Tables GetTables(BillSell billSell) { return(_context.Tables.Where(x => x.Id == billSell.Table.Id).Include(x => x.BillSells).SingleOrDefault()); }