Exemple #1
0
        public ActionResult Edit(Product model)
        {
            CheckBangSanPham(model);
            if (ModelState.IsValid)
            {
                using (var scope = new TransactionScope())
                {
                    Product pro = db.Product.Where(p => p.ID == model.ID).FirstOrDefault();
                    db.Entry(pro).CurrentValues.SetValues(model);
                    db.SaveChanges();

                    var path = Server.MapPath("~/App_Data");
                    path = path + '/' + model.ID;
                    if (Request.Files["HinhAnh"] != null && Request.Files["HinhAnh"].ContentLength > 0)
                    {
                        Request.Files["HinhAnh"].SaveAs(path);
                    }
                    else
                    {
                        ModelState.AddModelError("HinhAnh", "Chưa có hình sản phẩm");
                    }

                    scope.Complete(); // approve for transaction
                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.ProductTypeID = new SelectList(db.ProductType, "ID", "ProductTypeName", model.ProductTypeID);
            return(View(model));
        }
Exemple #2
0
 public ActionResult Edit(CashBill cashBill)
 {
     if (ModelState.IsValid)
     {
         try
         {
             db.Entry(cashBill).State = EntityState.Modified;
             Session["CashBill"]      = cashBill;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch (Exception e)
         {
             ModelState.AddModelError("", e.Message);
         }
     }
     return(View(cashBill));
 }
 public ActionResult Edit([Bind(Include = "ID,BillCode,CustomerName,PhoneNumber,Address,Date,Shipper,Note,GrandTotal")] CashBill cashBill)
 {
     Check(cashBill);
     if (ModelState.IsValid)
     {
         db.Entry(cashBill).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cashBill));
 }
Exemple #4
0
 public ActionResult Edit(ProductType model)
 {
     checkProductType(model);
     if (ModelState.IsValid)
     {
         db.Entry(model).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Exemple #5
0
        public ActionResult Edit(Account model)
        {
            if (ModelState.IsValid)
            {
                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            return(View(model));
        }
 public ActionResult Edit(CashBillDetail cashBillDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cashBillDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BillID    = new SelectList(db.CashBill, "ID", "BillCode", cashBillDetail.BillID);
     ViewBag.ProductID = new SelectList(db.Product, "ID", "ProductCode", cashBillDetail.ProductID);
     return(View(cashBillDetail));
 }
 public ActionResult Edit([Bind(Include = "ID,BillCode,CustomerID,Date,Shipper,Note,Method,Period,GrandTotal,Taken,Remain")] InstallmentBill installmentBill)
 {
     Check(installmentBill);
     if (ModelState.IsValid)
     {
         db.Entry(installmentBill).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerID = new SelectList(db.Customer, "ID", "CustomerCode", installmentBill.CustomerID);
     return(View(installmentBill));
 }