public string QueryEmp(HttpContext context) { var employeeBll = new EmployerBll(); string str; var jss = new JavaScriptSerializer(); var id = context.Request.Params["empid"]; var employee = new Employer() { Id = id }; try { var dt = employeeBll.Query(employee); var list = ConvertHelper <Employer> .ConvertToList(dt); str = jss.Serialize(list); str += "|"; } catch (Exception e) { Log.Error(e); str = "0|false"; return(str); } return(str); }
protected string GetDeptNode2() { var dt = _employerBll.GetTreeList(); var nodeStr = new StringBuilder(); //节点json字符串 if (dt.Rows.Count <= 0) // 没有数据退出 { return(string.Empty); } for (var i = 0; i < dt.Rows.Count; i++) { var nId = dt.Rows[i]["id"].ToString(); // 节点id var nName = dt.Rows[i]["name"].ToString(); // 节点名称 var pId = dt.Rows[i]["parentdept"].ToString(); // 上级节点id var department = new Department { Id = pId }; var employee = new Employer { Id = nId }; var pNameDt = _departmentBll.Query(department); var pName = pNameDt.Rows.Count <= 0 ? "" : pNameDt.Rows[0]["name"].ToString(); nodeStr.Append(","); var flag = nId.Substring(0, 1); switch (flag) { case "D": nodeStr.Append("{id:'" + nId + "',pId:'" + pId + "',pName:'" + pName + "' ,name:'" + nName + "',icon:'../../images/bumen.png',open:true }"); break; case "E": var pMailDt = _employerBll.Query(employee); var pMail = pMailDt.Rows.Count <= 0 ? "" : pMailDt.Rows[0]["email"].ToString(); nodeStr.Append("{id:'" + nId + "',pId:'" + pId + "',pName:'" + pName + "',pMail:'" + pMail + "' ,name:'" + nName + "',icon:'../../images/renyuan.png',open:true }"); break; } } return(nodeStr.ToString()); }