private void ResetState(T_Role role, DrisionDbContext context) { if (role.Role_Status == 1) { if (role.T_Users.Count > 0 || RoleFunctionManager.GetInstance().GetFunctions(role.Role_ID).Count > 0) { this.AjaxAlert("此角色已使用,不能停用!"); return; } role.Role_Status = 0; context.SaveChanges(); BingRoleToDataGridview(); this.AjaxAlert("停用角色成功!"); return; } else if (role.Role_Status == 0) { role.Role_Status = 1; context.SaveChanges(); BingRoleToDataGridview(); this.AjaxAlert("启用角色成功!"); return; } }
private void DeleteUser(T_Role role, DrisionDbContext context) { if (role.T_Users.Count > 0 || RoleFunctionManager.GetInstance().GetFunctions(role.Role_ID).Count > 0) { this.AjaxAlert("此角色已使用,不能删除!"); return; } context.T_Role.Remove(role); context.SaveChanges(); BingRoleToDataGridview(); if (lblEdit.Text.Trim() == role.Role_ID.ToString()) { ClearControl(); } this.AjaxAlert("删除角色成功!"); }