public void SetMenuType(int itemselectedID = 1)
        {
            MenuTypeDAO menuTypeDAO  = new MenuTypeDAO();
            var         ListMenuType = menuTypeDAO.SelectAll();

            ViewBag.ListMenuType = new SelectList(ListMenuType, "MenuTypeID", "Name", itemselectedID);
        }
Beispiel #2
0
        public ActionResult XoaMenuType(int ID)
        {
            var result = new MenuTypeDAO().Delete(ID);

            SetAlert("Xóa thông tin thành công", "success");
            return(RedirectToAction("IndexMenutype", "Menu"));
        }
Beispiel #3
0
        public JsonResult CreateMenuType(string strMenuType)
        {
            var dao = new MenuTypeDAO();
            JavaScriptSerializer js   = new JavaScriptSerializer();
            MenuType             menu = js.Deserialize <MenuType>(strMenuType);
            bool   status             = false;
            string message            = string.Empty;

            if (dao.Check_Name(menu.Name) == false)
            {
                dao.Insert(menu);
                message = "Thêm loại menu " + menu.Name + " thành công";
                status  = true;
            }
            else
            {
                status  = false;
                message = "Tên loại menu " + menu.Name + " đã tồn tại";
            }
            return(Json(new
            {
                status = status,
                message = message
            }));
        }
