/// <summary> /// 获得委托项目 /// </summary> /// <param name="strPointID">委托点位</param> /// <returns></returns> protected string getContractItem(string strPointID) { string strSortname = Request.Params["sortname"]; string strSortorder = Request.Params["sortorder"]; int intPageIdx = Convert.ToInt32(Request.Params["page"]); int intPagesize = Convert.ToInt32(Request.Params["pagesize"]); //构造查询对象 TMisContractPointitemVo objPointitem = new TMisContractPointitemVo(); TMisContractPointitemLogic objPointitemLogic = new TMisContractPointitemLogic(); if (strSortname == null || strSortname.Length == 0) { strSortname = TMisContractPointitemVo.ITEM_ID_FIELD; } objPointitem.SORT_FIELD = strSortname; objPointitem.SORT_TYPE = strSortorder; objPointitem.CONTRACT_POINT_ID = strPointID; int intTotalCount = objPointitemLogic.GetSelectResultCount(objPointitem);//总计的数据条数 DataTable dt = objPointitemLogic.SelectByTable(objPointitem, intPageIdx, intPagesize); return(CreateToJson(dt, intTotalCount)); }
/// <summary> /// 获取指定监测计划的监测点位信息 /// </summary> /// <param name="strPointId"></param> /// <returns></returns> private DataTable GetPendingPlanPointItemsDataTable(string strPointId) { DataTable dt = new DataTable(); if (!String.IsNullOrEmpty(strPointId)) { TMisContractPointitemVo objItems = new TMisContractPointitemVo(); objItems.CONTRACT_POINT_ID = strPointId; dt = new TMisContractPointitemLogic().GetItemsForPoint(objItems); } return(dt); }
protected void btnExport_QY_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); TMisContractVo objItems = new TMisContractVo(); string strWorkContent = ""; if (!String.IsNullOrEmpty(task_id)) { objItems.ID = task_id; } dt = new TMisContractLogic().GetExportInforData(objItems); FileStream file = new FileStream(HttpContext.Current.Server.MapPath("TempFile/QY/ContractInforSheet.xls"), FileMode.Open, FileAccess.Read); HSSFWorkbook hssfworkbook = new HSSFWorkbook(file); ISheet sheet = hssfworkbook.GetSheet("Sheet1"); //插入委托书单号 sheet.GetRow(2).GetCell(6).SetCellValue("No:" + dt.Rows[0]["CONTRACT_CODE"].ToString()); sheet.GetRow(4).GetCell(2).SetCellValue(dt.Rows[0]["COMPANY_NAME"].ToString()); //委托单位 sheet.GetRow(4).GetCell(5).SetCellValue(dt.Rows[0]["CONTACT_NAME"].ToString()); //联系人 sheet.GetRow(4).GetCell(8).SetCellValue(dt.Rows[0]["PHONE"].ToString()); //联系电话 sheet.GetRow(5).GetCell(2).SetCellValue(dt.Rows[0]["CONTACT_ADDRESS"].ToString()); //地址 sheet.GetRow(5).GetCell(5).SetCellValue(dt.Rows[0]["POST"].ToString()); //邮编 sheet.GetRow(9).GetCell(2).SetCellValue(dt.Rows[0]["TESTED_COMPANY_NAME"].ToString()); //受检单位 sheet.GetRow(9).GetCell(4).SetCellValue(dt.Rows[0]["TESTED_PHONE"].ToString()); //联系电话 sheet.GetRow(9).GetCell(8).SetCellValue(dt.Rows[0]["TESTED_CONTACT_ADDRESS"].ToString()); //地址 sheet.GetRow(9).GetCell(6).SetCellValue(dt.Rows[0]["TESTED_POST"].ToString()); //邮编 DataTable dtDict = PageBase.getDictList("RPT_WAY"); DataTable dtSampleSource = PageBase.getDictList("SAMPLE_SOURCE"); string strWay = "", strSampleWay = "";; if (dtDict != null) { foreach (DataRow dr in dtDict.Rows) { strWay += dr["DICT_TEXT"].ToString(); if (dr["DICT_CODE"].ToString() == dt.Rows[0]["RPT_WAY"].ToString()) { strWay += "■ "; } else { strWay += "□ "; } } } if (dtSampleSource != null) { foreach (DataRow dr in dtSampleSource.Rows) { strSampleWay += dr["DICT_TEXT"].ToString(); if (dr["DICT_TEXT"].ToString() == dt.Rows[0]["SAMPLE_SOURCE"].ToString()) { strSampleWay += "■ "; } else { strSampleWay += "□ "; } } } sheet.GetRow(5).GetCell(8).SetCellValue(strWay); //领取方式 sheet.GetRow(6).GetCell(2).SetCellValue(strSampleWay); //监测类型 sheet.GetRow(7).GetCell(2).SetCellValue(dt.Rows[0]["TEST_PURPOSE"].ToString()); //监测目的 sheet.GetRow(8).GetCell(2).SetCellValue(dt.Rows[0]["PROVIDE_DATA"].ToString()); //提供资料 sheet.GetRow(10).GetCell(2).SetCellValue(dt.Rows[0]["OTHER_ASKING"].ToString()); //其他要求 sheet.GetRow(15).GetCell(1).SetCellValue(dt.Rows[0]["MONITOR_ACCORDING"].ToString()); //监测依据 sheet.GetRow(20).GetCell(1).SetCellValue(dt.Rows[0]["REMARK2"].ToString()); //备注 string strExplain = @"1.是否有分包:□是[□电话确认;□其它: ] □否 是否使用非标准方法: □是 □否 2.监测收费参照广东省物价局粤价函[1996]64号文规定执行。委托单位到本站办公室(603室)领取《清远市非税收入缴款通知书》限期到通知书列明的银行所属任何一个网点缴监测费{0}元({1}),到颁行缴款后应将盖有银行收讫章的广东省非税收入(电子)票据执收单位联送回给本站综合室。 3.本站在确认已缴监测费用和委托方提供了必要的监测条件后60个工作日内完成监测。"; string strBUDGET = dt.Rows[0]["BUDGET"].ToString() == "" ? "0" : dt.Rows[0]["BUDGET"].ToString(); strExplain = string.Format(strExplain, strBUDGET, DaXie(strBUDGET)); sheet.GetRow(18).GetCell(1).SetCellValue(strExplain); //监测内容 string[] strMonitroTypeArr = dt.Rows[0]["TEST_TYPES"].ToString().Split(';'); if (dt.Rows[0]["SAMPLE_SOURCE"].ToString() == "送样") { //strWorkContent += "地表水、地下水(送样)\n"; int intLen = strMonitroTypeArr.Length; int INTSHOWLEN = 0; foreach (string strMonitor in strMonitroTypeArr) { INTSHOWLEN++; strWorkContent += GetMonitorName(strMonitor) + "、"; if (INTSHOWLEN == intLen - 1) { strWorkContent += "(送样)\n"; } } } //获取当前监测点信息 TMisContractPointVo ContractPointVo = new TMisContractPointVo(); ContractPointVo.CONTRACT_ID = task_id; ContractPointVo.IS_DEL = "0"; DataTable dtPoint = new TMisContractPointLogic().SelectByTable(ContractPointVo); string strOutValuePoint = "", strOutValuePointItems = ""; if (strMonitroTypeArr.Length > 0) { foreach (string strMonitor in strMonitroTypeArr) { string strMonitorName = "", strPointName = ""; DataRow[] drPoint = dtPoint.Select("MONITOR_ID='" + strMonitor + "'"); if (drPoint.Length > 0) { foreach (DataRow drrPoint in drPoint) { string strPointNameForItems = "", strPointItems = ""; strMonitorName = GetMonitorName(strMonitor) + ":"; strPointName += drrPoint["POINT_NAME"].ToString() + "、"; //获取当前点位的监测项目 TMisContractPointitemVo ContractPointitemVo = new TMisContractPointitemVo(); ContractPointitemVo.CONTRACT_POINT_ID = drrPoint["ID"].ToString(); DataTable dtPointItems = new TMisContractPointitemLogic().GetItemsForPoint(ContractPointitemVo); if (dtPointItems.Rows.Count > 0) { foreach (DataRow drItems in dtPointItems.Rows) { strPointNameForItems = strMonitorName.Substring(0, strMonitorName.Length - 1) + drrPoint["POINT_NAME"] + "(" + (drrPoint["SAMPLE_DAY"].ToString() == "" ? "1" : drrPoint["SAMPLE_DAY"].ToString()) + "天" + (drrPoint["SAMPLE_FREQ"].ToString() == "" ? "1" : drrPoint["SAMPLE_FREQ"].ToString()) + "次):"; strPointItems += drItems["ITEM_NAME"].ToString() + "、"; } strOutValuePointItems += strPointNameForItems + strPointItems.Substring(0, strPointItems.Length - 1) + ";\n"; } } //获取输出监测类型监测点位信息 strOutValuePoint += strMonitorName + strPointName.Substring(0, strPointName.Length - 1) + ";\n"; } } } strWorkContent += "监测点位:\n" + strOutValuePoint; strWorkContent += "监测因子与频次:\n" + strOutValuePointItems; sheet.GetRow(12).GetCell(1).SetCellValue(strWorkContent); using (MemoryStream stream = new MemoryStream()) { hssfworkbook.Write(stream); HttpContext curContext = HttpContext.Current; // 设置编码和附件格式 curContext.Response.ContentType = "application/vnd.ms-excel"; curContext.Response.ContentEncoding = Encoding.UTF8; curContext.Response.Charset = ""; curContext.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("委托监测协议书-" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls", Encoding.UTF8)); curContext.Response.BinaryWrite(stream.GetBuffer()); curContext.Response.End(); } }