private void LoadData() { List <SysMenu> menu_list = MenuBiz.GetAllMenus(); this.DataGridMenu.DataSource = menu_list; this.DataGridMenu.DataBind(); }
public async Task <IActionResult> AddMenuAsync([FromBody] AddMenuRequestDto request) { var menuBiz = new MenuBiz(); var entity = await menuBiz.GetByCodeAsync(request.MenuCode); if (entity != null) { return(Failed(ErrorCode.UserData, "code重复")); } var result = await menuBiz.InsertAsync(new MenuModel { CreatedBy = UserID, LastUpdatedBy = UserID, Enable = request.Enable, MenuGuid = Guid.NewGuid().ToString("N"), MenuName = request.MenuName, OrgGuid = string.Empty, Sort = request.Sort, MenuClass = request.MenuClass, MenuCode = request.MenuCode, MenuUrl = request.MenuUrl, ParentGuid = request.ParentGuid, }); if (!result) { return(Failed(ErrorCode.UserData, "修改失败")); } return(Success()); }
public async Task <IActionResult> UpdateMenuAsync([FromBody] UpdateMenuRequestDto request) { var menuBiz = new MenuBiz(); var entity = await menuBiz.GetAsync(request.MenuGuid); if (entity == null) { return(Failed(ErrorCode.UserData, "找不到数据")); } entity.LastUpdatedBy = UserID; entity.LastUpdatedDate = DateTime.Now; entity.MenuName = request.MenuName; entity.Sort = request.Sort; entity.Enable = request.Enable; entity.MenuClass = request.MenuClass; entity.MenuCode = request.MenuCode; entity.MenuUrl = request.MenuUrl; entity.ParentGuid = request.ParentGuid; var result = await menuBiz.UpdateAsync(entity); if (!result) { return(Failed(ErrorCode.UserData, "修改失败")); } return(Success()); }
private void DoUpdate(Control button) { Control _temp = button.NamingContainer; SysMenu entity = new SysMenu(); entity.MenuId = (_temp.FindControl("hidden_menu_id") as HtmlInputHidden).Value.Trim(); entity.MenuName = (_temp.FindControl("textbox_menu_name") as TextBox).Text; entity.ParentId = (_temp.FindControl("textbox_parent_id") as TextBox).Text; entity.IsValid = (_temp.FindControl("checkbox_is_valid") as CheckBox).Checked ? "Y" : "N"; entity.TypeId = int.Parse((_temp.FindControl("textbox_type_id") as TextBox).Text); entity.DisplayOrder = int.Parse((_temp.FindControl("textbox_display_order") as TextBox).Text); entity.Url = (_temp.FindControl("textbox_url") as TextBox).Text; entity.Description = (_temp.FindControl("textbox_description") as TextBox).Text; if (string.IsNullOrEmpty(entity.Description)) { entity.Description = entity.MenuName; } MenuBiz.UpdateMenu(entity); this.LoadData(); this.DataGridMenu.EditIndex = -1; this.DataGridMenu.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!UserUtils.isLogin()) { Response.Redirect(Constants.LINK_LOGIN); } //Page.Header.DataBind(); if (!Page.IsPostBack) { if (userLogin != null) { //Clear old Notification removeSession(); RoleEnum roleEnum = (RoleEnum)Enum.Parse(typeof(RoleEnum), userLogin.role_id.ToString()); menu_role menuRoleBiz = new menu_role(); MenuBiz menuBiz = new MenuBiz(); //Generate Navigator litNavigator.Text = menuBiz.getNavigator(Request.PhysicalPath); litMenu.Text = menuBiz.getMenuByRole(menuRoleBiz.getMenuByRole(userLogin.role_id), Request.PhysicalPath); litUserData.Text = String.Format("Login by :: {0} {1} ( {2} )", userLogin.first_name, userLogin.last_name, roleEnum.ToString()); //Generate Alert renderAlert(); } } }
protected void btnSave_Click(object sender, EventArgs e) { switch (CommandName) { case CommandNameEnum.Add: obj.Insert(); break; case CommandNameEnum.Edit: obj.Update(); break; } this.PKID = (this.PKID == 0) ? obj.GetMax() : this.PKID; MenuBiz menuBiz = new MenuBiz(); menu_role menuRoleBiz = new menu_role(); List <menu_role> _menuRoles = menuRoleBiz.getRoleListByRoleId(PKID); List <menu> menus = menuBiz.GetAll().Where(x => x.PREVIOUS_MENU_ID != null).OrderBy(x => x.DISPLAY_ORDER).ToList(); foreach (menu _menu in menus) { menu_role menuRole = _menuRoles.Where(x => x.MENU_ID == _menu.MENU_ID).FirstOrDefault(); if (menuRole != null) { menuRole.IS_CREATE = isChecked(menuRole, CommandNameEnum.Add); menuRole.IS_EDIT = isChecked(menuRole, CommandNameEnum.Edit); menuRole.IS_DELETE = isChecked(menuRole, CommandNameEnum.Delete); menuRole.RowState = CommandNameEnum.Edit; } else { menu_role _menuRole = new menu_role(); _menuRole.ROLE_ID = this.PKID; _menuRole.MENU_ID = Convert.ToInt32(_menu.MENU_ID); _menuRole.IS_REQUIRED_ACTION = false; _menuRole.IS_CREATE = false; _menuRole.IS_DELETE = false; _menuRole.IS_EDIT = false; _menuRole.UPDATE_BY = "SYSTEM"; _menuRole.CREATE_DATE = DateTime.Now; _menuRole.UPDATE_DATE = DateTime.Now; _menuRole.RowState = CommandNameEnum.Add; _menuRoles.Add(_menuRole); menu_role tmp_menuRole = _menuRoles.Where(x => x.MENU_ID == _menu.MENU_ID).FirstOrDefault(); tmp_menuRole.IS_CREATE = isChecked(tmp_menuRole, CommandNameEnum.Add); tmp_menuRole.IS_DELETE = isChecked(tmp_menuRole, CommandNameEnum.Edit); tmp_menuRole.IS_EDIT = isChecked(tmp_menuRole, CommandNameEnum.Delete); tmp_menuRole.RowState = CommandNameEnum.Add; } } foreach (menu_role _menuRole in _menuRoles.Where(x => x.IS_CREATE == (bool)false && x.IS_EDIT == (bool)false && x.IS_DELETE == (bool)false)) { _menuRole.RowState = CommandNameEnum.Delete; } menuRoleBiz.InsertList(_menuRoles); GeneralManager.Commit(); removeSession(); MessageBox.Show(this, Resources.MSG_SAVE_SUCCESS, PreviousPath); }
private void DoDelete(Control button) { Control _temp = button.NamingContainer; string menu_id = (_temp.FindControl("hidden_menu_id") as HtmlInputHidden).Value.Trim(); MenuBiz.DeleteMenu(menu_id); this.LoadData(); }
public async Task <IActionResult> DeleteMenuAsync([FromBody] DeleteRequestDto request) { var menuBiz = new MenuBiz(); var result = await menuBiz.DeleteAsync(request.Guid); if (!result) { return(Failed(ErrorCode.UserData, "删除失败")); } return(Success()); }
public async Task <IActionResult> GetLoginUserInfoAsync() { var account = await new ManagerAccountBiz().GetAsync(UserID); if (account == null) { return(Failed(ErrorCode.UserData, "找不到数据")); } var accessory = await new AccessoryBiz().GetAsync(account?.PortraitGuid); var response = account.ToDto <GetLoginUserInfoResponseDto>(); response.PortraitUrl = $"{accessory?.BasePath}{accessory?.RelativePath}"; response.Roles = (await new AccountRoleBiz().GetListAsync(UserID)).ToArray(); var roleRights = await new GrantRoleBiz().GetRoleRightAsync(response.Roles); //response.Menus = .Select(a => a.ToDto<MenuItemDto>()).ToArray(); var menuBiz = new MenuBiz(); IEnumerable <MenuModel> menus; if (account.IsSuper) { menus = await menuBiz.GetListAsync(); } else { menus = await menuBiz.GetByGuidsAsync(roleRights.ToArray()); } var buttonBiz = new ButtonBiz(); IEnumerable <ButtonModel> buttons; if (account.IsSuper) { buttons = await buttonBiz.GetListAsync(); } else { buttons = await buttonBiz.GetByGuidsAsync(roleRights.ToArray()); } menus = menus.OrderByDescending(a => a.Sort).ThenBy(a => a.CreatedBy); response.Menus = menus.GetTree(null, a => a.ParentGuid, a => a.MenuGuid, a => new MenuItemDto { MenuGuid = a.MenuGuid, MenuName = a.MenuName, Sort = a.Sort, MenuClass = a.MenuClass, MenuCode = a.MenuCode, MenuUrl = a.MenuUrl, ParentGuid = a.ParentGuid, Enable = a.Enable, Buttons = buttons.Where(s => s.MenuGuid == a.MenuGuid).Select(s => s.ButtonCode).ToArray() }); return(Success(response)); }
public ActionResult OrderCalendar(int id = 0) { ViewBag.Index = id; var model = new WeekOrderModel(); var date = DateTime.Today.AddDays(id * 7); var menuBiz = new MenuBiz(); var menus = menuBiz.GetWeekMenu(date); var orderBiz = new OrderBiz(); var orders = orderBiz.GetWeekOrders(date, User.Identity.ToString()); model.Menus = menus; model.Orders = orders; return(View("~/Views/Orders/WeekOrders.cshtml", model)); }
public ActionResult MenuCalendar([Bind(Include = "Id,Name,Index")] MenuModel menu) { ViewBag.Index = menu.Index; var menuBiz = new MenuBiz(); var menuDetails = new List <MenuDetail>(); for (int i = 0; i < 6; i++) { var foodId = int.Parse(this.Request.Params["food" + (i + 1)]); menuDetails.Add(new MenuDetail() { MenuId = menu.Id, FoodId = foodId }); } menuBiz.SaveMenu(menuDetails); return(RedirectToAction("MenuCalendar", new { id = menu.Index })); }
public ActionResult MenuCalendar(int id = 0) { ViewBag.Index = id; var model = new WeekMenuModel(); var date = DateTime.Today.AddDays(id * 7); var menuBiz = new MenuBiz(); var foodBiz = new FoodBiz(); var menus = menuBiz.GetWeekMenu(date); var primaryFoods = foodBiz.GetPrimaryFoods(); var secondaryFoods = foodBiz.GetSecondaryFoods(); model.Menus = menus; model.PrimaryFoods = primaryFoods; model.SecondaryFoods = secondaryFoods; return(View(model)); }
private void initialPage() { lbCommandName.Text = CommandName.ToString(); switch (CommandName) { case CommandNameEnum.Add: txtName.Enabled = true; btnSave.Enabled = true; btnCancel.Enabled = true; break; case CommandNameEnum.Edit: fillinScreen(); txtName.Enabled = true; btnSave.Enabled = true; btnCancel.Enabled = true; break; case CommandNameEnum.View: fillinScreen(); txtName.Enabled = false; btnSave.Enabled = false; btnCancel.Enabled = true; // break; } menu_role menuRoleBiz = new menu_role(); MenuBiz menuBiz = new MenuBiz(); List <menu_role> _menuRoles = menuRoleBiz.getRoleListByRoleId(PKID); menuBiz.getmenuByTree(ref this.tvPermission, _menuRoles); }
public async Task <IActionResult> DisableEnableMenuAsync([FromBody] DisableEnableRequestDto request) { var menuBiz = new MenuBiz(); var entity = await menuBiz.GetAsync(request.Guid); if (entity == null) { return(Failed(ErrorCode.UserData, "找不到数据")); } entity.LastUpdatedBy = UserID; entity.LastUpdatedDate = DateTime.Now; entity.Enable = request.Enable; var result = await menuBiz.UpdateAsync(entity); if (!result) { return(Failed(ErrorCode.UserData, "修改失败")); } return(Success()); }
private void BuildMenu() { TreeViewMenu.MarginBase = 5; TreeViewMenu.LevelIncrease = 10; List <SysMenu> sourceMenuList; BasePage base_page = this.Page as BasePage; if (base_page != null) { string emp_id = base_page.CurrentUser.UserId; sourceMenuList = HomePageBiz.GetMenuListByUser(emp_id); } else { sourceMenuList = MenuBiz.GetAllMenus(); } Trace.Write("count of menus: " + sourceMenuList.Count.ToString()); SystemMenuList systemMenus = new SystemMenuList(); foreach (SysMenu sourceMenu in sourceMenuList) { if (sourceMenu.IsValid.ToUpper() == "Y") { sourceMenu.Url = GetAbsoluteMenuUrl(sourceMenu.Url); systemMenus.Add(sourceMenu); } } systemMenus.SortByDisplayOrder(); List <string> selected_list = this.GetSelectedList(sourceMenuList); RenderMenu(MenuBiz.RootMenuID, systemMenus, TreeViewMenu, selected_list); }
public async Task <IActionResult> GetMenuTree2Async([FromBody] GetMenuListRequestDto request) { var menuBiz = new MenuBiz(); var entityList = await menuBiz.GetListAsync(); if (!string.IsNullOrWhiteSpace(request.Name)) { entityList = entityList.Where(a => a.MenuName.Contains(request.Name)); } entityList = entityList.OrderByDescending(a => a.Sort).ThenBy(a => a.CreatedBy); var buttonBiz = new ButtonBiz(); var buttonList = await buttonBiz.GetListAsync(enable : true); entityList = entityList.Union(buttonList.Select(a => new MenuModel { Enable = true, MenuGuid = a.ButtonGuid, MenuName = a.ButtonName, Sort = a.Sort, MenuClass = null, MenuCode = a.ButtonCode, MenuUrl = null, ParentGuid = a.MenuGuid, })); var response = entityList.GetTree(null, a => a.ParentGuid, a => a.MenuGuid, a => new GetMenuTreeDto { Enable = a.Enable, MenuGuid = a.MenuGuid, MenuName = a.MenuName, Sort = a.Sort, MenuClass = a.MenuClass, MenuCode = a.MenuCode, MenuUrl = a.MenuUrl, ParentGuid = a.ParentGuid, }); return(Success(response)); }
private void DoAddNew(Control button) { Control _temp = button.NamingContainer; SysMenu entity = new SysMenu(); entity.MenuId = (_temp.FindControl("textbox_menu_id") as TextBox).Text.Trim(); entity.MenuName = (_temp.FindControl("textbox_menu_name") as TextBox).Text; entity.ParentId = (_temp.FindControl("textbox_parent_id") as TextBox).Text; entity.IsValid = (_temp.FindControl("checkbox_is_valid") as CheckBox).Checked ? "Y" : "N"; entity.TypeId = int.Parse((_temp.FindControl("textbox_type_id") as TextBox).Text); entity.DisplayOrder = int.Parse((_temp.FindControl("textbox_display_order") as TextBox).Text); entity.Url = (_temp.FindControl("textbox_url") as TextBox).Text; entity.Description = (_temp.FindControl("textbox_description") as TextBox).Text; if (string.IsNullOrEmpty(entity.Description)) { entity.Description = entity.MenuName; } MenuBiz.InsertMenu(entity); this.LoadData(); }
protected void button_ok_Click(object sender, EventArgs e) { try { SysMenu menu = new SysMenu(); menu.MenuId = txt_menu_id.Text; menu.MenuName = txt_menu_name.Text; menu.ParentId = txt_parent_id.Text; menu.TypeId = int.Parse(txt_type_id.Text); menu.Url = txt_url.Text; menu.Description = txt_description.Text; menu.DisplayOrder = int.Parse(txt_display_order.Text); menu.IsValid = txt_is_valid.Text; MenuBiz.InsertMenu(menu); Response.Redirect("~/management/menumaintain.aspx"); } catch (Exception ex) { ScriptHelper.AjaxAlert(this.button_ok, ex.Message); } }