/// <summary> /// 获取角色列表为ZTree /// </summary> static public Object GetDepartmentInfoListForZTree() { #region 开始 string result = string.Empty; try { int channelId = DNTRequest.GetInt("channelId", 7); int ParentId = DNTRequest.GetInt("ParentId", 0); DepartmentInfoBLL op = new DepartmentInfoBLL(); DepartmentInfo model = new DepartmentInfo(); DataSet ds = op.GetList(" RecordIsDelete=0 "); DataTable dt = null; if (ds != null && ds.Tables.Count > 0) { dt = ds.Tables[0]; } List <Hashtable> list = new List <Hashtable>(); if (dt != null && dt.Rows.Count > 0) { DataRow[] allList = dt.Select(string.Format("ParentId={0}", ParentId), "DepartmentID ASC"); if (allList.Length > 0) { foreach (DataRow dr in allList) { bool isParent = false; DataRow[] allChild = dt.Select(string.Format("ParentId={0}", dr["DepartmentID"]), "DepartmentID ASC"); if (allChild != null && allChild.Length > 0) { isParent = true; } #region inner001 string className = ComPage.SafeToString(dr["DepartmentName"]); Hashtable ht = new Hashtable(); ht.Add("id", dr["DepartmentID"]); ht.Add("name", className); ht.Add("pId", dr["ParentId"]); ht.Add("open", true); if (isParent) { GetDepartmentInfoChild(list, allChild, dt); } list.Add(ht); #endregion } } } result = DNTRequest.GetResultJson(true, "success", list); } catch (Exception ex) { result = DNTRequest.GetResultJson(false, ex.Message, null); ExceptionLogBLL.WriteExceptionLogToDB(ex.ToString()); } return(result); #endregion end 开始 }
public void VerifySonDepartment(HttpContext context) { var DepartmentID = context.Request.QueryString["DepartmentID"]; DepartmentInfoBLL bll = new DepartmentInfoBLL(); DataSet ds = new DataSet(); int b = 0; if (!string.IsNullOrEmpty(DepartmentID)) { ds = bll.GetList(" ParentId=" + DepartmentID + " and RecordIsDelete=0"); if (ds.Tables[0].Rows.Count > 0) { b = ds.Tables[0].Rows[0]["DepartmentID"].ToInt(); } } context.Response.Write(b); }
/// <summary> /// 获取部门列表 /// </summary> static public Object GetDepartmentList() { string result = string.Empty; try { string sEcho = JsonRequest.GetJsonKeyVal(jsonText, "sEcho"); int displayStart = ComPage.SafeToInt(JsonRequest.GetJsonKeyVal(jsonText, "iDisplayStart")); int displayLength = ComPage.SafeToInt(JsonRequest.GetJsonKeyVal(jsonText, "iDisplayLength")); int pageIndex = (displayStart / displayLength) + 1; int pageSize = displayLength; #region 获取列表 StringBuilder where = new StringBuilder(); where.Append("1=1 and r.RecordIsDelete=0"); #region 条件搜索 string key = DNTRequest.GetString("searchKey"); if (string.IsNullOrEmpty(key)) { key = JsonRequest.GetJsonKeyVal(jsonText, "searchKey"); } string val = DNTRequest.GetString("searchValue"); if (string.IsNullOrEmpty(val)) { val = JsonRequest.GetJsonKeyVal(jsonText, "searchValue"); val = System.Web.HttpContext.Current.Server.UrlDecode(val); } if (!string.IsNullOrEmpty(val) && val != "undefined") { where.AppendFormat(" and (r.DepartmentName like '{0}%')", val); } #endregion string iSortCol_0 = JsonRequest.GetJsonKeyVal(jsonText, "iSortCol_0"); string sSortDir_0 = JsonRequest.GetJsonKeyVal(jsonText, "sSortDir_0"); int iSortingCols = ComPage.SafeToInt(JsonRequest.GetJsonKeyVal(jsonText, "iSortingCols")); string orderBy = string.Empty; if (!string.IsNullOrEmpty(iSortCol_0)) { string orderField = JsonRequest.GetJsonKeyVal(jsonText, string.Format("mDataProp_{0}", iSortCol_0)); orderBy = string.Format(" {0} {1}", orderField, sSortDir_0); } string sql = ""; int zys = 0; int sumcount = 0; DepartmentInfoBLL rolebll = new DepartmentInfoBLL(); DataTable dt = rolebll.GetList(where.ToString(), pageIndex, pageSize, orderBy, ref sql, ref zys, ref sumcount); /* * iTotalRecord = sumcount, * iTotalDisplayRecords = sumcount, */ object obj = new { result = true, code = "", msg = "", recordsTotal = sumcount, recordsFiltered = sumcount, data = ((dt == null) ? (new DataTable()) : (dt)), sEcho = sEcho, }; result = Newtonsoft.Json.JsonConvert.SerializeObject(obj); #endregion } catch (Exception ex) { result = DNTRequest.GetResultJson(false, "操作异常,请稍候再试", null); ExceptionLogBLL.WriteExceptionLogToDB(ex.ToString()); } return(result); }