public static bool payAndInsertDetailBill(DataGridView dgv, bill bil) { MessageBox.Show("Toan 3"); bool check = false;; int i = 0; for (i = 0; i < dgv.Rows.Count; i++) { check = false; detailBill detaiBill = new detailBill(); detaiBill.IdBill = bil.IdBill; detaiBill.IdProduct = int.Parse(dgv.Rows[i].Cells["idsp"].Value.ToString()); detaiBill.Price = int.Parse(dgv.Rows[i].Cells["giaban"].Value.ToString()); detaiBill.Quantity = int.Parse(dgv.Rows[i].Cells["soluong"].Value.ToString()); string sql = "insert into CHITIETHOADON values('" + detaiBill.IdBill + "','" + detaiBill.IdProduct + "','" + detaiBill.Price + "','" + detaiBill.Quantity + "')"; if (ConnectDAO.queryNonQuery(sql)) { check = true; } if (!check) { break; } //Console.WriteLine("chi tuet HOA DON"); //Console.WriteLine(" ma ct HOA DON" + detaiBill.IdBill); //Console.WriteLine(" id san pham" + detaiBill.IdProduct); //Console.WriteLine("gia" + detaiBill.Price); //Console.WriteLine("sol luong" + detaiBill.Quantity); } return(check); }
public ActionResult DeleteConfirmed(int id) { detailBill detailbill = db.detailBill.Find(id); db.detailBill.Remove(detailbill); db.SaveChanges(); return(RedirectToAction("Index")); }
// // GET: /detailBill/Details/5 public ActionResult Details(int id = 0) { detailBill detailbill = db.detailBill.Find(id); if (detailbill == null) { return(HttpNotFound()); } return(View(detailbill)); }
public ActionResult Edit(detailBill detailbill) { if (ModelState.IsValid) { db.Entry(detailbill).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.bill = new SelectList(db.bill, "id", "payment_term", detailbill.bill); ViewBag.product = new SelectList(db.product, "id", "product_name", detailbill.product); return(View(detailbill)); }
// // GET: /detailBill/Edit/5 public ActionResult Edit(int id = 0) { detailBill detailbill = db.detailBill.Find(id); if (detailbill == null) { return(HttpNotFound()); } ViewBag.bill = new SelectList(db.bill, "id", "payment_term", detailbill.bill); ViewBag.product = new SelectList(db.product, "id", "product_name", detailbill.product); return(View(detailbill)); }
public ActionResult Create(detailBill detailbill) { if (ModelState.IsValid) { db.detailBill.Add(detailbill); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.bill = new SelectList(db.bill, "id", "payment_term", detailbill.bill); ViewBag.product = new SelectList(db.product, "id", "product_name", detailbill.product); return(View(detailbill)); }