Beispiel #4
0
        public ActionResult IndexMenuType(string searchString, int page = 1, int pagesize = 10)
        {
            var dao          = new MenuTypeDAO();
            var listmenutype = dao.ListAll(searchString, page, pagesize);

            return(View(listmenutype));
        }
        // GET: Admin/MenuType
        public ActionResult Index()
        {
            var dao   = new MenuTypeDAO();
            var model = dao.listMenuType();

            return(View(model));
        }
 public ActionResult CreateMenuType(MenuType model)
 {
     if (ModelState.IsValid)
     {
         var dao = new MenuTypeDAO();
         //Kiểm tra xem tên Menu này dã có chưa
         bool exist = dao.MenuTypeExist(model.Name);
         if (!exist)
         {
             bool result = dao.CreateMenuType(model);
             if (result)
             {
                 SetAltert("Tạo MenuType thành công", 0);
                 return(RedirectToAction("Index", "MenuType"));
             }
             else
             {
                 SetAltert("Chưa tạo MenuType được", 1);
             }
         }
         else
         {
             SetAltert("MenuType này đã có", 2);
         }
     }
     return(View(model));
 }
        public ActionResult UpdateMenuType(int id)
        {
            var dao   = new MenuTypeDAO();
            var model = dao.menuTypeDetail(id);

            return(View(model));
        }
        public ActionResult Remove(int menutypeID)
        {
            MenuTypeDAO menuTypeDAO = new MenuTypeDAO();

            menuTypeDAO.Remove(menutypeID);
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(int id)
        {
            MenuTypeDAO menuTypeDAO = new MenuTypeDAO();
            var         menuType    = menuTypeDAO.GetMenuType(id);

            return(View(menuType));
        }
        // GET: Admin/MenuType
        public ActionResult Index(string searchString, int page = 1, int pagesize = 10)
        {
            var dao   = new MenuTypeDAO();
            var model = dao.ListAllPage(searchString, page, pagesize);

            ViewBag.SearchString = searchString;
            return(View(model));
        }
        public JsonResult ChangeStatus(long id)
        {
            var result = new MenuTypeDAO().ChangeStatus(id);

            return(Json(new {
                status = result
            }));
        }
Beispiel #12
0
        public ActionResult Delete(MenuType entity)
        {
            long id = new MenuTypeDAO().Delete(entity);

            if (id > 0)
            {
                SetAlert("Xóa bản ghi thành công", "success");
                return(RedirectToAction("Index", "MenuType"));//Action: Index, Controller: User neu OK
            }
            else
            {
                ModelState.AddModelError("", "Xóa không thành công !");
            }

            return(View("Index"));
        }
        // GET: Admin/MenuType
        public ActionResult Index(string searchString = "", int page = 1, int pagesize = 2)
        {
            ViewBag.searchString = searchString;
            MenuTypeDAO menuTypeDAO = new MenuTypeDAO();

            if (searchString == "")
            {
                var list = menuTypeDAO.SelectAll().ToPagedList(page, pagesize);
                return(View(list));
            }
            else
            {
                var list = menuTypeDAO.SelectWithCondition(searchString).ToPagedList(page, pagesize);
                return(View(list));
            }
        }
 public ActionResult Edit(MenuType menutype)
 {
     if (ModelState.IsValid)
     {
         var  dao    = new MenuTypeDAO();
         bool result = dao.Update(menutype);
         if (result)
         {
             SetAlert("Cập nhật mới thành công", "success");
             return(RedirectToAction("Index", "MenuType"));
         }
         else
         {
             ModelState.AddModelError("", "Xảy ra lỗi");
         }
     }
     return(View("Index"));
 }
 public ActionResult Edit(MenuType menuType)
 {
     if (ModelState.IsValid)
     {
         MenuTypeDAO menuTypeDAO = new MenuTypeDAO();
         var         check       = menuTypeDAO.Edit(menuType);
         if (check > 0)
         {
             TempData["msg"] = MessageBox.Show("Edit Thành Công");
             return(RedirectToAction("Index", "MenuType"));
         }
         else
         {
             ModelState.AddModelError("", "Edit Thành Công");
         }
     }
     return(View());
 }
Beispiel #16
0
        public ActionResult ThemMoiMenuType(MenuType entity)
        {
            if (ModelState.IsValid)
            {
                var dao = new MenuTypeDAO();

                long id = dao.Insert(entity);
                if (id > 0)
                {
                    SetAlert("Thêm loại menu thành công", "success");
                    return(RedirectToAction("IndexMenutype", "Menu"));
                }
                else
                {
                    SetAlert("Thêm menu không thành công", "error");
                    return(RedirectToAction("ThemMoiMenuType", "Menu"));
                }
            }
            return(View("IndexMenutype"));
        }
        public ActionResult Create(MenuType model)
        {
            if (ModelState.IsValid)
            {
                var dao = new MenuTypeDAO();
                var id  = dao.Insert(model);
                if (id > 0)
                {
                    SetAlert("Thêm mới thành công", "success");
                    return(RedirectToAction("Index", "MenuType"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm mới không thành công ! ");
                }
            }


            return(View());
        }
Beispiel #18
0
        public ActionResult CapNhatMenuType(MenuType entity)
        {
            if (ModelState.IsValid)
            {
                var dao    = new MenuTypeDAO();
                var result = dao.Update(entity);
                if (result)
                {
                    SetAlert("Cập nhật loại menu thành công", "success");
                    return(RedirectToAction("IndexMenuType", "Menu"));
                }
                else
                {
                    SetAlert("Cập nhật menu không thành công", "error");
                    return(RedirectToAction("CapNhatMenuType", "Menu"));
                }
            }

            return(View("IndexMenutype"));
        }
Beispiel #19
0
        public ActionResult Edit(MenuType entity)
        {
            bool kiemtra = new MenuTypeDAO().KiemTraMenuTypeTonTai(entity);

            if (kiemtra == true)
            {
                SetAlert("Đã tồn tại trong hệ thống !", "success");
            }
            else
            {
                long id = new MenuTypeDAO().Edit(entity);
                if (id > 0)
                {
                    SetAlert("Cập nhật thành công", "success");
                    return(RedirectToAction("Edit", "MenuType"));//Action: Index, Controller: User neu OK
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật không thành công !");
                }
            }
            return(View("Edit"));
        }
        public ActionResult UpdateMenuType(MenuType entity)
        {
            var  dao    = new MenuTypeDAO();
            bool exists = dao.MenuTypeExistforUpdate(entity.Name, entity.ID);

            if (!exists)
            {
                bool result = dao.UpdateMenuType(entity);
                if (result)
                {
                    SetAltert("Cập nhật MenuType thành công", 0);
                    return(RedirectToAction("Index", "MenuType"));
                }
                else
                {
                    SetAltert("Cập nhật không thành công", 1);
                }
            }
            else
            {
                SetAltert("MenuType đã có", 2);
            }
            return(View(entity));
        }
Beispiel #21
0
        //Delete
        public ActionResult Delete(long id)
        {
            var entity = new MenuTypeDAO().ViewDetail(id);

            return(View(entity));
        }
Beispiel #22
0
 public MenuController()
 {
     menuTypeDAO = new MenuTypeDAO(db);
     menuDAO     = new MenuDAO(db);
 }
Beispiel #23
0
        public void ListMenuType(long?selectedID = null)
        {
            var dao = new MenuTypeDAO();

            ViewBag.TypeID = new SelectList(dao.BindDropDown(), "ID", "Name", selectedID);
        }
Beispiel #24
0
        public void DropdownMenuType(int?menutypeID = null)
        {
            var dao = new MenuTypeDAO();

            ViewBag.MenuTypeList = new SelectList(dao.List(), "ID", "Name", menutypeID);
        }
Beispiel #25
0
        //Phương thức này để khởi tạo cho Dropdownlist TypeID trong View CreateMenu
        public void SetViewBag(long?selectedID = null)
        {
            var dao = new MenuTypeDAO();

            ViewBag.TypeID = new SelectList(dao.listMenuType(), "id", "Name", selectedID);
        }
Beispiel #26
0
        public ActionResult CapNhatMenuType(int ID)
        {
            var model = new MenuTypeDAO().GetByID(ID);

            return(View(model));
        }
Beispiel #27
0
        // GET: Admin/Menu
        public ActionResult Index()
        {
            var model = new MenuTypeDAO().ListAll();

            return(View(model));
        }
        public ActionResult Edit(long id)
        {
            var menutype = new MenuTypeDAO().GetID(id);

            return(View(menutype));
        }