using System; using System.Collections.Generic; using System.Linq; using System.Web; using BLL; using System.Data; using System.Data.SqlClient; using System.Text; using AspNet = System.Web.UI.WebControls; namespace FineUIPro.Web.HJGL.CheckManage { public partial class CheckResultsSummary : PageBase { #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString(); this.drpProjectId.DataTextField = "ProjectCode"; this.drpProjectId.DataValueField = "ProjectId"; this.drpProjectId.DataSource = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1"); this.drpProjectId.DataBind(); Funs.FineUIPleaseSelect(this.drpProjectId); this.InitTreeMenu();//加载树 } } #endregion #region 加载树 /// /// 加载树 /// private void InitTreeMenu() { this.tvControlItem.Nodes.Clear(); TreeNode rootNode = new TreeNode(); rootNode.Text = "施工号-管道编号"; rootNode.ToolTip = "项目"; rootNode.NodeID = "0"; rootNode.Expanded = true; this.tvControlItem.Nodes.Add(rootNode); List projects = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1"); if (this.drpProjectId.SelectedValue != null && this.drpProjectId.SelectedValue != "null") { projects = projects.Where(x => x.ProjectId == this.drpProjectId.SelectedValue).ToList(); } foreach (var item in projects) { TreeNode rootProjectNode = new TreeNode();//定义根节点 rootProjectNode.Text = item.ProjectCode; rootProjectNode.NodeID = item.ProjectId; rootProjectNode.EnableExpandEvent = true; rootProjectNode.ToolTip = item.ProjectName; rootProjectNode.CommandName = "施工号"; rootNode.Nodes.Add(rootProjectNode); TreeNode tn = new TreeNode(); tn.NodeID = "temp"; tn.Text = "正在加载..."; rootProjectNode.Nodes.Add(tn); } } /// /// 节点展开事件 /// /// /// protected void tvControlItem_NodeExpand(object sender, TreeNodeEventArgs e) { if (e.Node.Nodes != null) { e.Node.Nodes.Clear(); } List list = (from x in Funs.DB.View_CheckResultsSummaryTree where x.ProjectId == e.NodeID select x).ToList(); this.BindNodes(e.Node, list); } /// /// 绑定树节点 /// /// private void BindNodes(TreeNode node, List treeLists) { if (node.CommandName == "施工号") { var lists = (from x in treeLists orderby x.PipeCode descending select x).Distinct(); foreach (var item in lists) { TreeNode newNode = new TreeNode(); newNode.Text = item.PipeCode; newNode.NodeID = item.PipeId + "|" + item.ProjectId; newNode.ToolTip = "管道编号"; newNode.CommandName = "管道编号"; newNode.EnableClickEvent = true; node.Nodes.Add(newNode); } } } #endregion #region 点击TreeView /// /// 点击TreeView /// /// /// protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e) { BindPage(); BindGrid(); } #endregion #region 绑定数据 /// /// 绑定数据 /// private void BindGrid() { if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID) && !string.IsNullOrEmpty(this.tvControlItem.SelectedNode.ParentNode.NodeID)) { var pipeIds = this.tvControlItem.SelectedNodeID.Split('|').ToList(); string projectId = this.tvControlItem.SelectedNode.ParentNode.NodeID;//项目ID string isoClassId = pipeIds[0];//管道等级 string serviceId = pipeIds[1];//介质 string steId = pipeIds[2];//材质 List listStr = new List(); listStr.Add(new SqlParameter("@ProjectId", projectId)); listStr.Add(new SqlParameter("@ISC_ID", isoClassId)); listStr.Add(new SqlParameter("@SER_ID", serviceId)); listStr.Add(new SqlParameter("@STE_ID", steId)); listStr.Add(new SqlParameter("@Flag", "0")); SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunProc("HJGL_sp_CheckResultSummary1", parameter); this.Grid1.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } } private void BindPage() { var pipeIds = this.tvControlItem.SelectedNodeID.Split('|').ToList(); string projectId = this.tvControlItem.SelectedNode.ParentNode.NodeID;//项目ID string isoClassId = pipeIds[0];//管道等级 string serviceId = pipeIds[1];//介质 string steId = pipeIds[2];//材质 Model.SGGLDB db = Funs.DB; this.txtSupervisionUnit.Text = string.Empty; this.txtPipeClass.Text = string.Empty; this.txtPipelineCode.Text = string.Empty; //装置 var installationCode = (from x in db.Project_Installation where x.ProjectId == projectId select x.InstallationCode).FirstOrDefault(); if (!string.IsNullOrEmpty(installationCode)) { this.txtWorkAreaCode.Text = installationCode; } //监理单位 var project = BLL.Base_ProjectService.GetProjectByProjectId(projectId); if (!string.IsNullOrEmpty(project.WatchUnit)) { this.txtSupervisionUnit.Text = project.WatchUnit; } //施工单位 //var unitTypes = (from x in db.Project_Unit where x.ProjectId == projectId && x.UnitType.Contains("4") select x).FirstOrDefault(); //if (unitTypes != null) //{ // var unitName = BLL.Base_UnitService.GetUnitNameByUnitId(unitTypes.UnitId); // if (!string.IsNullOrEmpty(unitName)) // { // this.txtConstructionUnit.Text = unitName; // } //} this.txtConstructionUnit.Text = "镇海石化建安工程有限公司"; this.txtTestingStandard.Text = "NB/T47013-2015";//检测标准 this.txtPipeClass.Text = BLL.HJGL_PipingClassService.GetPipingClassByPipingClassId(isoClassId).ISC_IsoName;//管道级别 this.txtPipelineCode.Text = this.tvControlItem.SelectedNode.Text;//管道编号 var result = from x in db.HJGL_View_CheckResult where x.ProjectId == projectId && x.ISC_ID == isoClassId && x.STE_ID == steId && x.SER_ID == serviceId select x; #region 检测数量统计 //RT对焊接头 var rt1 = from x in result where x.JOTY_Group == "1" && x.States == "2" && x.SysType == "射线检测" select x; if (rt1.Count() > 0) { var q1 = from x in Funs.DB.HJGL_BO_QualityRating where rt1.Select(y => y.CH_TrustItemID).Contains(x.CH_TrustItemID) select x; var q2 = from x in Funs.DB.HJGL_BO_QualityRatingRepair where rt1.Select(y => y.JOT_ID).Contains(x.JOT_ID) select x; string rt1Num = rt1.Count().ToString(); string rt1FileNum = (q1.Count() + q2.Count()).ToString(); //string rt1FileNum = rt1.Sum(x => x.RTQueFile).Value.ToString(); this.lblRT1.Text = rt1Num + "/" + rt1FileNum;//RT对焊接头 } else { this.lblRT1.Text = "/"; } //UT对焊接头 var ut1 = from x in result where x.JOTY_Group == "1" && x.States == "2" && x.SysType == "超声波检测" select x; if (ut1.Count() > 0) { string ut1Num = ut1.Count().ToString(); string ut1FileNum = (Convert.ToDouble(ut1.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblUT1.Text = ut1Num + "/" + ut1FileNum;//UT对焊接头 } else { this.lblUT1.Text = "/"; } //MT对焊接头 var mt1= from x in result where x.JOTY_Group == "1" && x.States == "2" && x.SysType == "磁粉检测" select x; if (mt1.Count() > 0) { string mt1Num = mt1.Count().ToString(); string mt1FileNum = (Convert.ToDouble(mt1.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblMT1.Text = mt1Num + "/" + mt1FileNum;//MT对焊接头 } else { this.lblMT1.Text = "/"; } //PT对焊接头 var pt1 = from x in result where x.JOTY_Group == "1" && x.States == "2" && x.SysType == "渗透检测" select x; if (pt1.Count() > 0) { string pt1Num = pt1.Count().ToString(); string pt1FileNum = (Convert.ToDouble(pt1.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblPT1.Text = pt1Num + "/" + pt1FileNum;//PT对焊接头 } else { this.lblPT1.Text = "/"; } //MT角焊接头 var mt2 = from x in result where x.JOTY_Group == "2" && x.States == "2" && x.SysType == "磁粉检测" select x; if (mt2.Count() > 0) { string mt2Num = mt2.Count().ToString(); string mt2FileNum = (Convert.ToDouble(mt2.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblMT2.Text = mt2Num + "/" + mt2FileNum;//MT角焊接头 } else { this.lblMT2.Text = "/"; } //PT角焊接头 var pt2 = from x in result where x.JOTY_Group == "2" && x.States == "2" && x.SysType == "渗透检测" select x; if (pt2.Count() > 0) { string pt2Num = pt2.Count().ToString(); string pt2FileNum = (Convert.ToDouble(pt2.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblPT2.Text = pt2Num + "/" + pt2FileNum;//PT角焊接头 } else { this.lblPT2.Text = "/"; } //RT 支管连接接头 var rt3 = from x in result where x.JOTY_Group == "3" && x.States == "2" && x.SysType == "射线检测" select x; if (rt3.Count() > 0) { var q3 = from x in Funs.DB.HJGL_BO_QualityRating where rt3.Select(y => y.CH_TrustItemID).Contains(x.CH_TrustItemID) select x; var q4 = from x in Funs.DB.HJGL_BO_QualityRatingRepair where rt3.Select(y => y.JOT_ID).Contains(x.JOT_ID) select x; string rt3Num = rt3.Count().ToString(); string rt3FileNum = (q3.Count() + q4.Count()).ToString(); this.lblRT3.Text = rt3Num + "/" + rt3FileNum;//RT支管连接接头 } else { this.lblRT3.Text = "/"; } //UT 支管连接接头 var ut3 = from x in result where x.JOTY_Group == "3" && x.States == "2" && x.SysType == "超声波检测" select x; if (ut3.Count() > 0) { string ut3Num = ut3.Count().ToString(); string ut3FileNum = (Convert.ToDouble(ut3.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblUT3.Text = ut3Num + "/" + ut3FileNum;//UT支管连接接头 } else { this.lblUT3.Text = "/"; } //MT 支管连接接头 var mt3 = from x in result where x.JOTY_Group == "3" && x.States == "2" && x.SysType == "磁粉检测" select x; if (mt3.Count() > 0) { string mt3Num = mt3.Count().ToString(); string mt3FileNum = (Convert.ToDouble(mt3.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblMT3.Text = mt3Num + "/" + mt3FileNum;//MT支管连接接头 } else { this.lblMT3.Text = "/"; } //PT 支管连接接头 var pt3 = from x in result where x.JOTY_Group == "3" && x.States == "2" && x.SysType == "渗透检测" select x; if (pt3.Count() > 0) { string pt3Num = pt3.Count().ToString(); string pt3FileNum = (Convert.ToDouble(pt3.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblPT3.Text = pt3Num + "/" + pt3FileNum;//PT支管连接接头 } else { this.lblPT3.Text = "/"; } #endregion #region 不合格情况统计 //RT对焊接头 var unRT1 = from x in result where x.JOTY_Group == "1" && x.States == "4" && x.SysType == "射线检测" select x; if (unRT1.Count() > 0) { var q1 = from x in Funs.DB.HJGL_BO_QualityRating where x.IsPass== "不合格" && unRT1.Select(y => y.CH_TrustItemID).Contains(x.CH_TrustItemID) select x; string unRT1Num = unRT1.Count().ToString(); string unRT1FileNum = q1.Count().ToString(); //string unRT1FileNum = unRT1.Sum(x => x.RTQueFile).Value.ToString(); this.lblUnRT1.Text = unRT1Num + "/" + unRT1FileNum;//RT对焊接头 } else { this.lblUnRT1.Text = "/"; } //UT对焊接头 var unUT1 = from x in result where x.JOTY_Group == "1" && x.States == "4" && x.SysType == "超声波检测" select x; if (unUT1.Count() > 0) { string unUT1Num = unUT1.Count().ToString(); string unUT1FileNum = (Convert.ToDouble(unUT1.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblUnUT1.Text = unUT1Num + "/" + unUT1FileNum;//UT对焊接头 } else { this.lblUnUT1.Text = "/"; } // MT对焊接头 var unMT1 = from x in result where x.JOTY_Group == "1" && x.States == "4" && x.SysType == "磁粉检测" select x; if (unMT1.Count() > 0) { string unMT1Num = unMT1.Count().ToString(); string unMT1FileNum = (Convert.ToDouble(unMT1.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblUnMT1.Text = unMT1Num + "/" + unMT1FileNum;//MT对焊接头 } else { this.lblUnMT1.Text = "/"; } // PT对焊接头 var unPT1 = from x in result where x.JOTY_Group == "1" && x.States == "4" && x.SysType == "渗透检测" select x; if (unPT1.Count() > 0) { string unPT1Num = unPT1.Count().ToString(); string unPT1FileNum = (Convert.ToDouble(unPT1.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblUnPT1.Text = unPT1Num + "/" + unPT1FileNum;//PT对焊接头 } else { this.lblUnPT1.Text = "/"; } // MT角焊接头 var unMT2 = from x in result where x.JOTY_Group == "2" && x.States == "4" && x.SysType == "磁粉检测" select x; if (unMT2.Count() > 0) { string unMT2Num = unMT2.Count().ToString(); string unMT2FileNum = (Convert.ToDouble(unMT2.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblUnMT2.Text = unMT2Num + "/" + unMT2FileNum;//MT对焊接头 } else { this.lblUnMT2.Text = "/"; } // PT角焊接头 var unPT2 = from x in result where x.JOTY_Group == "2" && x.States == "4" && x.SysType == "渗透检测" select x; if (unPT2.Count() > 0) { string unPT2Num = unPT2.Count().ToString(); string unPT2FileNum = (Convert.ToDouble(unPT2.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblUnPT2.Text = unPT2Num + "/" + unPT2FileNum;//PT对焊接头 } else { this.lblUnPT2.Text = "/"; } // RT支管连接接头 var unRT3 = from x in result where x.JOTY_Group == "3" && x.States == "4" && x.SysType == "射线检测" select x; if (unRT3.Count() > 0) { var q1 = from x in Funs.DB.HJGL_BO_QualityRating where x.IsPass == "不合格" && unRT3.Select(y => y.CH_TrustItemID).Contains(x.CH_TrustItemID) select x; string unRT3Num = unRT3.Count().ToString(); string unRT3FileNum = q1.Count().ToString(); //unRT3.Sum(x => x.RTQueFile).Value.ToString(); this.lblUnRT3.Text = unRT3Num + "/" + unRT3FileNum;//RT支管连接接头 } else { this.lblUnRT3.Text = "/"; } // UT支管连接接头 var unUT3 = from x in result where x.JOTY_Group == "3" && x.States == "4" && x.SysType == "超声波检测" select x; if (unUT3.Count() > 0) { string unUT3Num = unUT3.Count().ToString(); string unUT3FileNum = (Convert.ToDouble(unUT3.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblUnUT3.Text = unUT3Num + "/" + unUT3FileNum;//UT支管连接接头 } else { this.lblUnUT3.Text = "/"; } // MT支管连接接头 var unMT3 = from x in result where x.JOTY_Group == "3" && x.States == "4" && x.SysType == "磁粉检测" select x; if (unMT3.Count() > 0) { string unMT3Num = unMT3.Count().ToString(); string unMT3FileNum = (Convert.ToDouble(unMT3.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblUnMT3.Text = unMT3Num + "/" + unMT3FileNum;//MT支管连接接头 } else { this.lblUnMT3.Text = "/"; } // PT支管连接接头 var unPT3 = from x in result where x.JOTY_Group == "3" && x.States == "4" && x.SysType == "渗透检测" select x; if (unPT3.Count() > 0) { string unPT3Num = unPT3.Count().ToString(); string unPT3FileNum = (Convert.ToDouble(unPT3.Sum(x => (x.JOT_Dia.HasValue ? x.JOT_Dia.Value : 0))) * 3.14 / 1000).ToString("#0.000"); this.lblUnPT3.Text = unPT3Num + "/" + unPT3FileNum;//PT支管连接接头 } else { this.lblUnPT3.Text = "/"; } #endregion } #endregion #region 排序 /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid(); } #endregion #region 页索引改变事件 /// /// 页索引改变事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } #endregion #region 分页选择下拉改变事件 /// /// 分页选择下拉改变事件 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } #endregion #region 项目下拉选择事件 /// /// 项目下拉选择事件 /// /// /// protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e) { this.InitTreeMenu(); } #endregion #region 格式化字符串 ///// ///// 获取RT/UT 合格/不合格 ///// ///// ///// //protected string ConvertRTUTResult(object result) //{ // string rtutResult = string.Empty; // if (result != null) // { // if (result.ToString() == "2") // { // rtutResult = "合格"; // } // else if (result.ToString() == "4") // { // rtutResult = "不合格"; // } // else if (result.ToString() == "2/4") // { // rtutResult = "合格/不合格"; // } // else if (result.ToString() == "4/2") // { // rtutResult = "不合格/合格"; // } // else // { // rtutResult = ""; // } // } // return rtutResult; //} ///// ///// 获取MT/PT合格/不合格 ///// ///// ///// //protected string ConvertMTPTResult(object result) //{ // string mtptResult = string.Empty; // if (result != null) // { // if (result.ToString() == "2") // { // mtptResult = "合格"; // } // else if (result.ToString() == "4") // { // mtptResult = "不合格"; // } // else if (result.ToString() == "2/4") // { // mtptResult = "合格/不合格"; // } // else // { // mtptResult = ""; // } // } // return mtptResult; //} #endregion #region 打印 /// /// 打印 /// /// /// protected void btnPrint_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID)) { var pipeIds = this.tvControlItem.SelectedNodeID.Split('|').ToList(); if (pipeIds != null) { string projectId = this.tvControlItem.SelectedNode.ParentNode.NodeID;//项目ID string isoClassId = pipeIds[0];//管道等级 string serviceId = pipeIds[1];//介质 string steId = pipeIds[2];//材质 string reportId = projectId + "|" + isoClassId + "|" + serviceId + "|" + steId; List listStr = new List(); listStr.Add(new SqlParameter("@ProjectId", projectId)); listStr.Add(new SqlParameter("@ISC_ID", isoClassId)); listStr.Add(new SqlParameter("@SER_ID", serviceId)); listStr.Add(new SqlParameter("@STE_ID", steId)); listStr.Add(new SqlParameter("@Flag", "0")); SqlParameter[] parameter = listStr.ToArray(); DataTable tb = BLL.SQLHelper.GetDataTableRunProc("HJGL_sp_CheckResultSummary", parameter); string pageNum = Funs.GetPagesCountByPageSize(5, 14, tb.Rows.Count).ToString(); string projectName = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName; string projectCode = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectCode; string varValue = string.Empty; string supervisionUnit = this.txtSupervisionUnit.Text.Trim();//监理单位 string pipeClassName = string.Empty;//管道等级 string pipelineCode = string.Empty;//管道编号 //var unitType = (from x in Funs.DB.Project_Unit where x.ProjectId == projectId && x.UnitType.Contains("2") select x).FirstOrDefault(); //if (unitType != null) //{ // var unit = BLL.Base_UnitService.GetUnit(unitType.UnitId); // supervisionUnit = unit.UnitName; //} pipeClassName = BLL.HJGL_PipingClassService.GetPipingClassByPipingClassId(isoClassId).ISC_IsoName;//管道等级 pipelineCode = this.tvControlItem.SelectedNode.Text;//管道编号 //V_Name6-V_Name15 string hg = this.lblRT1.Text.Trim() + "|" + this.lblUT1.Text.Trim() + "|" + this.lblMT1.Text.Trim() + "|" + this.lblPT1.Text.Trim() + "|" + this.lblMT2.Text.Trim() + "|" + this.lblPT2.Text.Trim() + "|" + this.lblRT3.Text.Trim() + "|" + this.lblUT3.Text.Trim() + "|" + this.lblMT3.Text.Trim() + "|" + this.lblPT3.Text.Trim(); ////V_Name16-V_Name25 string bhg = this.lblUnRT1.Text.Trim() + "|" + this.lblUnUT1.Text.Trim() + "|" + this.lblUnMT1.Text.Trim() + "|" + this.lblUnPT1.Text.Trim() + "|" + this.lblUnMT2.Text.Trim() + "|" + this.lblUnPT2.Text.Trim() + "|" + this.lblUnRT3.Text.Trim() + "|" + this.lblUnUT3.Text.Trim() + "|" + this.lblUnMT3.Text.Trim() + "|" + this.lblUnPT3.Text.Trim(); var installation = (from x in Funs.DB.Project_Installation where x.ProjectId == projectId select x.InstallationCode).FirstOrDefault(); var installationCode = installation;//单位工程 V_Name26 //施工单位 //string unitName = string.Empty;//V_Name27 //var unitTypes = (from x in Funs.DB.Project_Unit where x.ProjectId == projectId select x).FirstOrDefault(); //if (unitTypes != null) //{ // unitName = BLL.Base_UnitService.GetUnitNameByUnitId(unitTypes.UnitId); //} string unitName = "镇海石化建安工程有限公司"; //施工单位 V_Name27 var testingStandard = this.txtTestingStandard.Text.Trim();//检测标准 V_Name28 var workArea = installation;//区号 V_Name29 var reportDate = DateTime.Now.ToShortDateString();//报告日期 V_Name30 varValue = pageNum + "|" + projectName + "|" + supervisionUnit + "|" + pipeClassName + "|" + pipelineCode + "|" + hg + "|" + bhg + "|" + installationCode + "|" + unitName + "|" + testingStandard + "|" + workArea + "|" + reportDate + "|" + projectCode; varValue = HttpUtility.UrlEncodeUnicode(varValue); if (tb.Rows.Count <= 5) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_NDTSummaryReportId1, reportId, varValue, "打印 - "))); } else { PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_NDTSummaryReportId2, reportId, varValue, "打印 - "))); PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_NDTSummaryReportId1, reportId, varValue, "打印 - "))); } } } else { ShowNotify("请选择要打印的汇总表!", MessageBoxIcon.Warning); return; } } #endregion #region 导出按钮 /// 导出按钮 /// /// /// protected void btnOut_Click(object sender, EventArgs e) { Response.ClearContent(); string filename = Funs.GetNewFileName(); Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("管道无损检测结果汇总表" + filename, System.Text.Encoding.UTF8) + ".xls"); Response.ContentType = "application/excel"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write(GetGridTableHtml(Grid1)); Response.End(); } /// /// 导出方法 /// /// /// private string GetGridTableHtml(Grid grid) { StringBuilder sb = new StringBuilder(); grid.PageSize = 100000; BindGrid(); sb.Append(""); sb.Append(""); sb.Append(""); foreach (GridColumn column in grid.Columns) { sb.AppendFormat("", column.HeaderText); } sb.Append(""); foreach (GridRow row in grid.Rows) { sb.Append(""); foreach (GridColumn column in grid.Columns) { string html = row.Values[column.ColumnIndex].ToString(); if (column.ColumnID == "tfNumber") { html = (row.FindControl("labNumber") as AspNet.Label).Text; } sb.AppendFormat("", html); } sb.Append(""); } sb.Append("
{0}
{0}
"); return sb.ToString(); } #endregion } }