/// <summary> /// 获取所有数据列表 /// 作者:小朱 /// </summary> /// <returns>将DataTable转换为Json数据格式通过string类型返回</returns> public DataTable GetList(E_PageParameter ePageParameter) { DataTable dt = new DataTable(); int total = 0; string strWhere = GetWhere(ePageParameter); //dt = tTestReport.GetListByPage(strWhere, "UpdateTime DESC,T.SampleName ASC", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize, ref total).Tables[0]; int startindex = ePageParameter.pageindex * ePageParameter.pagesize + 1; int endindex = (ePageParameter.pageindex + 1) * ePageParameter.pagesize; dt = tTestReport.GetListByPage(strWhere, "TestTime DESC", startindex, endindex, ref total).Tables[0]; if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { string ApprovalPersonnelName = dt.Rows[i]["ApprovalPersonnelName"].ToString(); string RecordIDS = dt.Rows[i]["RecordIDS"].ToString(); StringBuilder strRecordIDS = new StringBuilder(); if (!string.IsNullOrEmpty(RecordIDS)) { string[] ArrRecordIDS = RecordIDS.Split(','); foreach (string item in ArrRecordIDS) { if (!string.IsNullOrEmpty(item)) { strRecordIDS.Append(string.Format("<a href='/OriginalRecord/OriginalRecordList?RecordID={0}&ApprovalPersonnelName={1}' style='color:Blue; font-weight:bold;'>{0}</a>,", item, ApprovalPersonnelName)); } } } dt.Rows[i]["RecordIDS"] = strRecordIDS.ToString().TrimEnd(','); string TaskNoS = dt.Rows[i]["TaskNoS"].ToString(); StringBuilder strTaskNoS = new StringBuilder(); if (!string.IsNullOrEmpty(TaskNoS)) { string[] ArrTaskNoS = TaskNoS.Split(','); foreach (string item in ArrTaskNoS) { if (!string.IsNullOrEmpty(item)) { strTaskNoS.Append(string.Format("<a href='/ExpePlan/ExpePlanList?PlanID={0}&ApprovalPersonnelName={1}' style='color:Blue; font-weight:bold;'>{0}</a>,", item, ApprovalPersonnelName)); } } } dt.Rows[i]["TaskNoS"] = strTaskNoS.ToString().TrimEnd(','); } } ePageParameter.count = total; return(dt); //string strJson = PublicClass.ToJson(dt, total); //if (strJson.Trim() == "") //{ // strJson = "{\"total\":0,\"rows\":[]}"; //} //return strJson; }
/// <summary> /// 获取所有数据列表 /// 作者:小朱 /// </summary> /// <returns>将DataTable转换为Json数据格式通过string类型返回</returns> public string GetList(int pageNumber, int pageSize, string AreaID, string StartTime, string EndTime, string SampleNum, string SampleName, string Department, string MainTestPersonne, string ReportID, string SamplingTimes, string SamplingTimee) { Session["_AreaID"] = AreaID; Session["_StartTime"] = StartTime; Session["_EndTime"] = EndTime; Session["_SampleNum"] = SampleNum; Session["_SampleName"] = SampleName; Session["_Department"] = Department; Session["_MainTestPersonne"] = MainTestPersonne; Session["_SamplingTimes"] = SamplingTimes; Session["_SamplingTimee"] = SamplingTimee; Session["_ReportID"] = ReportID; DataTable dt = new DataTable(); int total = 0; string strWhere = ""; if (!string.IsNullOrEmpty(ReportID) && ReportID != "0") { strWhere = PageTools.AddWhere(strWhere, "T.ReportID=" + ReportID); } if (!string.IsNullOrEmpty(AreaID) && AreaID != "-1") { strWhere = PageTools.AddWhere(strWhere, "T.AreaID=" + AreaID); } if (!string.IsNullOrEmpty(StartTime)) { strWhere = PageTools.AddWhere(strWhere, "T.IssuedTime>=cast('" + StartTime + "' as datetime)"); } if (!string.IsNullOrEmpty(EndTime)) { strWhere = PageTools.AddWhere(strWhere, "T.IssuedTime<=cast('" + EndTime + "' as datetime)"); } if (!string.IsNullOrEmpty(SampleNum)) { strWhere = PageTools.AddWhere(strWhere, "T.SampleNum like '%" + SampleNum + "%'"); } if (!string.IsNullOrEmpty(SampleName)) { strWhere = PageTools.AddWhere(strWhere, "T.SampleName like '%" + SampleName + "%'"); } if (!string.IsNullOrEmpty(Department)) { strWhere = PageTools.AddWhere(strWhere, "T.Department like '%" + Department + "%'"); } if (!string.IsNullOrEmpty(MainTestPersonne)) { strWhere = PageTools.AddWhere(strWhere, "D.PersonnelName like '%" + MainTestPersonne + "%'"); } if (!string.IsNullOrEmpty(SamplingTimes)) { strWhere = PageTools.AddWhere(strWhere, "SamplingTime>=cast('" + SamplingTimes + "' as datetime)"); } if (!string.IsNullOrEmpty(SamplingTimee)) { strWhere = PageTools.AddWhere(strWhere, "SamplingTime<=cast('" + SamplingTimee + "' as datetime)"); } //添加数据权限判断 switch (CurrentUserInfo.DataRange) { case 2: //区域 strWhere = PageTools.AddWhere(strWhere, "T.AreaID=" + CurrentUserInfo.AreaID + " "); break; case 3: //个人 strWhere = PageTools.AddWhere(strWhere, "T.EditPersonnelID=" + CurrentUserInfo.PersonnelID + " "); break; } try { //dt = tTestReport.GetListByPage(strWhere, "UpdateTime DESC,T.SampleName ASC", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize, ref total).Tables[0]; dt = tTestReport.GetListByPage(strWhere, "TestTime DESC", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize, ref total).Tables[0]; } catch { } if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { string ApprovalPersonnelName = dt.Rows[i]["ApprovalPersonnelName"].ToString(); string RecordIDS = dt.Rows[i]["RecordIDS"].ToString(); StringBuilder strRecordIDS = new StringBuilder(); if (!string.IsNullOrEmpty(RecordIDS)) { string[] ArrRecordIDS = RecordIDS.Split(','); foreach (string item in ArrRecordIDS) { if (!string.IsNullOrEmpty(item)) { strRecordIDS.Append(string.Format("<a href='/OriginalRecord/OriginalRecordList?RecordID={0}&ApprovalPersonnelName={1}' style='color:Blue; font-weight:bold;'>{0}</a>,", item, ApprovalPersonnelName)); } } } dt.Rows[i]["RecordIDS"] = strRecordIDS.ToString().TrimEnd(','); string TaskNoS = dt.Rows[i]["TaskNoS"].ToString(); StringBuilder strTaskNoS = new StringBuilder(); if (!string.IsNullOrEmpty(TaskNoS)) { string[] ArrTaskNoS = TaskNoS.Split(','); foreach (string item in ArrTaskNoS) { if (!string.IsNullOrEmpty(item)) { strTaskNoS.Append(string.Format("<a href='/ExpePlan/ExpePlanList?PlanID={0}&ApprovalPersonnelName={1}' style='color:Blue; font-weight:bold;'>{0}</a>,", item, ApprovalPersonnelName)); } } } dt.Rows[i]["TaskNoS"] = strTaskNoS.ToString().TrimEnd(','); } } string strJson = PublicClass.ToJson(dt, total); if (strJson.Trim() == "") { strJson = "{\"total\":0,\"rows\":[]}"; } return(strJson); }