protected void Page_Load(object sender, EventArgs e) { if (Request["roleName"] != null) { //拿到前台的值 string roleName = Request["roleName"]; string roleRemark = Request["roleRemark"]; int roleSortId = Convert.ToInt32(Request["roleSortId"]); //插入到数据库里 RoleModel role = new RoleModel(); role.Name = roleName; role.Remark = roleRemark; role.SortId = roleSortId; role.UpdateTime = DateTime.Now; role.IsDel = 0; RoleBll BLL = new RoleBll(); int rows = -1; rows = BLL.Add(role); //返回执行结果 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 SaveRole(HttpContext context) { var roleBll = new RoleBll(); var messageRespose = new MessageRespose(); var sb = new StringBuilder(); var roleid = Guid.NewGuid().ToString(); var rolename = context.Request.Params["jsmc"]; var roledesc = context.Request.Params["bz"]; var role = new Role { RoleId = roleid, RoleName = rolename, RoleDesc = roledesc, CreateDT = DateTime.Now }; try { roleBll.Add(role); //操作日志 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; } }
protected override CommandResult AddItem(object item) { return(bll.Add((Role)item)); }