/// <summary> /// 获取指定应用程序下指定菜单的子菜单最大序号 /// </summary> /// <param name="app">应用程序</param> /// <param name="parentMenu">父菜单</param> /// <returns>子菜单最大序号</returns> public int GetMaxOrderByApplicationAndParentMenu(SystemApplication app, SystemMenu parentMenu) { DetachedCriteria menuCriteria = DetachedCriteria.For(typeof(SystemMenu)); if (app == null) menuCriteria.Add(SystemMenuDao.PROPERTY_APPLICATIONID.IsNull()); else menuCriteria.Add(SystemMenuDao.PROPERTY_APPLICATIONID.Eq(app)); if (parentMenu == null) menuCriteria.Add(SystemMenuDao.PROPERTY_PARENTMENUID.IsNull()); else menuCriteria.Add(SystemMenuDao.PROPERTY_PARENTMENUID.Eq(parentMenu)); menuCriteria.SetProjection(SystemMenuDao.PROPERTY_MENUORDER.Max()); ISession session = this.DoGetSession(false); object result = menuCriteria.GetExecutableCriteria(session).SetMaxResults(1).UniqueResult(); if (result == null) return 0; else return (int)result; }
public ActionResult CreateOrUpdate(SystemMenu systemMenu) { systemMenu.Initialize(); var rsp = this.PermissionService.CreateOrUpdate(systemMenu); return rsp.IsSuccess ? this.CloseDialogWithAlert("保存成功!") : this.Alert("保存失败,失败详情:" + rsp.ErrorMessage); }
/// <summary> /// 获取制定菜单下的子菜单 /// </summary> /// <param name="parentMenu">父菜单</param> /// <returns>子菜单</returns> public List<SystemMenu> GetSubMenu(SystemMenu parentMenu) { DetachedCriteria menuCriteria = DetachedCriteria.For(typeof(SystemMenu)); if (parentMenu == null) menuCriteria.Add(SystemMenuDao.PROPERTY_PARENTMENUID.IsNull()); else menuCriteria.Add(SystemMenuDao.PROPERTY_PARENTMENUID.Eq(parentMenu)); menuCriteria.AddOrder(SystemMenuDao.PROPERTY_MENUORDER.Asc()); return this.FindListByDetachedCriteriaQuery(menuCriteria); }
/// <summary> /// 添加或者编辑系统菜单信息。 /// </summary> /// <param name="systemMenu">系统菜单信息</param> /// <returns>服务执行结果</returns> public Response CreateOrUpdate(SystemMenu systemMenu) { return this.InvokeService( nameof(CreateOrUpdate), () => { this.Persistence.Create(PermissionNamespace, "CreateOrUpdate", systemMenu); this.ClearCache<SystemMenu>(); }, systemMenu); }
public static SystemMenu GetSystemMenu(string menuCode) { SystemMenu item = new SystemMenu(); DataTable dt = SystemDAL.BaseProvider.GetSystemMenu(menuCode); if (dt.Rows.Count > 0) { item.FillData(dt.Rows[0]); if (!string.IsNullOrEmpty(item.PCode)) item.PCodeName = GetSystemMenu(item.PCode).Name; } return item; }
/// <summary> /// 默认构造函数 /// </summary> public SystemMenuBase() { _menu_id = 0; _menu_name = String.Empty; _menu_description = String.Empty; _menu_url = String.Empty; _menu_urltarget = String.Empty; _menu_iscategory = false; _parentmenu_id = null; _menu_order = 0; _menu_type = String.Empty; _menu_issystemmenu = false; _menu_isenable = false; _applicationid = null; }
private void Window_SourceInitialized(object sender, EventArgs e) { IntPtr windowHandle = (new WindowInteropHelper(this)).Handle; HwndSource src = HwndSource.FromHwnd(windowHandle); src.AddHook(new HwndSourceHook(WndProc)); try { m_SystemMenu = SystemMenu.FromWPFForm(this); m_SystemMenu.AppendSeparator(); m_SystemMenu.AppendMenu(m_UrlID, "Copy Current URL"); } catch (NoSystemMenuException) { } }
public static List<SystemMenu> GetSystemMenus() { List<SystemMenu> list = new List<SystemMenu>(); DataTable dt = SystemDAL.BaseProvider.GetSystemMenus(); SystemMenu model; foreach (DataRow item in dt.Rows) { model = new SystemMenu(); model.FillData(item); if (!string.IsNullOrEmpty(model.PCode)) model.PCodeName = GetSystemMenu(model.PCode).Name; list.Add(model); } return list; }
public virtual void ReSortedSubmenu(SystemMenu parentMenu) { List<SystemMenu> allSubSystemMenus = SelfDao.GetSubMenu(parentMenu); for (int i = 0; i < allSubSystemMenus.Count; i++) { allSubSystemMenus[i].MenuOrder = i + 1; SelfDao.Update(allSubSystemMenus[i]); } return; }
private void DeleteSubMenu(SystemMenu parentMenu) { List<SystemMenu> subMenus = SelfDao.GetSubMenu(parentMenu); foreach (SystemMenu menu in subMenus) { DeleteSubMenu(menu); } SelfDao.Delete(parentMenu); }
public override void Delete(SystemMenu instance) { if (instance == null) return; //递归循环删除所有的子菜单。 DeleteSubMenu(instance); }
public override void Create(SystemMenu obj) { //顶级菜单默认为菜单组 if (obj.ParentMenuID == null) { obj.MenuUrl = ""; obj.MenuIsCategory = true; } else { obj.MenuIsCategory = false; } //获取一个最大序号 obj.MenuOrder = SelfDao.GetMaxOrderByApplicationAndParentMenu(obj.ApplicationID, obj.ParentMenuID) + 1; base.Create(obj); }
/// <summary> /// Event handler for the forms' load event, it wires up our system menu items. Doing /// these in the constructor breaks CenterWindow. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InstallFormBase_Load(object sender, System.EventArgs e) { systemMenu = new SystemMenu(this); SystemMenuItem item = new SystemMenuItem("-", systemMenu); systemMenu.Add(item); item = new SystemMenuItem("&About", systemMenu); item.Click += new EventHandler(OnAbout); systemMenu.Add(item); }
/// <summary> /// 获取当前菜单同一级别的前一个菜单(如果之前没有菜单返回null) /// </summary> /// <param name="systemMenu">当前菜单</param> /// <returns>前一个菜单</returns> public SystemMenu FindPreMenu(SystemMenu systemMenu) { if (systemMenu == null) throw new ArgumentNullException("systemMenu", "systemMenu not allow null."); DetachedCriteria menuCriteria = DetachedCriteria.For(typeof(SystemMenu)); //同一子菜单下 if (systemMenu.ParentMenuID == null) menuCriteria.Add(SystemMenuDao.PROPERTY_PARENTMENUID.IsNull()); else menuCriteria.Add(SystemMenuDao.PROPERTY_PARENTMENUID.Eq(systemMenu.ParentMenuID)); //Order小于当前菜单 menuCriteria.Add(SystemMenuDao.PROPERTY_MENUORDER.Lt(systemMenu.MenuOrder)); //最大序号的菜单 menuCriteria.AddOrder(SystemMenuDao.PROPERTY_MENUORDER.Desc()); List<SystemMenu> listMenu = this.FindListByDetachedCriteriaQuery(menuCriteria); if (listMenu.Count <= 0) return null; else return listMenu[0]; }
public SystemMenuItem(string text, SystemMenu SM) { base.Text = text; menu = SM; if(text == "-") this.flags = SystemMenu.SEPERATOR; }
/// <summary> /// 默认构造函数 /// </summary> public SystemRoleMenuRelationBase() { _menurole_id = 0; _menu_id = null; _role_id = null; }
public static void SetMenuItem(HandleRef hMenu, SystemMenu menu, bool isEnabled) { EnableMenuItem(hMenu, menu, (isEnabled) ? ~1 : 1); }
private static extern bool EnableMenuItem(HandleRef handleMenu, SystemMenu idEnabledItem, int enable);
public virtual void MovePostion(SystemMenu systemMenu, int movePostion) { int currentOrder = 0; switch (movePostion) { case 0: return; case 1: SystemMenu preSystemMenu = SelfDao.FindPreMenu(systemMenu); if (preSystemMenu == null) return; currentOrder = systemMenu.MenuOrder; systemMenu.MenuOrder = preSystemMenu.MenuOrder; preSystemMenu.MenuOrder = currentOrder; SelfDao.Update(systemMenu); SelfDao.Update(preSystemMenu); break; case -1: SystemMenu nextSystemMenu = SelfDao.FindNextMenu(systemMenu); if (nextSystemMenu == null) return; currentOrder = systemMenu.MenuOrder; systemMenu.MenuOrder = nextSystemMenu.MenuOrder; nextSystemMenu.MenuOrder = currentOrder; SelfDao.Update(systemMenu); SelfDao.Update(nextSystemMenu); break; default: throw new NotImplementedException(" movePostion must be 1 or -1 now"); } return; }
public static bool UpdateSystemMenu(SystemMenu systemMenu) { return SystemDAL.BaseProvider.UpdateSystemMenu(systemMenu.MenuCode, systemMenu.Name, systemMenu.Controller, systemMenu.View, systemMenu.Sort); }
public static bool AddSystemMenu(SystemMenu systemMenu) { return SystemDAL.BaseProvider.AddSystemMenu(systemMenu.MenuCode, systemMenu.Name, systemMenu.Controller, systemMenu.View, systemMenu.PCode, systemMenu.Sort, systemMenu.Layer, systemMenu.Type); }
public List<SystemMenu> GetSubMenu(SystemMenu menu) { return this.SelfDao.GetSubMenu(menu); }
private static extern bool EnableMenuItem(HandleRef hMenu, SystemMenu UIDEnabledItem, int uEnable);