public void Updatetb_Sys_RolesBtn(tb_Sys_RolesBtn tb_Sys_RolesBtn) { var existstb_Sys_Menu = this.Gettb_Sys_RolesBtnById(tb_Sys_RolesBtn.Id); this.tb_Sys_RolesBtnRepository.SetValues(tb_Sys_RolesBtn, existstb_Sys_Menu); this.runtimeService.Commit(); }
/// <summary> /// 删除按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { tb_Sys_Roles role = GvRoles.GetFocusedRow() as tb_Sys_Roles; if (gridviewAction.SelectedRowsCount >= 0) { Guid?menuId = this.treeMenu.FocusedNode.GetValue(treeListColumn1).ToString().ToGuidOrNull(); if (menuId != null) { tb_Sys_Button action = gridviewAction.GetFocusedRow() as tb_Sys_Button; if (action != null) { tb_Sys_RolesBtn roleBtn = rolesBtnService.GetByMenuId(role.Id, menuId ?? new Guid(), action.Id);//ServiceHelper.Current.DbSession.Itb_Sys_RoleActionDAL.GetListBy(m => m.RoleID == role.RoleID && m.MoudelID == module.ModuleID && m.ActionID == action.ActionID).FirstOrDefault(); if (roleBtn != null) { rolesBtnService.Deletetb_Sys_RolesBtn(roleBtn.Id); this.gridviewAction.DeleteSelectedRows(); XtraMessageBox.Show("删除成功"); } } } } }
//保存 private void btnSave_Click(object sender, EventArgs e) { //保存菜单 if (toolCommand == "AddMenu") { //roleRightService.DeleteRolesId(sys_roleid); foreach (TreeListNode node in treeList1.Nodes) { Guid menuId = node.GetValue(treeListColumn1).ToString().ToGuid(); //获取PermissionID if (node.CheckState == CheckState.Checked && !listmenuID.Contains(menuId)) { tb_Sys_Menu module = menuService.Gettb_Sys_MenuById(menuId);//ServiceHelper.Current.DbSession.Itb_Sys_ModuleDAL.GetListBy(m => m.ModuleID == moduleId).FirstOrDefault(); tb_Sys_RolesRight rolesRight = new tb_Sys_RolesRight { Roles_Id = sys_roleid, Menu_Id = module.Id }; roleRightService.Createtb_Sys_RolesRight(rolesRight); } else if (node.CheckState != CheckState.Checked && listmenuID.Contains(menuId)) { roleRightService.GetByMenuIdAndRolesId(sys_roleid, menuId); } SaveTreeList(node); } } else if (toolCommand == "AddAction")//保存按钮 { foreach (TreeListNode node in treeList1.Nodes) { if (node.CheckState == CheckState.Checked) { // tb_Sys_Roles role = role//ServiceHelper.Current.DbSession.Itb_Sys_RoleDAL.GetListBy(r => r.RoleID == sys_roleid).FirstOrDefault(); Guid btnId = node.GetValue(treeListColumn1).ToString().ToGuid(); //获取PermissionID tb_Sys_RolesBtn roleAction = new tb_Sys_RolesBtn { Roles_Id = sys_roleid, Menu_Id = sys_moduleId, Btn_Id = btnId }; rolesBtnService.Createtb_Sys_RolesBtn(roleAction); } } } else if (toolCommand == "AddUser") { foreach (TreeListNode node in treeList1.Nodes) { if (node.CheckState == CheckState.Checked) { Guid userId = node.GetValue(treeListColumn1).ToString().ToGuid(); //获取PermissionID tb_Sys_UserRole roleuser = new tb_Sys_UserRole { RoleId = sys_roleid, UserId = userId }; //int row = ServiceHelper.Current.DbSession.Itb_Sys_UserRoleDAL.Add(roleuser); userRoleService.Createtb_Sys_UserRole(roleuser); } } } else if (toolCommand == "AddControl") { foreach (TreeListNode node in treeList1.Nodes) { if (node.CheckState == CheckState.Checked) { Guid controlID = node.GetValue(treeListColumn1).ToString().ToGuid(); //获取ControlID tb_Sys_RolesControl rolecontrol = new tb_Sys_RolesControl { Roles_Id = sys_roleid, ControlId = controlID }; //int row = ServiceHelper.Current.DbSession.Itb_Sys_UserRoleDAL.Add(roleuser); roleControlService.Create(rolecontrol); } } } MessageBox.Show("保存成功"); DialogResult = System.Windows.Forms.DialogResult.OK; }
public void Createtb_Sys_RolesBtn(tb_Sys_RolesBtn tb_Sys_RolesBtn) { this.tb_Sys_RolesBtnRepository.Add(tb_Sys_RolesBtn); this.runtimeService.Commit(); }