コード例 #1
0
        public ActionResult Update(Product model)
        {
            try
            {
                var f = Request.Files["uplLogo"];
                if (f != null && f.ContentLength > 0)
                {
                    model.Image = model.Id
                                  + f.FileName.Substring(f.FileName.LastIndexOf("."));
                    f.SaveAs(Server.MapPath("/Content/img/products/" + model.Image));
                }
                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                ModelState.AddModelError("", "Updated");
            }
            catch
            {
                ModelState.AddModelError("", "Error");
            }

            ViewBag.Products   = db.Products;
            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", model.CategoryId);
            ViewBag.SupplierId = new SelectList(db.Suppliers, "Id", "Name", model.SupplierId);
            return(View("Index", model));
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "Id,OrderId,ProductId,UnitPrice,Quantity,Discount")] Supplier chitiet)
 {
     if (ModelState.IsValid)
     {
         db.Entry(chitiet).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(chitiet));
 }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "Id,Password,Fullname,Email,Photo,Activated")] Customer khachhang)
 {
     if (ModelState.IsValid)
     {
         db.Entry(khachhang).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(khachhang));
 }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "Id,CustomerId,OrderDate,RequireDate,Receiver,Address,Description,Amount")] Order dondh)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dondh).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dondh));
 }
コード例 #5
0
 public ActionResult Edit([Bind(Include = "Id,NameVN,Name,Icon")] Category danmuc)
 {
     if (ModelState.IsValid)
     {
         db.Entry(danmuc).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(danmuc));
 }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "Id,Name,Logo,Email,Phone")] Supplier nhasx)
 {
     if (ModelState.IsValid)
     {
         db.Entry(nhasx).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(nhasx));
 }
コード例 #7
0
 public ActionResult Edit([Bind(Include = "Id,OrderId,ProductId,UnitPrice,Quantity,Discount")] OrderDetail orderDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orderDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OrderId   = new SelectList(db.Orders, "Id", "CustomerId", orderDetail.OrderId);
     ViewBag.ProductId = new SelectList(db.Products, "Id", "Name", orderDetail.ProductId);
     return(View(orderDetail));
 }
コード例 #8
0
        public ActionResult Edit(Product Ma, int CategoryID, string Suppliers)
        {
            //  db.Products.(Id);
            if (ModelState.IsValid)
            {
                Ma.SupplierId = (Suppliers);

                Ma.CategoryId = CategoryID;
                // Ma.UnitBrief ="";
                Ma.ProductDate = DateTime.Now;
                //  Ma.SupplierId = "";
                db.Entry(Ma).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
コード例 #9
0
        public ActionResult Update(Supplier model)
        {
            try
            {
                var f = Request.Files["uplLogo"];
                if (f != null && f.ContentLength > 0)
                {
                    model.Logo = model.Id
                                 + f.FileName.Substring(f.FileName.LastIndexOf("."));
                    f.SaveAs(Server.MapPath("/Content/img/suppliers/" + model.Logo));
                }
                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                ModelState.AddModelError("", "Updated");
            }
            catch
            {
                ModelState.AddModelError("", "Error");
            }

            ViewBag.Suppliers = db.Suppliers;
            return(View("Index", model));
        }