// GET: Admin/InstallmentBills/Edit/5 public ActionResult Edit(int?id) { Session["idi"] = id; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InstallmentBill installmentBill = db.InstallmentBills.Find(id); var query = db.CashBillDetails.Where(cbd => cbd.BillID == id).ToList(); var b = query as List <CashBillDetail>; var sum = 0; foreach (var chiTiet in b) { sum += (chiTiet.Quantity * chiTiet.SalePrice); } installmentBill.GrandTotal = sum; Session["CashBilli"] = installmentBill; if (installmentBill == null) { return(HttpNotFound()); } ViewBag.CustomerID = new SelectList(db.Customers, "ID", "CustomerCode", installmentBill.CustomerID); return(View(installmentBill)); }
public ActionResult DeleteConfirmed(int id) { InstallmentBill installmentbill = db.InstallmentBills.Find(id); db.InstallmentBills.Remove(installmentbill); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(InstallmentBill model) { if (ModelState.IsValid) { Session["InsCashBill"] = model; } ViewBag.CustomerID = new SelectList(db.Customers, "ID", "CustomerName", model.CustomerID); return(View(model)); }
public ActionResult Create(InstallmentBill installmentBill) { checkValidatorIB(installmentBill); if (ModelState.IsValid) { Session["IBill"] = installmentBill; } ViewBag.CustomerID = new SelectList(db.Customers, "ID", "CustomerCode", installmentBill.CustomerID); return(View(installmentBill)); }
public ActionResult Edit([Bind(Include = "ID,BillCode,CustomerID,Date,Shipper,Note,Method,Period,GrandTotal,Taken,Remain")] InstallmentBill installmentbill) { if (ModelState.IsValid) { db.Entry(installmentbill).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "ID", "CustomerCode", installmentbill.CustomerID); return(View(installmentbill)); }
public ActionResult Edit(InstallmentBill model) { if (ModelState.IsValid) { db.Entry(model).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "ID", "CustomerCode", model.CustomerID); return(View(model)); }
public ActionResult Create([Bind(Include = "ID,BillCode,CustomerID,Date,Shipper,Note,Method,Period,GrandTotal,Taken,Remain")] InstallmentBill installmentBill) { Check(installmentBill); if (ModelState.IsValid) { db.InstallmentBill.Add(installmentBill); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customer, "ID", "CustomerCode", installmentBill.CustomerID); return(View(installmentBill)); }
// GET: /Admin/InstallmentBill/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InstallmentBill installmentbill = db.InstallmentBills.Find(id); if (installmentbill == null) { return(HttpNotFound()); } return(View(installmentbill)); }
public ActionResult Edit(InstallmentBill installmentBill) { checkValidatorIB(installmentBill); if (ModelState.IsValid) { installmentBill.Date = DateTime.Now; db.Entry(installmentBill).State = EntityState.Modified; Session["IBill"] = installmentBill; db.SaveChanges(); return(Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString())); } ViewBag.CustomerID = new SelectList(db.Customers, "ID", "CustomerCode", installmentBill.CustomerID); return(Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString())); }
// GET: Admin/InstallmentBills/Edit/5 public ActionResult Edit(int id) { if (Session["UserName"] != null) { InstallmentBill installmentBill = db.InstallmentBills.Find(id); Session["IBill"] = installmentBill; ViewBag.CustomerID = new SelectList(db.Customers, "ID", "CustomerCode", installmentBill.CustomerID); return(View(installmentBill)); } else { return(RedirectToAction("Login", "Login")); } }
// GET: InstallmentBills/Delete/5 public ActionResult Delete(int?ID) { if (ID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InstallmentBill installmentBill = db.InstallmentBills.Find(ID); if (installmentBill == null) { return(HttpNotFound()); } return(View(installmentBill)); }
// GET: /Admin/InstallmentBill/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InstallmentBill installmentbill = db.InstallmentBills.Find(id); if (installmentbill == null) { return(HttpNotFound()); } ViewBag.CustomerID = new SelectList(db.Customers, "ID", "CustomerCode", installmentbill.CustomerID); return(View(installmentbill)); }
public void checkValidatorIB(InstallmentBill ib) { if (ib.Method.Length <= 0) { ModelState.AddModelError("Method", "Độ dài lớn hơn 0"); } if (ib.Period <= 0) { ModelState.AddModelError("Period", "Thời gian giai hạn lớn hơn "); } if (ib.Shipper != null && !ib.Shipper.StartsWith(" ")) { ModelState.AddModelError("Shipper", "Không nhập kí tự khoảng trắng hoặc để trống"); } }
private void checkInstallBill(InstallmentBill inBill) { if (inBill.Method == null || inBill.Method.Equals("")) { ModelState.AddModelError("Method", "Không được trống"); } if (inBill.Shipper == null || inBill.Shipper.Equals("")) { ModelState.AddModelError("Shipper", "Vui Lòng Điền Tên Người Giao Hàng"); } if (inBill.Period < 15) { ModelState.AddModelError("Period", "Thời gian góp vui lòng từ 15 ngày trở lên"); } if (inBill.Taken <= 0) { ModelState.AddModelError("Taken", "Tiền đã nhận vui lòng lớn hơn 0"); } if (inBill.Remain <= 0) { ModelState.AddModelError("Remain", "Tiền phải góp vui lòng lớn hơn 0"); } }
private void Check(InstallmentBill model) { if (model.CustomerID > 20) { ModelState.AddModelError("CustomerID", "Mã khách hàng phải ít hơn 20 kí tự!"); } if (model.Customer.CustomerName.Length > 50) { ModelState.AddModelError("CustomerName", "Tên khách hàng phải ít hơn 50 kí tự!"); } if (model.Customer.YearOfBirth <= 0) { ModelState.AddModelError("YearOfBirth", "Năm sinh của khách hàng phải lớn hơn 0!"); } if (model.Customer.PhoneNumber.Length <= 0) { ModelState.AddModelError("PhoneNumber", "Số điện thoại phải nhiều hơn 0 kí tự!"); } //if (model.Date) // ModelState.AddModelError("Shipper", "Tên Shipper phải ít hơn 30 kí tự!"); if (model.Customer.Address.Length > 100) { ModelState.AddModelError("Address", "Địa chỉ phải ít hơn 100 kí tự!"); } if (model.Shipper.Length > 50) { ModelState.AddModelError("Shipper", "Tên Shipper phải ít hơn 50 kí tự!"); } if (model.Note.Length > 100) { ModelState.AddModelError("Note", "Ghi chú phải ít hơn 100 kí tự!"); } //if (model.Method < 5) // ModelState.AddModelError("Method", "Hình thức thanh toán phải nhiều hơn 10 kí tự!"); //if (model.Period < 1) // ModelState.AddModelError("Period", "Chu kì phải nhiều hơn 1!"); //if (model.ProductCode > 20) // ModelState.AddModelError("ProductCode", "Mã sản phẩm phải ngắn hơn 20 kí tự!"); //if (model.ProductName > 50) // ModelState.AddModelError("ProductName", "Tên sản phẩm phải ngắn hơn 50 kí tự!"); //if (model.Quantity <= 0) // ModelState.AddModelError("Quantity", "Số lượng phải lớn hơn 0!"); //if (model.InstallmentPrice <= 0) // ModelState.AddModelError("InstallmentPrice", "Giá bán phải lớn hơn 0!"); if (model.GrandTotal <= 0) { ModelState.AddModelError("GrandTotal", "Tổng số tiền thanh toán phải lớn hơn 0!"); } if (model.Taken <= 0) { ModelState.AddModelError("Taken", "Tổng số tiền đã đưa phải lớn hơn 0!"); } if (model.Remain <= 0) { ModelState.AddModelError("Remain", "Tổng số tiền còn lại phải lớn hơn 0!"); } }