public ActionResult Edit(int id) { var thucpham = new ThucphamDao().ViewDetail(id); SetViewBag(thucpham.ID_loaithucpham); return(View(thucpham)); }
// // GET: /Admin/Thucpham/ public ActionResult Index(string searchString, int page = 1, int pageSize = 10) { var dao = new ThucphamDao(); var model = dao.ListAllPaing(searchString, page, pageSize); ViewBag.SearchString = searchString; return(View(model)); }
public JsonResult ListName(string q) { var data = new ThucphamDao().ListName(q); return(Json(new { data = data, status = true }, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(Thucpham thucpham) { if (ModelState.IsValid) { var dao = new ThucphamDao(); thucpham.MetaTitle = VietNamChar.ReplaceUnicode(thucpham.Ten_thucpham); var result = dao.Update(thucpham); if (result) { return(RedirectToAction("Index", "Thucpham")); } else { ModelState.AddModelError("", "Cập nhật không thành công"); } } return(View("Index")); }
public ActionResult Create(Thucpham thucpham) // Tạo tài khoản { if (ModelState.IsValid) { var dao = new ThucphamDao(); thucpham.MetaTitle = VietNamChar.ReplaceUnicode(thucpham.Ten_thucpham); long id = dao.Insert(thucpham); if (id > 0) { return(RedirectToAction("Index", "Thucpham")); } else { ModelState.AddModelError("", "Thêm không thành công"); } } return(View("Index")); }
public ActionResult Search(string keyword, int page = 1, int pageSize = 5) { int totalRecord = 0; var model = new ThucphamDao().Search(keyword, ref totalRecord, page, pageSize); ViewBag.Total = totalRecord; ViewBag.Page = page; ViewBag.Keyword = keyword; int maxPage = 5; int totalPage = 0; totalPage = (int)Math.Ceiling((double)(totalRecord / pageSize)); ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = page + 1; ViewBag.Prev = page - 1; return(View(model)); }
// // GET: /ThucphamRan/ public ActionResult Index() { var model = new ThucphamDao().GetRandom(); return(View(model)); }
public ActionResult Chitietthucpham(int id) { var model = new ThucphamDao().ViewDetail(id); return(View(model)); }