/// <summary> /// 根据角色生成菜单 /// </summary> /// <param name="roleID"></param> /// <returns></returns> public static MenuStrip InitMenu(string roleID, System.Windows.Forms.Form mainForm) { parentForm = mainForm; //清空已打开的窗口 for (int i = 0; i < parentForm.MdiChildren.Length; i++) { parentForm.MdiChildren[i].Close(); } PrivilegeService _proxy = new PrivilegeService(); using (_proxy as IDisposable) { menuCollection = _proxy.QueryByTypeRoleId("MenuRes", roleID); } foreach (Control _ctl in parentForm.Controls) { if (_ctl.GetType() == typeof(MenuStrip)) { parentForm.Controls.Remove(_ctl); } } return(AddRootMenu()); }
private void cmbType_SelectedValueChanged(object sender, EventArgs e) { currentResourceList.Clear(); this.cbResource.SelectedIndexChanged -= new System.EventHandler(this.cbResource_SelectedIndexChanged); if (cmbType.SelectedValue == null) { return; } if (currentRole.ParentId == "roleadmin" || currentRole.ID == "roleadmin") { currentResourceList = new ResourceProcess().QueryByTypeParentId(pageJudge, cmbType.SelectedValue.ToString()); } else { PrivilegeService _proxy = Common.Util.CreateProxy(); using (_proxy as IDisposable) { IList <RoleResourceMapping> newRoleResourcelist = _proxy.QueryByTypeRoleId(pageJudge, currentRole.ParentId); foreach (RoleResourceMapping newRoleResource in newRoleResourcelist) { if (newRoleResource.Resource != null && newRoleResource.Resource.Id != null) { bool Judge = true; if (currentResourceList.Count == 0) { currentResourceList.Add(newRoleResource.Resource); } else { foreach (Neusoft.HISFC.BizLogic.Privilege.Model.Resource newRes in currentResourceList) { if (newRoleResource.Resource.Id == newRes.Id || newRes.ParentId != cmbType.SelectedValue.ToString()) { Judge = false; break; } } if (Judge) { currentResourceList.Add(newRoleResource.Resource); } } } } } } cbResource.DataSource = currentResourceList; cbResource.ValueMember = "Id"; cbResource.SelectedIndex = -1; this.cbResource.SelectedIndexChanged += new System.EventHandler(this.cbResource_SelectedIndexChanged); tbTypeName.Text = string.Empty; tbControl.Text = string.Empty; tbControlDll.Text = string.Empty; }
private void LoadTreeListView() { List <String> orgTypeList = new List <string>(); PrivilegeService _proxy = Common.Util.CreateProxy(); using (_proxy as IDisposable) { IList <String> keys = null; keys = _proxy.QueryAppID(); if (keys != null) { foreach (string key in keys) { List <String> orgType = _proxy.GetOrgType(key); if (orgType != null) { foreach (String orgtypeone in orgType) { orgTypeList.Add(orgtypeone); } } } } //orgTypeList = _proxy.GetOrgType("HIS"); currentRoleResourcList = _proxy.QueryByTypeRoleId(pageJudge, currentRole.Id); } foreach (string orgType in orgTypeList) { string[] orgTypeArray = orgType.Split('|'); TreeListViewItem item = new TreeListViewItem(); item.Text = orgTypeArray[1].ToString(); item.Name = orgTypeArray[0].ToString(); item.Tag = orgTypeArray; item.ImageIndex = 0; item.SubItems.AddRange(new string[] { orgTypeArray[0], orgTypeArray[2] == "isDepTrue" ? "ÊÇ" : "·ñ" }); nTreeListView1.Items.Add(item); } if (currentRoleResourcList != null || currentRoleResourcList.Count != 0) { for (int item = 0; item < nTreeListView1.ItemsCount; item++) { foreach (RoleResourceMapping roleRes in currentRoleResourcList) { if (nTreeListView1.Items[item].Name == roleRes.Resource.Id) { nTreeListView1.Items[item].Checked = true; } } } } }
private void LoadRoleResource() { nTreeListView1.Items.Clear(); PrivilegeService _proxy = Common.Util.CreateProxy(); using (_proxy as IDisposable) { if (currentRole != null) { currentRoleResourcList = _proxy.QueryByTypeRoleId(pageJudge, currentRole.ID); } } TreeListViewItem rootNode = null; if (pageJudge == MenuPageJudge) { rootNode = new TreeListViewItem("授权的菜单:", 0); } if (pageJudge == WebPageJudge) { rootNode = new TreeListViewItem("授权Web菜单:", 6); } if (pageJudge == UserPageJudge) { rootNode = new TreeListViewItem("授权的用户:", 0); } if (pageJudge == DictionaryPageJudge) { rootNode = new TreeListViewItem("授权的常数:", 3); } if (pageJudge == ReportPageJudge) { rootNode = new TreeListViewItem("授权的报表:", 0); } currentRoleResource = new RoleResourceMapping(); currentRoleResource.ParentId = "root"; currentRoleResource.Id = "root"; currentRoleResource.OrderNumber = 0; currentRoleResource.ValidState = "1"; rootNode.Tag = currentRoleResource; nTreeListView1.Items.Add(rootNode); if (currentRoleResourcList == null || currentRoleResourcList.Count == 0) { return; } ConstructTreeNode(rootNode, currentRoleResourcList); nTreeListView1.ExpandAll(); }
private void InitComboBox() { InitCmbType(); InitCmbImage(); if (currentRole.ParentId == "roleadmin" || currentRole.ID == "roleadmin") { PrivilegeService _proxy = Common.Util.CreateProxy(); using (_proxy as IDisposable) { currentResourceList = _proxy.QueryResourcesByType(pageJudge); } } else { currentResourceList = new List <Neusoft.HISFC.BizLogic.Privilege.Model.Resource>(); PrivilegeService _proxy = Common.Util.CreateProxy(); using (_proxy as IDisposable) { IList <RoleResourceMapping> newRoleResourcelist = _proxy.QueryByTypeRoleId(pageJudge, currentRole.ParentId); foreach (RoleResourceMapping newRoleResource in newRoleResourcelist) { if (newRoleResource.Resource != null && newRoleResource.Resource.Id != null) { bool Judge = true; if (currentResourceList.Count == 0) { currentResourceList.Add(newRoleResource.Resource); } else { foreach (Neusoft.HISFC.BizLogic.Privilege.Model.Resource newRes in currentResourceList) { if (newRoleResource.Resource.Id == newRes.Id) { Judge = false; break; } } if (Judge) { currentResourceList.Add(newRoleResource.Resource); } } } } } } if (currentResourceList.Count != 0) { FiltrateList(); } cbResource.DataSource = currentResourceList; cbResource.ValueMember = "Id"; cbResource.SelectedIndex = -1; if (pageUpdate == JudgeOperate) { if (controlRoleResource.Resource.Id != null) { cbResource.SelectedValue = controlRoleResource.Resource.Id; } } }