protected void Page_Load(object sender, EventArgs e) { if (Request["method"] != null) { //查询数据库的数据 RoleBll BLL = new RoleBll(); DataTable dt = BLL.GetAll(); DataSet set = new DataSet(); set.Tables.Add(dt); string json = JsonConvert.SerializeObject(set); //向客户端写回数据 Response.Clear(); Response.ContentType = "text/plain"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write(json); Response.End(); } if (Request["id"] != null) { RoleBll BLL = new RoleBll(); int rows = BLL.Del(Convert.ToInt32(Request["id"])); Response.Clear(); Response.ContentType = "text/plain"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write(rows); Response.End(); } }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <returns></returns> public StringBuilder DelRole(HttpContext context) { var menuPowerBll = new MenuPowerBll(); var roleBll = new RoleBll(); var userrolebll = new UseRolesBll(); var messageRespose = new MessageRespose(); var sb = new StringBuilder(); var roleId = context.Request.Params["nodeid"]; var role = new Role { RoleId = roleId }; var userrole = new UseRoles { RoleId = roleId }; var menuPowerDel = new MenuPower { PowerId = roleId }; try { if (roleId == "role_admin") { return(sb.Append(messageRespose.Success = "3")); } //联动删除 roleBll.Del(role); userrolebll.Del2(userrole); menuPowerBll.Del(menuPowerDel); //操作日志 if (null == context.Session[Constant.LoginUser]) { return(sb.Append(messageRespose.Success = "2")); } var oprlog = new OprLog { Operator = ((Employer)(context.Session[Constant.LoginUser])).Name, OperResult = "成功", OprSrc = "删除角色", LogDate = DateTime.Now }; _oprLogBll.Add(oprlog); return(sb.Append(messageRespose.Success = "删除成功!")); } catch (Exception e) { Log.Error("保存角色出错", e); throw; } }