void EditRole(string moduleActionId, int roleId) { Role role = new Role(roleId, txtRoleName.Text.Trim(), txtRoleDesc.Text.Trim(), string.Empty, 1, DateTime.Now, Profile.AccountInfo.UserID, DateTime.Now, Profile.AccountInfo.UserID); try { RoleOpts added = PermissionManager.EditRole(role, moduleActionId); switch (added) { case RoleOpts.Exist: mbMessage.ShowMsg("此角色名已存在,请勿重复使用!", Color.Red); break; case RoleOpts.Failed: mbMessage.ShowMsg("修改角色信息失败,信息无法入库!", Color.Red); break; case RoleOpts.Success: mbMessage.ShowMsg("修改角色成功,可继续修改角色信息,若完成请返回!", Color.Navy); BindData(roleId); break; default: break; } } catch (Exception ex) { throw new HHException(ExceptionType.Failed, "修改用户角色时发生了错误,请联系管理员!(" + ex.Message + ")"); } }
/// <summary> /// 修改用户角色 /// </summary> /// <param name="role"></param> /// <param name="moduleActionId"></param> /// <returns></returns> public static RoleOpts EditRole(Role role, string moduleActionId) { RoleOpts result = PermissionDataProvider.Instance.EditRole(role, moduleActionId); if (result == RoleOpts.Success) { HHCache.Instance.Remove(_AllRolesCacheKey); } return(result); }
/// <summary> /// 删除角色 /// </summary> /// <param name="roleID"></param> /// <returns></returns> public static RoleOpts DeleteRole(int roleID) { RoleOpts result = PermissionDataProvider.Instance.DeleteRole(roleID); if (result == RoleOpts.Success) { HHCache.Instance.Remove(_AllRolesCacheKey); } return(result); }
public void egvRoles_RowDeleting(object sender, GridViewDeleteEventArgs e) { int roleId = (int)egvRoles.DataKeys[e.RowIndex].Value; RoleOpts result = PermissionManager.DeleteRole(roleId); switch (result) { case RoleOpts.Exist: throw new HHException(ExceptionType.Failed, "此角色下存在关联用户,无法直接删除(请先删除此角色下关联用户)!"); case RoleOpts.Failed: throw new HHException(ExceptionType.Failed, "删除角色时失败,请确认此角色存在,并状态正常!"); case RoleOpts.Success: BindRoles(); break; } }