示例#1
0
        public JsonResult Delete(int id)
        {
            var isUsed = new MenuTypeDao().CheckMenuIsUsed(id);

            if (!isUsed)
            {
                var res = new MenuTypeDao().Delete(id);
                if (res)
                {
                    return(Json(new
                    {
                        status = true
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        status = false
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new
                {
                    status = false,
                    message = "Có menu đang dùng. Vui lòng kiểm tra lại"
                }, JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
        public JsonResult LoadData(int type, string keyword, int pageIndex, int pageSize)
        {
            string str   = NonUnicode.RemoveUnicode(keyword).ToLower();
            var    model = new MenuTypeDao().ListAll();

            switch (type)
            {
            case 0: model = model.Where(x => NonUnicode.RemoveUnicode(x.Name.ToLower()).Contains(str)); break;
            }

            int totalRow = model.Count();

            model = model.OrderByDescending(x => x.ID)
                    .Skip((pageIndex - 1) * pageSize)
                    .Take(pageSize);
            int totalRowCurent = model.Count();

            return(Json(new
            {
                data = model,
                total = totalRow,
                totalCurent = totalRowCurent,
                status = true
            }, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public ActionResult Edit(MenuType collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // TODO: Add insert logic here

                    MenuTypeDao bdDao = new MenuTypeDao();
                    UserLogin   us    = (UserLogin)Session[SystemConsts.USER_SESSION];
                    //  collection.CreatedBy = us.UserName;
                    // collection.CreatedDate = Hepper.GetDateServer();
                    collection.ModifiedBy   = us.UserName;
                    collection.ModifiedDate = Hepper.GetDateServer();

                    if (bdDao.Update(collection))
                    {
                        SetAlert("Thêm thành công", "success");
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        SetAlert("Không thêm được", "danger");
                    }
                }
                return(View());
            }
            catch
            {
                SetAlert("Không thêm được", "danger");
                return(View());
            }
        }
示例#4
0
        public JsonResult GetDetail(int id)
        {
            var model = new MenuTypeDao().GetByID(id);

            return(Json(new
            {
                data = model,
                status = true
            }, JsonRequestBehavior.AllowGet));
        }
示例#5
0
        public JsonResult SaveData(string strMenuType)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            MenuType             menuType   = serializer.Deserialize <MenuType>(strMenuType);
            bool   status  = false;
            string action  = string.Empty;
            string message = string.Empty;
            bool   res     = new MenuTypeDao().CheckIDExist(menuType.ID);

            if (res)
            {
                var model = new MenuTypeDao();
                try
                {
                    model.Insert(menuType);
                    status = true;
                    action = "insert";
                }
                catch (Exception ex)
                {
                    status  = false;
                    message = ex.Message;
                }
            }
            else
            {
                //update existing DB
                //save db
                try
                {
                    var model = new MenuTypeDao().Update(menuType);
                    status = true;
                    action = "update";
                }
                catch (Exception ex)
                {
                    status  = false;
                    message = ex.Message;
                }
            }

            return(Json(new
            {
                status = status,
                message = message,
                action = action
            }));
        }
示例#6
0
        // GET: Admin/Menu/Edit/5
        public ActionResult Edit(long id)
        {
            MenuDao     dbMenu     = new MenuDao();
            MenuTypeDao dbMenuType = new MenuTypeDao();
            Menu        menu       = null;

            try
            {
                menu = dbMenu.FindByID(id);
                var items = GetClientMenuViewModel();
                ViewBag.ParentID = new SelectList(items, "ID", "Text", menu.ParentID);
                ViewBag.GroupID  = new SelectList(dbMenuType.ToList(), "ID", "Name");
            }
            catch
            {
                ModelState.AddModelError("", Resources.ResourceAdmin.ErrorGetRecordMessage);
            }
            return(View(menu));
        }
示例#7
0
        public ActionResult Create(MenuType collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // TODO: Add insert logic here

                    MenuTypeDao bdDao = new MenuTypeDao();
                    if (bdDao.FindByID(collection.ID) == null)
                    {
                        UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION];
                        collection.CreatedBy    = us.UserName;
                        collection.CreatedDate  = Hepper.GetDateServer();
                        collection.ModifiedBy   = us.UserName;
                        collection.ModifiedDate = Hepper.GetDateServer();
                        //collection.CreateBy = us.UserName;
                        //collection.ModifiedBy = us.UserName;
                        if (bdDao.Insert(collection))
                        {
                            SetAlert("Thêm thành công", "success");
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            SetAlert("Không thêm được", "danger");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Mã nhóm menu đã tồn tại");
                    }
                }
                return(View());
            }
            catch
            {
                SetAlert("Không thêm được", "danger");
                return(View());
            }
        }
示例#8
0
        public ActionResult Delete(string id)
        {
            try
            {
                // TODO: Add delete logic here

                MenuTypeDao bdDao = new MenuTypeDao();
                MenuDao     mnDao = new MenuDao();
                if (mnDao.FindByMenuType(id).Count > 0)
                {
                    SetAlert("Đang sử dụng không được phép xóa", SystemConsts.ALERT_DANGER);
                    return(RedirectToAction("Index"));
                }
                bdDao.Delete(id);
                // SetAlert("Xóa thành công", "success");
                return(RedirectToAction("Index"));
            }
            catch
            {
                // SetAlert("Không xóa được", "danger");
                return(View());
            }
        }
示例#9
0
        public ActionResult Edit(Menu collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // TODO: Add insert logic here

                    MenuDao   bdDao = new MenuDao();
                    UserLogin us    = (UserLogin)Session[SystemConsts.USER_SESSION];

                    collection.UpdatedBy   = us.UserName;
                    collection.UpdatedDate = Hepper.GetDateServer();
                    MenuDao     dbMenu     = new MenuDao();
                    MenuTypeDao dbMenuType = new MenuTypeDao();
                    var         items      = GetClientMenuViewModel();
                    ViewBag.ParentID = new SelectList(items, "ID", "Text");
                    ViewBag.GroupID  = new SelectList(dbMenuType.ToList(), "ID", "Name");
                    if (bdDao.Update(collection))
                    {
                        SetAlert("Thêm thành công", "success");
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        SetAlert("Không cập nhật được", "danger");
                    }
                }
                return(View());
            }
            catch
            {
                SetAlert("Không thêm được", "danger");
                return(View());
            }
        }
示例#10
0
        // GET: Admin/MenuType/Edit/5
        public ActionResult Edit(string id)
        {
            MenuTypeDao bdDao = new MenuTypeDao();

            return(View(bdDao.FindByID(id)));
        }
示例#11
0
        // GET: Admin/MenuType
        public ActionResult Index()
        {
            MenuTypeDao bdDao = new MenuTypeDao();

            return(View(bdDao.ToList()));
        }
示例#12
0
        private void PopulateGroupIDDropDownList(object selectedParent = null)
        {
            MenuTypeDao dbDao = new MenuTypeDao();

            ViewBag.Groups = new SelectList(dbDao.ToList(), "ID", "Name", selectedParent);
        }
示例#13
0
 /// <summary>
 ///
 /// </summary>
 public MenuTypeBll()
 {
     _menuTypeDao = new MenuTypeDao();
 }
示例#14
0
        // GET: Admin/MenuTypes
        public ActionResult Index()
        {
            var model = new MenuTypeDao().ListAll();

            return(View(model));
        }
示例#15
0
        public void SetDropdownList(string selectedId = null)
        {
            var dao = new MenuTypeDao();

            ViewBag.MenuTypeID = new SelectList(dao.ListAll(), "ID", "Name", selectedId);
        }