public ActionResult AddDepartmentMethod() { try { //int parentID, string departmentName, int creatPersonID, ref string errMsg var parentIDStr = Request["parentID"]; ///部门父节点ID,没有则为0 var departmentName = Request["departmentName"]; //部门名称 string creatPersonIDsStr = Session["id"] == null ? "" : Session["id"].ToString(); int parentID = -1; int createPersonID = -1; if (int.TryParse(parentIDStr, out parentID) && int.TryParse(creatPersonIDsStr, out createPersonID)) { string errMsg = ""; if (EmployeeManage.AddDepartment(parentID, departmentName, createPersonID, ref errMsg)) { return(Content("ok")); } else { return(Content(errMsg)); } } else { return(Content("请输入正确的Int类型!")); } } catch (Exception ex) { return(Content(ex.Message)); } }