/// <summary> /// 获取所有数据列表 /// 作者:小朱 /// </summary> /// <returns>将DataTable转换为Json数据格式通过string类型返回</returns> public string GetList(int pageNumber, int pageSize, int FileType, int ParentID) { DataTable dt = new DataTable(); int total = 0; string strWhere = ""; strWhere = PageTools.AddWhere(strWhere, "FileType=" + FileType); strWhere = PageTools.AddWhere(strWhere, "ParentID=" + ParentID); try { dt = tFileList.GetListByPage(strWhere, "FileID Desc", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize, ref total).Tables[0]; } catch { } string strJson = PublicClass.ToJson(dt, total); if (strJson.Trim() == "") { strJson = "{\"total\":0,\"rows\":[]}"; } return(strJson); }
public string GetSanitationList(int pageNumber, int pageSize, string _searchtext, string _searchtype, int _supplierId) { DataTable dt = new DataTable(); int total = 0; try { if (_supplierId > 0 && !string.IsNullOrEmpty(_searchtype)) { string where = " type1='供应商管理' and type2 = '" + _searchtype + "' and tId = " + _supplierId; if (!string.IsNullOrEmpty(_searchtext)) { var strs = _searchtext.Split(','); where += string.Format(" and createDate BETWEEN '{0}' and '{1}'", strs[0], strs[1]); } dt = _attachmentbll.GetListByPage(where, "updateDate", pageNumber * 8 - 7, pageNumber * 8).Tables[0]; total = dt.Rows.Count; total = _attachmentbll.GetModelList(where).Count; } } catch { } return(PublicClass.ToJson(dt, total)); }
/// <summary> /// 获取所有数据列表 /// 作者:小朱 /// </summary> /// <returns>将DataTable转换为Json数据格式通过string类型返回</returns> public string GetList(int pageNumber, int pageSize, string AreaID, string ProjectName, string ExpeType, string ProjectTypeID, string LaboratoryID) { DataTable dt = new DataTable(); int total = 0; StringBuilder strWhere = new StringBuilder(); if (!string.IsNullOrEmpty(AreaID) && AreaID.Trim() != "-1") //区域ID { strWhere.AddWhere("AreaID=" + AreaID); } if (!string.IsNullOrEmpty(ProjectName))//项目名称 { strWhere.AddWhere("ProjectName like '%" + ProjectName + "%'"); } if (!string.IsNullOrEmpty(ExpeType))//检验类型 { strWhere.AddWhere("ExpeType like '%" + ExpeType + "%'"); } if (!string.IsNullOrEmpty(ProjectTypeID) && ProjectTypeID.Trim() != "-1")//项目类别ID { strWhere.AddWhere("ProjectTypeID=" + ProjectTypeID); } if (!string.IsNullOrEmpty(LaboratoryID) && LaboratoryID.Trim() != "-1")//实验室ID { strWhere.AddWhere("LaboratoryID=" + LaboratoryID); } dt = tProject.GetListByPage(strWhere.ToString(), "", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize, ref total).Tables[0]; 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 StrSearch) { DataTable dt = new DataTable(); int total = 0; string strWhere = ""; if (StrSearch != null && StrSearch.Trim() != "") { strWhere = " T.ClientName like '%" + StrSearch.Trim() + "%'"; } //添加数据权限判断 switch (CurrentUserInfo.DataRange) { case 2: //区域 strWhere += (strWhere.Length > 0 ? " and " : "") + " T.AreaID=" + CurrentUserInfo.AreaID; break; case 3: //个人 strWhere += (strWhere.Length > 0 ? " and " : "") + " T.EditPersonnelID=" + CurrentUserInfo.PersonnelID; break; } try { dt = tClientManage.GetListByPage(strWhere, "", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize, ref total).Tables[0]; } catch { } 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 StrSearch) { DataTable dt = new DataTable(); int total = 0; string strWhere = ""; if (!string.IsNullOrEmpty(StrSearch)) { strWhere = PageTools.AddWhere(strWhere, "MagazineName like '%" + StrSearch + "%' "); } //添加数据权限判断 switch (CurrentUserInfo.DataRange) { case 2: //区域 strWhere += (strWhere.Length > 0 ? " and " : "") + " AreaID=" + CurrentUserInfo.AreaID; break; case 3: //个人 strWhere += (strWhere.Length > 0 ? " and " : "") + " EditPersonnelID=" + CurrentUserInfo.PersonnelID; break; } try { dt = tElectronicsMagazine.GetListByPage(strWhere, "AddTime Desc", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize, ref total).Tables[0]; } catch { } string strJson = PublicClass.ToJson(dt, total); if (strJson.Trim() == "") { strJson = "{\"total\":0,\"rows\":[]}"; } return(strJson); }
public ActionResult EasyConsumeLog() { ViewData["ddl_company"] = PublicClass.GetAreaList("请选择", CurrentUserInfo.AreaID.Value); ViewBag._lid = CurrentUserInfo.AreaID; return(View()); }
public ActionResult DeviceLog() { ViewData["ddl_company"] = PublicClass.GetAreaList("请选择"); ViewBag._lid = CurrentUserInfo.AreaID; return(View()); }
public ActionResult MeasureCheck() { ViewData["ddl_company"] = PublicClass.GetAreaList("请选择", CurrentUserInfo.AreaID.Value); return(View()); }
/// <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); }
/// <summary> /// 导出药品入库 /// 作者:章建国 /// </summary> /// <returns></returns> public FileResult Export_Sample(string _search, string _searchtype, int _companyid) { DataTable dt = new DataTable(); System.IO.MemoryStream stream = new MemoryStream(); try { string where = " 1=1 "; switch (_searchtype) { case "样品名称": where += string.Format(" and name like '%%{0}%%' ", _search); break; case "样品人": where += string.Format(" and detectionUser like '%%{0}%%' ", _search); break; case "抽样日期": var times = _search.Split(','); where += string.Format(" and detectionDate >= '{0}' and detectionDate <= '{1}' ", times[0], times[1]); break; } if (_companyid > 0) { where += string.Format(" and createUser in (select PersonnelID from tb_InPersonnel where AreaID = {0}) ", _companyid); } else { if (CurrentUserInfo.AreaID > 0 && CurrentUserInfo.DataRange == 3) { int _userid = CurrentUserInfo.PersonnelID; where += string.Format(" and CreateUser = (select PersonnelID from tb_InPersonnel where AreaID = {0} and PersonnelID = {1}) ", CurrentUserInfo.AreaID, _userid); } else if (CurrentUserInfo.AreaID > 0 && CurrentUserInfo.DataRange == 2) { int _userid = CurrentUserInfo.PersonnelID; where += string.Format(" and createUser in (select PersonnelID from tb_InPersonnel where AreaID = {0}) ", CurrentUserInfo.AreaID); } } dt = _samplebll.GetList(where).Tables[0]; BLL.PersonnelManage.T_tb_InPersonnel inpersonnel = new BLL.PersonnelManage.T_tb_InPersonnel(); BLL.ClientManage.T_tb_ClientManage clientManage = new BLL.ClientManage.T_tb_ClientManage(); for (int i = 0; i < dt.Rows.Count; i++) { try { int userid = Convert.ToInt32(dt.Rows[i]["handleUser"]); dt.Rows[i]["handleUser"] = inpersonnel.GetModel(userid).PersonnelName; } catch { } try { int InspectCompany = Convert.ToInt32(dt.Rows[i]["InspectCompany"]); dt.Rows[i]["InspectCompany"] = clientManage.GetModel(InspectCompany).ClientName; } catch { } } stream = PublicClass.ExportSampleToExcel(dt); } catch { } string filename = "样品列表" + DateTime.Now.ToFileTime() + ".xls"; return(File(stream, "application/vnd.ms-excel", filename)); }
/// <summary> /// 获取所有数据列表 /// 作者:章建国 /// </summary> /// <returns>将DataTable转换为Json数据格式通过string类型返回</returns> public string GetSampleList(int pageNumber, int pageSize, string _searchtext, string _searchtype, int _cid) { DataTable dt = new DataTable(); int total = 0; try { string where = " 1=1 "; switch (_searchtype) { case "样品名称": where += string.Format(" and name like '%%{0}%%' ", _searchtext); break; case "样品人": where += string.Format(" and detectionUser like '%%{0}%%' ", _searchtext); break; case "抽样日期": var times = _searchtext.Split(','); where += string.Format(" and detectionDate >= '{0}' and detectionDate <= '{1}' ", times[0], times[1]); break; } if (_cid > 0) { where += string.Format(" and createUser in (select PersonnelID from tb_InPersonnel where AreaID = {0}) ", _cid); } else { if (CurrentUserInfo.AreaID > 0 && CurrentUserInfo.DataRange == 3) { int _userid = CurrentUserInfo.PersonnelID; where += string.Format(" and CreateUser = (select PersonnelID from tb_InPersonnel where AreaID = {0} and PersonnelID = {1}) ", CurrentUserInfo.AreaID, _userid); } else if (CurrentUserInfo.AreaID > 0 && CurrentUserInfo.DataRange == 2) { int _userid = CurrentUserInfo.PersonnelID; where += string.Format(" and createUser in (select PersonnelID from tb_InPersonnel where AreaID = {0}) ", CurrentUserInfo.AreaID); } } dt = _samplebll.GetListByPage(where, "createDate desc", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize).Tables[0]; BLL.PersonnelManage.T_tb_InPersonnel inpersonnel = new BLL.PersonnelManage.T_tb_InPersonnel(); BLL.ClientManage.T_tb_ClientManage clientManage = new BLL.ClientManage.T_tb_ClientManage(); for (int i = 0; i < dt.Rows.Count; i++) { try { int userid = Convert.ToInt32(dt.Rows[i]["handleUser"]); dt.Rows[i]["handleUser"] = inpersonnel.GetModel(userid).PersonnelName; } catch { } try { int InspectCompany = Convert.ToInt32(dt.Rows[i]["InspectCompany"]); dt.Rows[i]["InspectCompany"] = clientManage.GetModel(InspectCompany).ClientName; } catch { } } total = dt.Rows.Count; total = _samplebll.GetModelList(where).Count; } catch { } return(PublicClass.ToJson(dt, total)); }
/// <summary> /// 获取所有数据列表 /// 作者:小朱 /// </summary> /// <returns>将DataTable转换为Json数据格式通过string类型返回</returns> public string GetList(int pageNumber, int pageSize, string AreaID, string PlanTypeID, string InspectTimeStart, string InspectTimeEnd, string TaskNo, string ProjectID, string PlanID, string SampleName, string Status) { DataTable dt = new DataTable(); int total = 0; string strWhere = ""; if (!string.IsNullOrEmpty(PlanID) && PlanID != "0") { strWhere = PageTools.AddWhere(strWhere, "T.PlanID=" + PlanID + " "); } if (!string.IsNullOrEmpty(AreaID))//区域 { strWhere = PageTools.AddWhere(strWhere, "T.AreaID=" + AreaID + " "); } if (!string.IsNullOrEmpty(PlanTypeID))//计划类别 { strWhere = PageTools.AddWhere(strWhere, "T.PlanTypeID=" + PlanTypeID + " "); } if (!string.IsNullOrEmpty(InspectTimeStart))//检验开始时间 { strWhere = PageTools.AddWhere(strWhere, "InspectTime>=cast('" + InspectTimeStart + "' as datetime) "); } if (!string.IsNullOrEmpty(InspectTimeEnd))//送检结束时间 { strWhere = PageTools.AddWhere(strWhere, "InspectTime<=cast('" + InspectTimeEnd + "' as datetime) "); } if (!string.IsNullOrEmpty(TaskNo))//任务单号 { strWhere = PageTools.AddWhere(strWhere, "T.TaskNo like '%" + TaskNo.Trim() + "%' "); } if (!string.IsNullOrEmpty(ProjectID))//检验项目 { strWhere = PageTools.AddWhere(strWhere, "T.ProjectID=" + ProjectID + " "); } if (!string.IsNullOrEmpty(SampleName))//样品名称 { strWhere = PageTools.AddWhere(strWhere, "C.name like '%" + SampleName + "%' "); } if (!string.IsNullOrEmpty(Status))//样品名称 { strWhere = PageTools.AddWhere(strWhere, "T.Status =" + Status); } //添加数据权限判断 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 = tExpePlan.GetListByPage(strWhere, "", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize, ref total).Tables[0]; } catch { } string strJson = PublicClass.ToJson(dt, total); if (strJson.Trim() == "") { strJson = "{\"total\":0,\"rows\":[]}"; } return(strJson); }
/// <summary> /// 获取所有数据列表 /// 作者:章建国 /// </summary> /// <returns>将DataTable转换为Json数据格式通过string类型返回</returns> public string GetEasyConsumeOUTList(int pageNumber, int pageSize, int _cid, string _searchtext, string _searchtype, string _datetype, string _txtdate) { DataTable dt = new DataTable(); int total = 0; try { string where = " 1 = 1 "; switch (_searchtype) { case "名称": if (string.IsNullOrEmpty(_searchtext)) { break; } where += string.Format(" and tb_EasyConsume.name like '%%{0}%%' ", _searchtext); break; case "厂家与场地": if (string.IsNullOrEmpty(_searchtext)) { break; } where += string.Format(" and product like '%%{0}%%' ", _searchtext); break; case "经手人": if (string.IsNullOrEmpty(_searchtext)) { break; } var listperson = new BLL.PersonnelManage.T_tb_InPersonnel().GetModelList(" PersonnelName like '%%" + _searchtext + "%%'"); string personids = ""; foreach (var item in listperson) { personids += item.PersonnelID + ","; } if (!string.IsNullOrEmpty(personids)) { where += string.Format(" and user1 in({0}) ", personids.Substring(0, personids.Length - 1)); } break; } switch (_datetype) { case "年": if (string.IsNullOrEmpty(_txtdate)) { break; } where += string.Format(" and year(createDate) ={0} ", _txtdate); break; case "月": if (string.IsNullOrEmpty(_txtdate)) { break; } DateTime _dtime = DateTime.Parse("1949-10-01"); DateTime.TryParse(_txtdate, out _dtime); where += _dtime.Year > 1949 ? string.Format(" and year(createDate) = {0} and month(createDate) = {1} ", _dtime.Year, _dtime.Month) : ""; break; } if (CurrentUserInfo.DataRange == 3) { int _userid = CurrentUserInfo.PersonnelID; where += string.Format(" and T.CreateUser = (select PersonnelID from tb_InPersonnel where AreaID = {0} and PersonnelID = {1}) ", CurrentUserInfo.AreaID.Value, _userid); } else if (_cid > 0 || CurrentUserInfo.DataRange == 2) { int _userid = CurrentUserInfo.PersonnelID; where += string.Format(" and T.createUser in (select PersonnelID from tb_InPersonnel where AreaID = {0}) ", _cid); } dt = _easyconsumeoutbll.GetListByPage(where, "updateDate desc", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize).Tables[0]; //dt.Columns.Add("name"); //dt.Columns.Add("type"); //dt.Columns.Add("danwei"); //dt.Columns.Add("PersonnelName"); //for (int i = 0; i < dt.Rows.Count; i++) //{ // DataRow dr = dt.Rows[i]; // int eid = Convert.ToInt32(dr["eId"]); // tb_EasyConsume _easyconsume = _easyconsumebll.GetModel(eid); // dt.Rows[i]["name"] = _easyconsume.name; // dt.Rows[i]["type"] = _easyconsume.type; // dt.Rows[i]["danwei"] = new tb_BaseBLL().GetModel(_easyconsume.unit.Value).baseName; // dt.Rows[i]["PersonnelName"] = new BLL.PersonnelManage.T_tb_InPersonnel().GetModel(Convert.ToInt32(dr["user1"])).PersonnelName; //} total = dt.Rows.Count; total = _easyconsumeoutbll.GetEasyConsumeOUTCount(where); } catch { } return(PublicClass.ToJson(dt, total)); }
/// <summary> /// 获取所有数据列表 /// 作者:章建国 /// </summary> /// <returns>将DataTable转换为Json数据格式通过string类型返回</returns> public string GetEasyConsumeList(int pageNumber, int pageSize, int _cid, string _searchtext, string _searchtype) { DataTable dt = new DataTable(); int total = 0; try { string where = " 1 = 1 "; switch (_searchtype) { case "名称": where += string.Format(" and name like '%%{0}%%' ", _searchtext); break; case "规格型号": where += string.Format(" and type like '%%{0}%%' ", _searchtext); break; case "单位": where += string.Format(" and danwei like '%%{0}%%' ", _searchtext); break; } if (_cid > 0 && CurrentUserInfo.DataRange == 3) { int _userid = CurrentUserInfo.PersonnelID; where += string.Format(" and CreateUser = (select PersonnelID from tb_InPersonnel where AreaID = {0} and PersonnelID = {1}) ", _cid, _userid); } else if (_cid > 0 && CurrentUserInfo.DataRange == 2) { int _userid = CurrentUserInfo.PersonnelID; where += string.Format(" and createUser in (select PersonnelID from tb_InPersonnel where AreaID = {0}) ", _cid); } dt = _easyconsumebll.GetListByPage(where, "updateDate", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize).Tables[0]; total = dt.Rows.Count; total = _easyconsumebll.GetEasyConsumeCount(where); } catch { } dt.Columns.Add(new DataColumn("djr")); dt.Columns.Add("chukulv"); dt.Columns.Add("rukucount"); dt.Columns.Add("chukucount"); for (int i = 0; i < dt.Rows.Count; i++) { try { int userid = Convert.ToInt32(dt.Rows[i]["createUser"]); dt.Rows[i]["djr"] = new BLL.PersonnelManage.T_tb_InPersonnel().GetModel(userid).PersonnelName; String chukulv = "0%"; int ruku = Utils.GetInt(DbHelperSQL.GetSingle(" select sum(amount) amount from tb_EasyConsumeIN where eId=" + dt.Rows[i]["id"])); int chuku = Utils.GetInt(DbHelperSQL.GetSingle(" select sum(amount) amount from tb_EasyConsumeOUT where eId=" + dt.Rows[i]["id"])); dt.Rows[i]["rukucount"] = ruku; dt.Rows[i]["chukucount"] = chuku; if (chuku > 0) { chukulv = (Convert.ToDouble(chuku) / Convert.ToDouble(ruku)).ToString("p"); } dt.Rows[i]["chukulv"] = chukulv; } catch (Exception e) { continue; } } return(PublicClass.ToJson(dt, total)); }
/// <summary> /// 批量导出 /// </summary> /// <param name="ids"></param> /// <returns></returns> public FilePathResult ExpAllPDF(string ids) { DataTable dt = new DataTable(); int total = 0; string strWhere = ""; if (!string.IsNullOrEmpty(ids)) { strWhere = PageTools.AddWhere(strWhere, $"T.ReportID in ({ids})"); } //添加数据权限判断 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; } dt = tTestReport.GetListByPage(strWhere, "TestTime DESC", 1, 10000, ref total).Tables[0]; var strs = "批量下载-"; string[] iFile = new string[1]; if (dt != null && dt.Rows.Count > 0) { iFile = new string[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { ProcessStartInfo Pss = new ProcessStartInfo(); Pss.FileName = Server.MapPath("/HtmlToPDF/wkhtmltopdf.exe"); string strUrl = System.Configuration.ConfigurationManager.AppSettings["HostName"].ToString() + "/ReportView/TestReportView?ReportID=" + dt.Rows[i]["ReportID"];//Request.UserHostName var eTestReport = tTestReport.GetModel(Convert.ToInt32(dt.Rows[i]["ReportID"])); if (i == 0) { strs += eTestReport.SampleName; } string FileName = UrnHtml(eTestReport.SampleNum) + ".pdf"; string FilePath = Server.MapPath("/TestReportPDF/" + FileName); Pss.Arguments = string.Format("{0} {1}", "\"" + strUrl + "\"", "\"" + FilePath + "\""); Pss.UseShellExecute = false; Pss.RedirectStandardInput = true; Pss.RedirectStandardOutput = true; bool bresult = false; using (Process PS = new Process()) { PS.StartInfo = Pss; PS.Start(); PS.WaitForExit(); if (PS.ExitCode == 0) { bresult = true; PS.Close(); } } iFile[i] = FilePath; } } string oFile = AppDomain.CurrentDomain.BaseDirectory + "UpFile//DownLoads//" + strs + ".zip"; PublicClass.CompressFiles(iFile, oFile); return(File(oFile, "application/octet-stream", strs + ".zip")); }
/// <summary> /// 获取所有数据列表 /// 作者:章建国 /// </summary> /// <returns>将DataTable转换为Json数据格式通过string类型返回</returns> public string GetBorrwList_for_Log(int pageNumber, int pageSize, string _search, string _searchtype, int _cid) { DataTable bookdatetable = new DataTable(); int total = 0; try { string where = " 1 = 1"; #region 搜索条件 if (!string.IsNullOrEmpty(_search)) { switch (_searchtype) { case "bianhao": where = " code like '%%" + _search + "%%'"; break; case "mingchen": where = " name like '%%" + _search + "%%'"; break; case "zhongshu": var zhongshujihe = _basebll.GetModelList(" where pId = 10"); if (zhongshujihe != null && zhongshujihe.Count > 0) { zhongshujihe = zhongshujihe.Where(w => w.baseName.Contains(_search)).ToList(); where = " type1 = " + zhongshujihe.First().id; } break; case "leibie": var leibiejihe = _basebll.GetModelList(" where pId = 13"); if (leibiejihe != null && leibiejihe.Count > 0) { leibiejihe = leibiejihe.Where(w => w.baseName.Contains(_search)).ToList(); where = " type2 = " + leibiejihe.First().id; } break; case "zuozhe": where = " author like '%%" + _search + "%%'"; break; case "zhuangtai": var zhuangtaijihe = _basebll.GetModelList(" where pId = 13"); if (zhuangtaijihe != null && zhuangtaijihe.Count > 0) { zhuangtaijihe = zhuangtaijihe.Where(w => w.baseName.Contains(_search)).ToList(); where = " status = " + zhuangtaijihe.First().id; } break; case "chubanshe": where = " press like '%%" + _search + "%%'"; break; case "jieyueren": where = " name like '%%" + _search + "%%'"; break; case "jieyueriqi": where = string.Format(" and convert(char(8), borrowDate, 112) like '%%{0}%%'", _search); break; case "guihuanriqi": where = string.Format(" and convert(char(8), backDate, 112) like '%%{0}%%'", _search); break; } } #endregion if (_cid > 0 && CurrentUserInfo.DataRange == 3) { int _userid = CurrentUserInfo.PersonnelID; where += string.Format(" and CreateUser = (select PersonnelID from tb_InPersonnel where AreaID = {0} and PersonnelID = {1}) ", _cid, _userid); } else if (_cid > 0 && CurrentUserInfo.DataRange == 2) { int _userid = CurrentUserInfo.PersonnelID; where += string.Format(" and CreateUser in (select PersonnelID from tb_InPersonnel where AreaID = {0}) ", _cid); } bookdatetable = _bookbll.GetListByPage(where, "updateDate", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize).Tables[0]; bookdatetable.Columns.Add(new DataColumn("borrowNum")); bookdatetable.Columns.Add(new DataColumn("amount")); bookdatetable.Columns.Add(new DataColumn("bname")); for (int i = 0; i < bookdatetable.Rows.Count; i++) { int bookid = Convert.ToInt32(bookdatetable.Rows[i]["id"]); var bookborrowList = _bookborrowbll.GetModelList(" status = 2 and bookId = " + bookid); int borrowNum = 0; foreach (var item in bookborrowList) { borrowNum += item.borrowNum.Value; } bookdatetable.Rows[i]["amount"] = bookdatetable.Rows[i]["num"]; bookdatetable.Rows[i]["borrowNum"] = borrowNum; } bookdatetable.Columns.Remove("num"); //dt = _bookborrowbll.GetListByPage(where, "updateDate", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize).Tables[0]; total = bookdatetable.Rows.Count; total = _bookbll.GetModelList(where).Count; } catch { } return(PublicClass.ToJson(bookdatetable, total)); }
/// <summary> /// 获取所有数据列表 /// 作者:章建国 /// </summary> /// <returns>将DataTable转换为Json数据格式通过string类型返回</returns> public string GetBorrwList(int pageNumber, int pageSize, string _search, string _searchtype, int _cid) { DataTable dt = new DataTable(); int total = 0; try { string where = " 1 = 1"; if (!string.IsNullOrEmpty(_search)) { switch (_searchtype) { case "bianhao": where = " code like '%%" + _search + "%%'"; break; case "mingchen": where = " bookName like '%%" + _search + "%%'"; break; case "zhongshu": var zhongshujihe = _basebll.GetModelList(" where pId = 10"); if (zhongshujihe != null && zhongshujihe.Count > 0) { zhongshujihe = zhongshujihe.Where(w => w.baseName.Contains(_search)).ToList(); where = " type1 = " + zhongshujihe.First().id; } break; case "leibie": var leibiejihe = _basebll.GetModelList(" where pId = 13"); if (leibiejihe != null && leibiejihe.Count > 0) { leibiejihe = leibiejihe.Where(w => w.baseName.Contains(_search)).ToList(); where = " type2 = " + leibiejihe.First().id; } break; case "zuozhe": where = " author like '%%" + _search + "%%'"; break; case "zhuangtai": var zhuangtaijihe = _basebll.GetModelList(" where pId = 13"); if (zhuangtaijihe != null && zhuangtaijihe.Count > 0) { zhuangtaijihe = zhuangtaijihe.Where(w => w.baseName.Contains(_search)).ToList(); where = " status = " + zhuangtaijihe.First().id; } break; case "chubanshe": where = " press like '%%" + _search + "%%'"; break; case "jieyueren": where = " name like '%%" + _search + "%%'"; break; case "jieyueriqi": where = string.Format(" and convert(char(8), borrowDate, 112) like '%%{0}%%'", _search); break; case "guihuanriqi": where = string.Format(" and convert(char(8), backDate, 112) like '%%{0}%%'", _search); break; } } if (_cid > 0 && CurrentUserInfo.DataRange == 3) { int _userid = CurrentUserInfo.PersonnelID; where += string.Format(" and CreateUser = (select PersonnelID from tb_InPersonnel where AreaID = {0} and PersonnelID = {1}) ", _cid, _userid); } else if (_cid > 0 && CurrentUserInfo.DataRange == 2) { int _userid = CurrentUserInfo.PersonnelID; where += string.Format(" and CreateUser in (select PersonnelID from tb_InPersonnel where AreaID = {0}) ", _cid); } dt = _bookborrowbll.GetListByPage(where, "updateDate", pageNumber * pageSize - (pageSize - 1), pageNumber * pageSize).Tables[0]; total = dt.Rows.Count; total = _bookborrowbll.GetModelList(where).Count; } catch { } return(PublicClass.ToJson(dt, total)); }
public FilePathResult ExpAllPDF() { string AreaID = Session["_AreaID"].ToString(); string StartTime = Session["_StartTime"].ToString(); string EndTime = Session["_EndTime"].ToString(); string SampleNum = Session["_SampleNum"].ToString(); string SampleName = Session["_SampleName"].ToString(); string Department = Session["_Department"].ToString(); string MainTestPersonne = Session["_MainTestPersonne"].ToString(); string SamplingTimes = Session["_SamplingTimes"].ToString(); string SamplingTimee = Session["_SamplingTimee"].ToString(); string ReportID = ""; if (Session["_ReportID"] != null) { ReportID = Session["_ReportID"].ToString(); } 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", 1, 10000, ref total).Tables[0]; } catch { } string[] iFile = new string[1]; if (dt != null && dt.Rows.Count > 0) { iFile = new string[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { ProcessStartInfo Pss = new ProcessStartInfo(); Pss.FileName = Server.MapPath("/HtmlToPDF/wkhtmltopdf.exe"); string strUrl = System.Configuration.ConfigurationManager.AppSettings["HostName"].ToString() + "/ReportView/TestReportView?ReportID=" + dt.Rows[i]["ReportID"];//Request.UserHostName var eTestReport = tTestReport.GetModel(Convert.ToInt32(dt.Rows[i]["ReportID"])); //string FileName = Guid.NewGuid() + ".pdf"; string FileName = UrnHtml(eTestReport.SampleNum) + ".pdf"; string FilePath = Server.MapPath("/TestReportPDF/" + FileName); Pss.Arguments = string.Format("{0} {1}", "\"" + strUrl + "\"", "\"" + FilePath + "\""); Pss.UseShellExecute = false; Pss.RedirectStandardInput = true; Pss.RedirectStandardOutput = true; bool bresult = false; using (Process PS = new Process()) { PS.StartInfo = Pss; PS.Start(); PS.WaitForExit(); if (PS.ExitCode == 0) { bresult = true; PS.Close(); } } iFile[i] = FilePath; } } var strs = DateTime.Now.ToFileTime().ToString(); string oFile = AppDomain.CurrentDomain.BaseDirectory + "UpFile//DownLoads//" + strs + ".zip"; PublicClass.CompressFiles(iFile, oFile); return(File(oFile, "application/octet-stream", strs + ".zip")); }
public FileResult ExportReport(string ddl_selecttype, string txt_dept, string ddl_type, string txt_search, string txt_StartTime, string txt_EndTime) { DataTable dt = new DataTable(); System.IO.MemoryStream stream = new MemoryStream(); #region 获取数据 int total = 0; string strWhere = " 1=1 "; try { if (!string.IsNullOrEmpty(txt_dept)) { switch (ddl_selecttype) { case "mhcx": { strWhere += " and Department like '%%" + txt_dept + "%%'"; break; } case "qzpp": { strWhere += " and Department = '" + txt_dept + "'"; break; } } } if (!string.IsNullOrEmpty(txt_search)) { switch (ddl_type) { case "ypmc": { strWhere += " and name like '%%" + txt_search + "%%'"; break; } case "jyxm": { strWhere += " and ProjectName like '%%" + txt_search + "%%'"; break; } case "jyr": { strWhere += " and TestPersonnelName like '%%" + txt_search + "%%'"; break; } } } if (!string.IsNullOrEmpty(txt_StartTime)) { strWhere += " and DetectTime >= '" + txt_StartTime + "'"; } if (!string.IsNullOrEmpty(txt_EndTime)) { strWhere += " and DetectTime <= '" + txt_EndTime + "'"; } dt = tDetectProject.GetExportListByReport(strWhere, "").Tables[0]; dt.Columns.Add("QualifiedLevelA", typeof(int)); dt.Columns.Add("QualifiedLevelB", typeof(int)); for (int i = 0; i < dt.Rows.Count; i++) { try { dt.Rows[i]["QualifiedLevelA"] = tDetectProject.GetListCountForReport(dt.Rows[i], "合格"); dt.Rows[i]["QualifiedLevelB"] = tDetectProject.GetListCountForReport(dt.Rows[i], ""); } catch { continue; } } DataRow dr2 = dt.NewRow(); dr2["name"] = "总合计"; dr2["QualifiedLevel"] = tDetectProject.GetAllListCountForReport(strWhere, ""); dr2["QualifiedLevelA"] = tDetectProject.GetAllListCountForReport(strWhere, "1"); dr2["QualifiedLevelB"] = tDetectProject.GetAllListCountForReport(strWhere, "2"); dt.Rows.InsertAt(dr2, dt.Rows.Count); stream = PublicClass.ExportReportToExcel(dt); } catch { } #endregion string filename = "实验统计列表" + DateTime.Now.ToFileTime() + ".xls"; return(File(stream, "application/vnd.ms-excel", filename)); }
/// <summary> /// 获取所有数据列表 /// 作者:小朱 /// </summary> /// <returns>将DataTable转换为Json数据格式通过string类型返回</returns> public string GetList(int pageNumber, int pageSize, string EntrustCompany, string SampleName, string ProjectID, string TaskNo, string SubmissionTimeStart, string SubmissionTimeEnd) { DataTable dt = new DataTable(); int total = 0; string strWhere = "B.handleUser is null"; //已销毁的样品 对应的委托检验不显示 if (!string.IsNullOrEmpty(EntrustCompany)) //送检单位 { strWhere = PageTools.AddWhere(strWhere, "EntrustCompany like '%" + EntrustCompany + "%' "); } if (!string.IsNullOrEmpty(SampleName))//样品名称 { strWhere = PageTools.AddWhere(strWhere, "B.name like '%" + SampleName + "%' "); } if (!string.IsNullOrEmpty(ProjectID) && ProjectID != "-1")//检验项目 { strWhere = PageTools.AddWhere(strWhere, " T.ProjectID=" + ProjectID); } if (!string.IsNullOrEmpty(TaskNo))//任务单号 { strWhere = PageTools.AddWhere(strWhere, "TaskNo like '%" + TaskNo + "%' "); } if (!string.IsNullOrEmpty(SubmissionTimeStart))//起始送检日期 { strWhere = PageTools.AddWhere(strWhere, "SubmissionTime>=cast('" + SubmissionTimeStart + "' as datetime) "); } if (!string.IsNullOrEmpty(SubmissionTimeEnd))//结束送检日期 { strWhere = PageTools.AddWhere(strWhere, "SubmissionTime<=cast('" + SubmissionTimeEnd + "' as datetime) "); } //添加数据权限判断 switch (CurrentUserInfo.DataRange) { case 2: //区域 strWhere += (strWhere.Length > 0 ? " and " : "") + " T.AreaID=" + CurrentUserInfo.AreaID; break; case 3: //个人 strWhere += (strWhere.Length > 0 ? " and " : "") + " T.EditPersonnelID=" + CurrentUserInfo.PersonnelID; break; } try { dt = tEntrustTesting.GetListByPage(strWhere, "", 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 RecordID = dt.Rows[i]["ReportID"].ToString(); if (RecordID != "0") { dt.Rows[i]["strReportID"] = string.Format("<a href='/TestReport/TestReportList?ReportID={0}' style='color:Blue; font-weight:bold;'>{0}</a>", RecordID); } } } string strJson = PublicClass.ToJson(dt, total); if (strJson.Trim() == "") { strJson = "{\"total\":0,\"rows\":[]}"; } return(strJson); }