Ejemplo n.º 1
0
        public ActionResult Create(NhomSanPham collection)
        {
            var session = (UserSession)Session[CommonConstant.USER_SESSION];

            collection.CreateBy   = session.UserName;
            collection.CreateDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                var  dao = new NhomsanphamDao();
                long id  = dao.Insert(collection);
                if (id > 0)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", CommonConstant.INSERT_FAIL);
                }
            }
            else
            {
                ModelState.AddModelError("", CommonConstant.INSERT_FAIL);
            }
            return(View("Index"));
        }
Ejemplo n.º 2
0
        public ActionResult Index(string searchKey, int page = 1, int pagesize = 10)
        {
            var nhomsp = new NhomsanphamDao();

            if (!string.IsNullOrEmpty(searchKey))
            {
                var lst = nhomsp.SearchResult(searchKey, page, pagesize);
                return(View(lst));
            }
            else
            {
                var model = nhomsp.ListAll(page, pagesize);
                return(View(model));
            }
        }
Ejemplo n.º 3
0
 public ActionResult Edit(NhomSanPham cate)
 {
     if (ModelState.IsValid)
     {
         var dao = new NhomsanphamDao();
         var res = dao.Update(cate);
         if (res)
         {
             return(RedirectToAction("Index", "NhomSanPham"));
         }
         else
         {
             ModelState.AddModelError("", CommonConstant.UPDATE_FAIL);
         }
     }
     return(View("Index"));
 }
Ejemplo n.º 4
0
        // GET: admin/NhomSanPham/Edit/5
        public ActionResult Edit(int id)
        {
            var cate = new NhomsanphamDao().ViewDetail(id);

            return(View(cate));
        }