private void checkedListBoxControl1_ItemCheck(object sender, DevExpress.XtraEditors.Controls.ItemCheckEventArgs e) { CheckedListBoxItem currItem = (CheckedListBoxItem)checkedListBoxControl1.GetItem(e.Index); 职务等级 职务等级 = (职务等级)currItem.Value; string rolename = this.CurrentRole.Name; //如果选中 if (e.State == CheckState.Checked) { RoleLevel rLevel = RoleLevel.GetRoleLevel(rolename, CurrentCompany.公司编码, 职务等级.编码); if (rLevel == null) { rLevel = new RoleLevel(); rLevel.角色 = rolename; rLevel.公司编码 = CurrentCompany.公司编码; rLevel.职务等级 = 职务等级.编码; rLevel.Save(); } } //如果没有选中 if (e.State == CheckState.Unchecked) { RoleLevel rLevel = RoleLevel.GetRoleLevel(rolename, CurrentCompany.公司编码, 职务等级.编码); if (rLevel != null) { rLevel.Delete(); } } }
private void InitListBox() { if (this.CurrentRole != null) { if (checkedListBoxControl1.Items.Count == 0) { //初始化职务等级列表 职务等级 管培生, 副总经理以上; 管培生.编码 = "管培生"; 管培生.称 = "管培生"; 副总经理以上.编码 = "副总经理以上"; 副总经理以上.称 = "副总经理以上"; List <职务等级> lvlList = new List <职务等级>(); lvlList.Add(管培生); lvlList.Add(副总经理以上); foreach (DictionaryEntry entry in PsHelper.GetSupvLvls()) { 职务等级 lvl = new 职务等级 { 编码 = (string)entry.Value, 称 = (string)entry.Key }; lvlList.Add(lvl); } lvlList = lvlList.OrderBy(a => a.编码).ToList(); foreach (职务等级 lvl in lvlList) { CheckedListBoxItem item = new CheckedListBoxItem(lvl, false); checkedListBoxControl1.Items.Add(item); } } checkedListBoxControl1.BeginUpdate(); if (CurrentCompany != null) { List <RoleLevel> groups = RoleLevel.GetRoleLevels(this.CurrentRole.Name).FindAll(a => a.公司编码 == CurrentCompany.公司编码); foreach (CheckedListBoxItem item in checkedListBoxControl1.Items) { 职务等级 grade = (职务等级)item.Value; bool isChecked = groups.Find(a => a.职务等级 == grade.编码) != null; item.CheckState = isChecked ? CheckState.Checked : CheckState.Unchecked; } } checkedListBoxControl1.EndUpdate(); } }
private void Init() { //初始化公司列表 repositoryItemCompany.Items.Clear(); foreach (CompanyInfo c in CompanyInfo.GetAll()) { ImageComboBoxItem item = new ImageComboBoxItem(c.公司简称, c.公司编码); repositoryItemCompany.Items.Add(item); } //初始化职务等级列表 repositoryItemGrade.Items.Clear(); repositoryItemGrade.Items.Add(new ImageComboBoxItem("管培生", "管培生")); repositoryItemGrade.Items.Add(new ImageComboBoxItem("副总经理以上", "副总经理以上")); List <职务等级> lvlList = new List <职务等级>(); foreach (DictionaryEntry entry in PsHelper.GetSupvLvls()) { 职务等级 lvl = new 职务等级 { 编码 = (string)entry.Value, 称 = (string)entry.Key }; lvlList.Add(lvl); } lvlList = lvlList.OrderBy(a => a.编码).ToList(); foreach (职务等级 lvl in lvlList) { ImageComboBoxItem item = new ImageComboBoxItem(lvl.称, lvl.编码); repositoryItemGrade.Items.Add(item); } //初始化角色列表 List <Role> allRoles = Role.GetAll(); foreach (Role role in allRoles) { repositoryItemRole.Items.Add(role.Name); } //只显示当前薪等表里的权限,历史记录隐藏 impowerList.Clear(); foreach (RoleLevel rg in RoleLevel.GetAll()) { impowerList.Add(rg); } gridControl1.DataSource = impowerList; }
private void Init() { //初始化职务等级列表 repositoryItemImageComboBox.Items.Clear(); List <职务等级> lvlList = new List <职务等级>(); foreach (DictionaryEntry entry in PsHelper.GetSupvLvls()) { 职务等级 lvl = new 职务等级 { 编码 = (string)entry.Value, 称 = (string)entry.Key }; lvlList.Add(lvl); } lvlList = lvlList.OrderBy(a => a.编码).ToList(); foreach (职务等级 lvl in lvlList) { ImageComboBoxItem item = new ImageComboBoxItem(lvl.称, lvl.编码); repositoryItemImageComboBox.Items.Add(item); } LoadData(); }