public ActionResult Create(HttpPostedFileBase Image, FormCollection form) { string imageLink = "/Content/image/xamomi1.jpg"; if (Image.ContentLength > 0 && Image != null) { imageLink = "/Content/image/" + Image.FileName; string path = Path.Combine(Server.MapPath("~/Content/image"), Image.FileName); Image.SaveAs(path); } var product = new Product() { Masp = form["Masp"], Tensp = form["Tensp"], HinhAnh = imageLink, Kind_PhuKien = Kind_PhuKien.GetKind_PhuKien_Id(db, form["Kind_PhuKien"]), Kind_Product = Kind_Product.GetKind_Product_Id(db, form["Kind_Product"]), Gia = int.Parse(form["Gia"]), Soluong = int.Parse(form["Soluong"]), TrongLuong = form["TrongLuong"], TimeSac = form["TimeSac"], KetNoiCungLuc = form["KetNoiCungLuc"], TimeSuDung = form["TimeSuDung"], }; db.Products.Add(product); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(string id) { Kind_PhuKien kind_PhuKien = db.Kind_PhuKiens.Find(id); db.Kind_PhuKiens.Remove(kind_PhuKien); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: PhuKien/Create public ActionResult Create() { var ProductModel = new Product() { Kind_PhuKiens = Kind_PhuKien.GetKind_PhuKien(db), Kind_Products = Kind_Product.GetKind_Product(db), }; return(View(ProductModel)); }
// GET: Kind_PhuKien/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Kind_PhuKien kind_PhuKien = db.Kind_PhuKiens.Find(id); if (kind_PhuKien == null) { return(HttpNotFound()); } return(View(kind_PhuKien)); }
public ActionResult LoaiPhukien(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Kind_PhuKien kind_PhuKien = db.Kind_PhuKiens.Find(id); if (kind_PhuKien == null) { return(HttpNotFound()); } ViewBag.Phukien = db.Kind_PhuKiens.Where(s => s.Id_Kind.Contains("K")); return(View(kind_PhuKien)); }
public ActionResult Edit(HttpPostedFileBase image, FormCollection form, string id) { string imageLink = "/Content/image/xamomi1.jpg"; if (image != null && image.ContentLength > 0) { imageLink = "/Content/image/" + image.FileName; string path = Path.Combine(Server.MapPath("~/Content/image/"), image.FileName); image.SaveAs(path); } Kind_PhuKien kind = db.Kind_PhuKiens.Find(id); kind.Id_Kind = form["Id_Kind"]; kind.Kind_Phukien_Image = form["Kind_Phukien_Image"]; kind.Kind_Phukien_Image = imageLink; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(FormCollection form, HttpPostedFileBase image) { string imageLink = "/Content/image/xamomi1.jpg"; if (image != null && image.ContentLength > 0) { imageLink = "/Content/image/" + image.FileName; string path = Path.Combine(Server.MapPath("~/Content/image/"), image.FileName); image.SaveAs(path); } var kind = new Kind_PhuKien() { Id_Kind = form["Id_Kind"], Kind_Name = form["Kind_Name"], Kind_Phukien_Image = imageLink }; db.Kind_PhuKiens.Add(kind); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: Kind_PhuKien/Create public ActionResult Create() { var kind_pk = new Kind_PhuKien(); return(View(kind_pk)); }