// // GET: /Admin/AminProduct/Create public ActionResult Create() { ProductViewModels sp = new ProductViewModels(); sp.dsLoai1 = LoaiBus.DanhSach(); return(View(sp)); }
// GET: Admin/SanPham/Edit/5 public ActionResult Edit(int id) { var rs = SanPhamBus.ChiTiet(id); List <CustomDropDownList> BiXoa = new List <CustomDropDownList>() { new CustomDropDownList { Text = "Không Xóa", Value = 0 }, new CustomDropDownList { Text = "Xóa", Value = 1 } }; List <CustomDropDownList> TinhTrang = new List <CustomDropDownList>() { new CustomDropDownList { Text = "Còn Hàng", Value = 1 }, new CustomDropDownList { Text = "Hết Hàng", Value = 0 } }; ViewBag.TinhTrang = new SelectList(TinhTrang, "Value", "Text"); ViewBag.BiXoa = new SelectList(BiXoa, "Value", "Text"); ViewBag.MaHang = new SelectList(HangBus.DanhSach(), "MaHang", "TenHang", rs.MaHang); ViewBag.MaLoai = new SelectList(LoaiBus.DanhSach(), "MaLoai", "TenLoai", rs.MaLoai); return(View(rs)); }
// GET: Admin/SanPham/Create public ActionResult Create() { List <CustomDropDownList> BiXoa = new List <CustomDropDownList>() { new CustomDropDownList { Text = "Không Xóa", Value = 0 }, new CustomDropDownList { Text = "Xóa", Value = 1 } }; List <CustomDropDownList> TinhTrang = new List <CustomDropDownList>() { new CustomDropDownList { Text = "Còn Hàng", Value = 1 }, new CustomDropDownList { Text = "Hết Hàng", Value = 0 } }; ViewBag.TinhTrang = new SelectList(TinhTrang, "Value", "Text"); ViewBag.BiXoa = new SelectList(BiXoa, "Value", "Text"); ViewBag.MaHang = new SelectList(HangBus.DanhSach(), "MaHang", "TenHang"); ViewBag.MaLoai = new SelectList(LoaiBus.DanhSach(), "MaLoai", "TenLoai"); return(View()); }
public ActionResult Create(ProductViewModels sp) { try { var validImageTypes = new string[] { "image/gif", "image/jpeg", "image/pjpeg", "image/png" }; if (sp.ImageUpload == null || sp.ImageUpload.ContentLength == 0) { ModelState.AddModelError("ImageUpload", "Chưa chọn hình"); } else if (!validImageTypes.Contains(sp.ImageUpload.ContentType)) { ModelState.AddModelError("ImageUpload", "Làm ơn chọn file có định dạng hình GIF, JPG, PNG."); } if (ModelState.IsValid) { if (sp.ImageUpload != null && sp.ImageUpload.ContentLength > 0) { var uploadDir = "~/image/product"; var imagePath = Path.Combine(Server.MapPath(uploadDir), sp.ImageUpload.FileName); var imageUrl = Path.Combine(uploadDir, sp.ImageUpload.FileName); sp.ImageUpload.SaveAs(imagePath); sp.Hinh = sp.ImageUpload.FileName; } } sp.NgayDangSP = DateTime.Now; sp.LuotXem = 0; ProductBus.Them(sp); return(RedirectToAction("Index")); } catch (Exception ex) { ProductViewModels spham = new ProductViewModels(); spham.dsLoai1 = LoaiBus.DanhSach(); return(View(spham)); } }
// // GET: /Loai/ public ActionResult Index() { return(View(LoaiBus.DanhSach())); }