public ActionResult Buy(string phone, string name) { // lưu bảng bill -> idbill BillDao dao = new BillDao(); Bill bill = new Bill(); bill.username = name; bill.iduser = phone; int id = dao.Add(bill); ShoppingCart cart = (ShoppingCart)Session["cart"]; if (cart != null) { List <ItemCart> ListCart = cart.ListItem; List <BilDetail> ls = new List <BilDetail>(); for (int i = 0; i < ListCart.Count; i++) { BilDetail billdetail = new BilDetail(); billdetail.idbill = idbill; billdetail.idproduct = idproduct; billdetail.quantity = ListCart[i].quantity; billdetail.prict = (decimal)ListCart[i].price; ls.Add(billdetail); // lưu bảng billandProduct dao.addBillDetai(ls); } } Session["cart"] = null; return(View()); }
public bool createBills(DataGrid dg, DateTime bill_date, DateTime traffic_month_and_year, bool print) { bool valid = false; foreach (Company c in dg.SelectedItems) { Bill newBill = (Bill)c.Bill.Clone(); newBill.BillDate = bill_date; newBill.BillNumForYear = BillMaxHelper.findMaxBillNumForYear(traffic_month_and_year.Year) + 1; newBill.TrafficMonth = MonthHelper.getMonthFromInt(traffic_month_and_year.Month); newBill.TrafficYear = traffic_month_and_year.Year; newBill.Id = ApplicationA.Instance.Bills[ApplicationA.Instance.Bills.Count - 1].Id + 1; valid = BillDao.Add(newBill); if (valid) { ApplicationA.Instance.Bills.Add(newBill); c.Bill = newBill; ApplicationA.WriteToLogActions(newBill.Id, "racun"); } MessageBox.Show(newBill.Items.Count.ToString()); foreach (Billitem item in newBill.Items) { valid = BillitemDao.Add(item, newBill); if (valid) { item.Id = BillMaxHelper.findMaxBillItemId(newBill); ApplicationA.WriteToLogActions(item.Id, "stavka racuna"); } } if (print) { ExcelFileEditHelper.editExcelFile(c, print); } } return(valid); }
internal void SaveBill(Bill bill) { _billDao.Add(bill); }
public string Add(Bill bill) { ISqlMapper mapper = MapperHelper.GetMapper(); BillDao dao = new BillDao(mapper); return dao.Add(bill); }