public ActionResult Edit(string id)
        {
            var dao   = new LoaiMatHangDao();
            var model = dao.GetByID(id);

            return(View(model));
        }
        // GET: Admin/LoaiMatHang
        public ActionResult Index()
        {
            var dao   = new LoaiMatHangDao();
            var model = dao.ListAll();

            return(View(model));
        }
        public ActionResult Delete(string id)
        {
            var dao   = new LoaiMatHangDao();
            var model = dao.GetByID(id);

            if (model != null)
            {
                dao.Delete(model);
            }
            return(RedirectToAction("Index"));
        }
 public ActionResult Create(LoaiMatHang entity)
 {
     if (ModelState.IsValid)
     {
         var dao = new LoaiMatHangDao();
         if (dao.Insert(entity))
         {
             SetAlert("Thêm thành công!", "success");
         }
         else
         {
             SetAlert("Lỗi thêm hàng hóa!", "error");
         }
     }
     else
     {
         SetAlert("Lỗi thêm hàng hóa!", "error");
     }
     return(View());
 }
 public ActionResult Edit(LoaiMatHang entity)
 {
     if (ModelState.IsValid)
     {
         var dao = new LoaiMatHangDao();
         if (dao.Update(entity))
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             SetAlert("Lỗi cập nhật chủng loại!", "error");
             return(View(entity));
         }
     }
     else
     {
         SetAlert("Lỗi cập nhật chủng loại!", "error");
         return(View(entity));
     }
 }
示例#6
0
        public void SetLoaiMH(string selectedId = null)
        {
            var dao = new LoaiMatHangDao();

            ViewBag.LoaiMH = new SelectList(dao.ListAll(), "ID", "Ten", selectedId);
        }