public ActionResult DeleteConfirmed(int id) { Oders_Detail oders_Detail = db.Oders_Details.Find(id); db.Oders_Details.Remove(oders_Detail); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Order_Detail,Oders_id,pro_id,quantity,detail_price,detail_sale_price,total_price")] Oders_Detail oders_Detail) { if (ModelState.IsValid) { db.Entry(oders_Detail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Oders_id = new SelectList(db.Oderss, "Oders_id", "cus_id", oders_Detail.Oders_id); ViewBag.pro_id = new SelectList(db.Products, "pro_id", "pro_name", oders_Detail.pro_id); return(View(oders_Detail)); }
// GET: Admin_quanli/Oders_Detail/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Oders_Detail oders_Detail = db.Oders_Details.Find(id); if (oders_Detail == null) { return(HttpNotFound()); } return(View(oders_Detail)); }
// GET: Admin_quanli/Oders_Detail/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Oders_Detail oders_Detail = db.Oders_Details.Find(id); if (oders_Detail == null) { return(HttpNotFound()); } ViewBag.Oders_id = new SelectList(db.Oderss, "Oders_id", "cus_id", oders_Detail.Oders_id); ViewBag.pro_id = new SelectList(db.Products, "pro_id", "pro_name", oders_Detail.pro_id); return(View(oders_Detail)); }
public ActionResult CheckOutt(string payment_met, string fullname, string address, string phone, Oders order, string descripsion, string date) { List <Basket> carts = (List <Basket>)Session["basket"]; var total = carts.Sum(x => x.Price * x.Quantity); var uid = Session["admin"].ToString(); Customer user = db.Customers.Find(uid); var bill = new Oders(); bill.Oders_id = "OD" + DateTime.Now.ToString("ddMMyyyy-hhmmss"); bill.cus_id = user.cus_id; bill.fullname = fullname; bill.phone = phone; bill.address = address; bill.Description = descripsion; bill.total_amount = total; bill.payment_method = payment_met; bill.create_date = DateTime.Now; try { db.Oderss.Add(bill); db.SaveChanges(); var listPay = (List <Basket>)Session["basket"]; foreach (var item in listPay) { var detail = new Oders_Detail(); //detail.OrderDetailId = "DT" + DateTime.Now.ToString("dd/MM/yyyy-mmhhss"); detail.Oders_id = bill.Oders_id; detail.pro_id = item.ProductId; detail.quantity = item.Quantity; detail.detail_sale_price = item.Price; detail.total_price = item.Money; db.Oders_Details.Add(detail); db.SaveChanges(); } Session.Remove("basket"); } catch (Exception ex) { throw new ApplicationException("Có lỗi xảy ra không thể thực hiện thanh toán: ", ex); } return(View("Success")); }