public IActionResult SaveItem(string Id = null, int IdCoQuan = 1) { MenusModel data = new MenusModel(); string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); int IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString()); data.SearchData = new SearchMenus() { CurrentPage = 0, ItemsPerPage = 10, Keyword = "", IdCoQuan = IdCoQuan }; data.ListItemsArticle = ArticlesService.GetListStaticArticle(); data.ListType = MenusService.GetListType(); data.ListCategoriesArticles = CategoriesArticlesService.GetList(); data.ListCategoriesProducts = ProductsCategoriesService.GetList(); data.ListItemsMenus = MenusService.GetListItems(true, IdCoQuan); if (IdDC == 0) { data.Item = new Menus(); } else { data.Item = MenusService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName); } return(View(data)); }
public ActionResult SaveItem(MenusModel model) { string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); int IdDC = Int32.Parse(MyModels.Decode(model.Item.Ids, API.Models.Settings.SecretId + ControllerName).ToString()); MenusModel data = model; if (ModelState.IsValid) { if (model.Item.Id == IdDC) { model.Item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]); MenusService.SaveItem(model.Item); if (model.Item.Id > 0) { TempData["MessageSuccess"] = "Cập nhật thành công"; } else { TempData["MessageSuccess"] = "Thêm mới thành công"; } return(RedirectToAction("Index", new { IdCoQuan = model.Item.IdCoQuan })); } } data.ListType = MenusService.GetListType(); return(View(data)); }
public ActionResult UpdateStatus([FromQuery] string Ids, Boolean Status) { string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); Menus item = new Menus() { Id = Int32.Parse(MyModels.Decode(Ids, API.Models.Settings.SecretId + ControllerName).ToString()), Status = Status }; try { if (item.Id > 0) { item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]); dynamic UpdateStatus = MenusService.UpdateStatus(item); TempData["MessageSuccess"] = "Cập nhật Trạng Thái thành công"; return(Json(new MsgSuccess())); } else { TempData["MessageError"] = "Cập nhật Trạng Thái Không thành công"; return(Json(new MsgError())); } } catch { TempData["MessageSuccess"] = "Cập nhật Trạng Thái không thành công"; return(Json(new MsgError())); } }
public IHttpActionResult GetByWhere(MenusDto menusDto) { var service = new MenusService(); if (!string.IsNullOrEmpty(menusDto.ResNum) || !string.IsNullOrEmpty(menusDto.ResName)) { var menusList = service.GetByWhere(menusDto.ResNum, menusDto.ResName); var result = new { list = menusList.Select(item => new { ID = item.ID, ResNum = item.ResNum, ResName = item.ResName, ParentNum = item.ParentNum, ResType = item.ResType, CssName = item.CssName, Sort = item.Sort, Url = item.Url, CreateTime = item.CreateTime.ToString("yyyy-MM-dd,hh:mm:ss"), }) }; return(Json(result)); } else { return(GetMenusList()); } }
public ActionResult DeleteItem(string Id) { string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); Menus model = new Menus() { Id = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString()) }; try { if (model.Id > 0) { model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]); MenusService.DeleteItem(model); TempData["MessageSuccess"] = "Xóa thành công"; return(Json(new MsgSuccess())); } else { TempData["MessageError"] = "Xóa Không thành công"; return(Json(new MsgError())); } } catch { TempData["MessageSuccess"] = "Xóa không thành công"; return(Json(new MsgError())); } }
public IHttpActionResult EditMenus(SysResource sysResource) { var service = new MenusService(); var editMenus = service.EditMenus(sysResource); var result = new { Count = editMenus ? "修改成功" : "修改失败" }; return(Json(result)); }
public IHttpActionResult DeleteMeuns(int ID) { var service = new MenusService(); var delMeuns = service.DeleteMenus(ID); var result = new { Count = delMeuns ? "删除成功" : "删除失败" }; return(Json(result)); }
protected void Page_Load(object sender, EventArgs e) { if (Session["adminInfo"] == null) { Response.Redirect("/MyAdmin/AdminLogin.aspx"); } else if (((Worker)Session["adminInfo"]).wtype == "8 ") { MenusService menuService = new MenusService(); //管理员菜单列表 menuList = menuService.GetModelList("mstatus=" + 8); } else { MenusService menuService = new MenusService(); //员工菜单列表 menuList = menuService.GetModelList("mstatus=" + 0); } }
public IActionResult Index([FromQuery] SearchMenus dto) { int TotalItems = 0; string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); MenusModel data = new MenusModel() { SearchData = dto }; data.ListItems = MenusService.GetListPagination(data.SearchData, API.Models.Settings.SecretId + ControllerName); data.ListDMCoQuan = DMCoQuanService.GetListByLoaiCoQuan(0, 1); if (data.ListItems != null && data.ListItems.Count() > 0) { TotalItems = data.ListItems[0].TotalRows; } data.Pagination = new Models.Partial.PartialPagination() { CurrentPage = data.SearchData.CurrentPage, ItemsPerPage = data.SearchData.ItemsPerPage, TotalItems = TotalItems, QueryString = Request.QueryString.ToString() }; return(View(data)); }
public IHttpActionResult AddMenus(SysResource sysResource) { var menus = new MenusService(); var maxMenusNum = menus.GetAll().Select(item => item.ResNum).LastOrDefault(); int maxNum = int.Parse(maxMenusNum); maxNum++; sysResource.ResNum = maxNum.ToString().PadLeft(6, '0'); sysResource.Depth = 0; sysResource.ChildCount = 0; sysResource.IsHide = 1; sysResource.IsDelete = 0; sysResource.Depart = 0; sysResource.CreateTime = DateTime.Now; sysResource.UpdateTime = DateTime.Now; var addMenus = menus.Add(sysResource); var result = new { Count = addMenus ? "添加成功" : "添加失败" }; return(Json(result)); }
public IHttpActionResult GetMenusList() { var menusService = new MenusService(); var menusList = menusService.GetAll().OrderByDescending(item => item.UpdateTime).Where(item => item.IsDelete != 1).OrderByDescending(item => item.CreateTime); var result = new { list = menusList.Select(item => new { ID = item.ID, ResNum = item.ResNum, ResName = item.ResName, ParentNum = item.ParentNum, ResType = item.ResType, CssName = item.CssName, Sort = item.Sort, Url = item.Url, CreateTime = item.CreateTime.ToString("yyyy-MM-dd,hh:mm:ss") }) }; return(Json(result)); }
public MenusService_Test() { this.service = new MenusService(new MaharajasDbContext()); }
private void BuildMenu() { this.barManager_0.ForceLinkCreate(); BarManager manager = null; bool flag = false; BarSubItem item = new BarSubItem(); MenusService menusSer = new MenusService(); TList <Menus> lstMainMenu = menusSer.GetAll(); foreach (Menus menu in lstMainMenu) { if (menu.Subitem == 1 && menu.Skip == true) { item = new BarSubItem(manager, menu.Prompt.Trim()); item.Name = menu.Menukey.Trim(); this.menuBar.AddItem(item); continue; } if (menu.Menukey.Trim() == "/-") { flag = true; continue; } if (menu.Subitem == 2 && menu.Skip == true) { BarSubItem item2 = new BarSubItem(manager, menu.Prompt.ToString()); item2.Tag = menu.Id.ToString(); item2.Enabled = menu.Skip == null ? false : menu.Skip.Value; item2.ImageIndex = menu.Imageidx == null ? -1 : menu.Imageidx.Value; item.AddItem(item2); TList <Menus> lstSubMenu = menusSer.Find("parent=" + int.Parse(item2.Tag.ToString())); foreach (Menus submenu in lstSubMenu) { if (submenu.Menukey.Trim() == "/-") { flag = true; } else { BarButtonItem item3 = new BarButtonItem(manager, submenu.Prompt, submenu.Imageidx.Value); item3.Tag = submenu.Menukey.Trim(); item3.Enabled = submenu.Skip.Value; BarItemLink link = item2.AddItem(item3); if (flag) { link.BeginGroup = true; flag = false; } } } continue; } if ((menu.Subitem == 0) && (menu.Menukey.Trim() != "/-") && menu.Skip == true) { BarButtonItem item4 = new BarButtonItem(manager, menu.Prompt, menu.Imageidx.Value); item4.Tag = menu.Menukey.Trim(); item4.Enabled = menu.Skip.Value; BarItemLink link2 = item.AddItem(item4); if (!flag) { continue; } link2.BeginGroup = true; flag = false; } } }