Exemplo n.º 1
0
 public ActionResult Edit(CashBill cashBill)
 {
     checkValidator(cashBill);
     if (ModelState.IsValid)
     {
         cashBill.Date            = DateTime.Now;
         db.Entry(cashBill).State = EntityState.Modified;
         Session["CashBill"]      = cashBill;
         db.SaveChanges();
         return(Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString()));
     }
     return(Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString()));
 }
 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()));
 }
Exemplo n.º 3
0
 public ActionResult Edit(News news)
 {
     if (ModelState.IsValid)
     {
         using (var scope = new TransactionScope())
         {
             if (Request.Files["ImageFile"] != null && Request.Files["ImageFile"].ContentLength > 0)
             {
                 var fileNameOld = Server.MapPath(news.Image);
                 if (System.IO.File.Exists(fileNameOld))
                 {
                     System.IO.File.Delete(fileNameOld);
                 }
                 //string fileName = Path.GetFileNameWithoutExtension(product.ImageFile.FileName);
                 string extension = Path.GetExtension(Request.Files["ImageFile"].FileName);
                 string fileName  = RandomString(5, true) + DateTime.Now.ToString("yymmssfff") + extension;
                 news.Image = "/Assets/Admin/img/news/" + fileName;
                 fileName   = Path.Combine(Server.MapPath("/Assets/Admin/img/news/"), fileName);
                 Request.Files["ImageFile"].SaveAs(fileName);
             }
             db.Entry(news).State = EntityState.Modified;
             db.SaveChanges();
             scope.Complete();
             TempData["message"] = "Chỉnh sửa tin tức thành công.";
             return(RedirectToAction("Index"));
         }
     }
     return(View(news));
 }
Exemplo n.º 4
0
 public ActionResult Edit(Product product)
 {
     CheckValidationProduct(product);
     if (ModelState.IsValid)
     {
         using (var scope = new TransactionScope())
         {
             if (Request.Files["ImageFile"] != null && Request.Files["ImageFile"].ContentLength > 0)
             {
                 var fileNameOld = Server.MapPath(product.Avatar);
                 if (System.IO.File.Exists(fileNameOld))
                 {
                     System.IO.File.Delete(fileNameOld);
                 }
                 //string fileName = Path.GetFileNameWithoutExtension(product.ImageFile.FileName);
                 string extension = Path.GetExtension(Request.Files["ImageFile"].FileName);
                 string fileName  = RandomString(5, true) + DateTime.Now.ToString("yymmssfff") + extension;
                 product.Avatar = "/Assets/Admin/img/products/" + fileName;
                 fileName       = Path.Combine(Server.MapPath("/Assets/Admin/img/products/"), fileName);
                 Request.Files["ImageFile"].SaveAs(fileName);
             }
             db.Entry(product).State = EntityState.Modified;
             db.SaveChanges();
             scope.Complete();
             TempData["message"] = "Chỉnh sửa sản phẩm thành công.";
             return(RedirectToAction("Index"));
         }
     }
     ViewBag.ProductTypeID = new SelectList(db.ProductTypes, "ID", "ProductTypeName", product.ProductTypeID);
     return(View(product));
 }
Exemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "ID,Fullname,Email,Phone,Title,Comment")] Contact contact)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contact).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(contact));
 }
Exemplo n.º 6
0
 public ActionResult Index(Introduction introduction)
 {
     if (ModelState.IsValid)
     {
         introduction.ID = 1;
         db.Entry(introduction).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(introduction));
 }
Exemplo n.º 7
0
 public ActionResult Edit(InstallmentBillDetail installmentBillDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(installmentBillDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BillID    = new SelectList(db.InstallmentBills, "ID", "BillCode", installmentBillDetail.BillID);
     ViewBag.ProductID = new SelectList(db.Products, "ID", "ProductCode", installmentBillDetail.ProductID);
     return(View(installmentBillDetail));
 }
Exemplo n.º 8
0
 public ActionResult Edit(ProductType productType)
 {
     checkValidatorProductType(productType);
     if (ModelState.IsValid)
     {
         db.Entry(productType).State = EntityState.Modified;
         db.SaveChanges();
         TempData["message"] = "Chỉnh sửa loại sản phẩm thành công.";
         return(RedirectToAction("Index"));
     }
     return(View(productType));
 }