public string DeleteRole(HttpContext context) { string status = "{\"status\":-1}"; int roleID = 0; if (int.TryParse(context.Request.Form["pid"], out roleID) && roleID > 0) { BCtrl_SysRole bllRole = new BCtrl_SysRole(); if (bllRole.IsCanDelRole(roleID)) { if (bllRole.Delete(roleID)) { ClearCacheOrSession.ClearRoleCacheByCRUD(); status = "{\"status\":1}"; } else { status = "{\"status\":0}"; } } else { status = "{\"status\":2}"; } } return(status); }
public string SetRole(HttpContext context) { string returnValue = "{\"state\":0}"; string userid = context.Request.Form["userid"]; int roleid = 0; int.TryParse(context.Request.Form["roleid"], out roleid); if (string.IsNullOrEmpty(userid) || roleid == 0) { returnValue = "{\"state\":-1}"; //传递参数不完整 } else { if (new BCtrl_SysUser().SetUserRole(userid, roleid)) { //如果用户被设置为超级管理员应该获得所有分类权限 if (roleid == 100) { if (GetFunToAdmin(userid)) { ClearCacheOrSession.ClearRoleCacheByCRUD(); returnValue = "{\"state\":1}"; } } else { if (new BCtrl_SysUser().SetUserFun(userid, roleid)) { ClearCacheOrSession.ClearRoleCacheByCRUD(); returnValue = "{\"state\":1}"; } } } } return(returnValue); }