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)); } }
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(); } }