Exemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "detail_ID,user_ID,cart_ID,ID,detail_TotalBegin,detail_fee,detail_Totalmoney,detail_ShipName,detail_ShipLastName,detail_ShipPhone,detail_ShipEmail,detail_ShipProvince,detail_ShipDistrict,detail_ShipTown,detail_ShipStreet,detail_PayName,detail_PayLastName,detail_PayPhone,detail_PayEmail,detail_PayProvince,detail_PayDistrict,detail_PayTown,detail_PayStreet,detail_dateorder,detail_note,checked")] OrderDetail orderDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orderDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.cart_ID = new SelectList(db.Orders, "cart_ID", "pro_Name", orderDetail.cart_ID);
     ViewBag.ID      = new SelectList(db.SaleCodes, "ID", "sale_code", orderDetail.ID);
     ViewBag.user_ID = new SelectList(db.Users, "user_ID", "user_PassWord", orderDetail.user_ID);
     return(View(orderDetail));
 }
Exemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "Color_ID,NameColor,Code")] Color color)
 {
     if (ModelState.IsValid)
     {
         db.Entry(color).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(color));
 }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "contact_ID,contact_LastName,contact_Name,contact_Address,contact_Phone,contact_Email,contactt_Content")] Contact contact)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contact).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(contact));
 }
Exemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "OptionID,Name")] OptionSale optionSale)
 {
     if (ModelState.IsValid)
     {
         db.Entry(optionSale).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OptionID = new SelectList(db.OptionSales, "OptionID", "Name", optionSale.OptionID);
     ViewBag.OptionID = new SelectList(db.OptionSales, "OptionID", "Name", optionSale.OptionID);
     return(View(optionSale));
 }
 public ActionResult Edit([Bind(Include = "group_ID,group_Name,image,Description")] GroupProduct groupProduct, HttpPostedFileBase ChangeImage)
 {
     if (ModelState.IsValid)
     {
         if (ChangeImage != null)
         {
             string path = Server.MapPath("~/Uploads/nhomsanpham");
             if (!Directory.Exists(path))
             {
                 Directory.CreateDirectory(path);
             }
             string filename = ChangeImage.FileName.Split('\\').Last();
             ChangeImage.SaveAs(path + "\\" + filename);
             groupProduct.image = "/Uploads/nhomsanpham" + "\\" + filename;
         }
         db.Entry(groupProduct).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(groupProduct));
 }
Exemplo n.º 6
0
 public ActionResult Edit(Menu menu, HttpPostedFileBase ChangeImage)
 {
     if (ModelState.IsValid)
     {
         if (ChangeImage != null)
         {
             string path = Server.MapPath("~/Uploads/danhmuc");
             if (!Directory.Exists(path))
             {
                 Directory.CreateDirectory(path);
             }
             string filename = ChangeImage.FileName.Split('\\').Last();
             ChangeImage.SaveAs(path + "\\" + filename);
             menu.Image = "/Uploads/danhmuc" + "\\" + filename;
         }
         db.Entry(menu).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(menu));
 }
Exemplo n.º 7
0
        public ActionResult Edit(Product product, HttpPostedFileBase Image, Boolean DeleteSmallImage, HttpPostedFileBase[] moreimage)
        {
            if (ModelState.IsValid)
            {
                string path          = Server.MapPath("~/Uploads/AnhSanPham");
                string pathMoreimage = Server.MapPath("~/Uploads/AnhChiTietSanPham");
                if (Image != null)
                {
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    string filename = Image.FileName.Split('\\').Last();
                    Image.SaveAs(path + "\\" + filename);
                    product.pro_Image = "/Uploads/AnhSanPham" + "\\" + filename;
                }
                if (DeleteSmallImage.Equals(true))
                {
                    var remove = db.LinkImages.Where(x => x.pro_ID == product.pro_ID).ToList();
                    foreach (var i in remove)
                    {
                        db.LinkImages.Remove(i);
                    }
                }
                if (moreimage.FirstOrDefault() != null)
                {
                    var deteleitem = db.LinkImages.Where(x => x.pro_ID == product.pro_ID).ToList();
                    foreach (var item in deteleitem)
                    {
                        db.LinkImages.Remove(item);
                    }

                    foreach (var item in moreimage)
                    {
                        if (!Directory.Exists(pathMoreimage))
                        {
                            Directory.CreateDirectory(pathMoreimage);
                        }
                        string Selectfile = item.FileName.Split('\\').Last();
                        item.SaveAs(pathMoreimage + "\\" + Selectfile);
                        LinkImage smallimage = new LinkImage();
                        smallimage.pro_ID          = product.pro_ID;
                        smallimage.link_ImageSmall = "/Uploads/AnhChiTietSanPham" + "\\" + Selectfile;
                        db.LinkImages.Add(smallimage);
                    }
                }

                db.Entry(product).State = EntityState.Modified;
                if (product.pro_Quanty > 0)
                {
                    product.pro_Status = true;
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.Color_ID = new SelectList(db.Colors, "Color_ID", "NameColor", product.Color_ID);
            ViewBag.group_ID = new SelectList(db.GroupProducts, "group_ID", "group_Name", product.group_ID);
            ViewBag.Menu_ID  = new SelectList(db.Menus, "Menu_ID", "Name", product.Menu_ID);
            ViewBag.OptionID = new SelectList(db.OptionSales, "OptionID", "Name", product.OptionID);
            ViewBag.OptionID = new SelectList(db.OptionSales, "OptionID", "Name", product.OptionID);
            return(View(product));
        }