public ActionResult Edit(int id, sanpham sp) { //try //{ // // TODO: Add update logic here // return RedirectToAction("Index"); //} //catch //{ // return View(); //} if (HttpContext.Request.Files.Count > 0) { var hpf = HttpContext.Request.Files[0]; if (hpf.ContentLength > 0) { string fileName = Guid.NewGuid().ToString(); string fullPathWithFileName = "~/images/home/" + fileName + ".jpg"; hpf.SaveAs(Server.MapPath(fullPathWithFileName)); sp.HinhAnh = fileName + ".jpg"; } } QLsanphambus.EditSanPham(id, sp); return(RedirectToAction("Index")); }
// GET: Admin/QLSanPham public ActionResult Index(int page = 1) { //var ds = QLsanphambus.DanhSachSanPham(); //return View(ds); var dsSanPham = QLsanphambus.HienThiDanhSachSanPham(page, 7); return(View(dsSanPham)); }
public ActionResult Delete(int id, sanpham sp) { //try //{ // // TODO: Add delete logic here // return RedirectToAction("Index"); //} //catch //{ // return View(); //} QLsanphambus.DeleteSanPham(id, sp); return(RedirectToAction("Index")); }
public ActionResult Create(sanpham sp) { if (HttpContext.Request.Files.Count > 0) { var hpf = HttpContext.Request.Files[0]; if (hpf.ContentLength > 0) { string fileName = Guid.NewGuid().ToString(); string fullPathWithFileName = "~/images/home/" + fileName + ".jpg"; hpf.SaveAs(Server.MapPath(fullPathWithFileName)); sp.HinhAnh = fileName + ".jpg"; } } sp.SoLuongBan = 0; sp.SoLuongXem = 0; sp.BiXoa = 0; //sp.NgayNhap = DateTime.Now; QLsanphambus.ThemSanPham(sp); return(RedirectToAction("Index")); }
// GET: Admin/QLSanPham/Edit/5 public ActionResult Edit(int id) { ViewBag.MaNhaSanXuat = new SelectList(QLNhaSanXuatbus.HienThiDanhSachNSX(), "MaNhaSanXuat", "TenNhaSanXuat"); ViewBag.MaLoaiSanPham = new SelectList(QLloaisanphambus.HienThiLoaiSanPham(), "MaLoaiSanPham", "TenLoaiSanPham"); return(View(QLsanphambus.ChiTietSanPham(id))); }