예제 #1
0
        public ActionResult Edit(int id)
        {
            var thucpham = new ThucphamDao().ViewDetail(id);

            SetViewBag(thucpham.ID_loaithucpham);
            return(View(thucpham));
        }
예제 #2
0
        //
        // 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));
        }
예제 #3
0
        public JsonResult ListName(string q)
        {
            var data = new ThucphamDao().ListName(q);

            return(Json(new
            {
                data = data,
                status = true
            }, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
 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"));
 }
예제 #5
0
        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"));
        }
예제 #6
0
        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));
        }
예제 #8
0
        public ActionResult Chitietthucpham(int id)
        {
            var model = new ThucphamDao().ViewDetail(id);

            return(View(model));
        }