diff --git a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/交工技术文件目录.frx b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/交工技术文件目录.frx index 57a60b6..8a5fb02 100644 --- a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/交工技术文件目录.frx +++ b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/交工技术文件目录.frx @@ -1,5 +1,5 @@  - + using System; using System.Collections; using System.Collections.Generic; @@ -51,7 +51,7 @@ namespace FastReport } - + @@ -61,7 +61,7 @@ namespace FastReport - + @@ -72,16 +72,16 @@ namespace FastReport - - + + - + - + @@ -99,13 +99,13 @@ namespace FastReport - - + + - + @@ -113,14 +113,14 @@ namespace FastReport - - - + + + - + @@ -129,15 +129,15 @@ namespace FastReport - - + + - - + + - + diff --git a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/交工技术文件说明.frx b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/交工技术文件说明.frx index fc87606..9552aa6 100644 --- a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/交工技术文件说明.frx +++ b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/交工技术文件说明.frx @@ -1,5 +1,5 @@  - + using System; using System.Collections; using System.Collections.Generic; @@ -33,7 +33,7 @@ namespace FastReport - + @@ -48,14 +48,18 @@ namespace FastReport - + - - + + + + + + diff --git a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装汇总表.frx b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装汇总表.frx index 48ffa5d..bf9ae25 100644 --- a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装汇总表.frx +++ b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装汇总表.frx @@ -1,5 +1,5 @@  - + using System; using System.Collections; using System.Collections.Generic; @@ -42,7 +42,7 @@ namespace FastReport } - + @@ -75,115 +75,144 @@ namespace FastReport - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -207,7 +236,7 @@ namespace FastReport - + @@ -234,9 +263,9 @@ namespace FastReport - - - + + + @@ -260,7 +289,7 @@ namespace FastReport - + @@ -288,12 +317,14 @@ namespace FastReport - + - + + + diff --git a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装汇总表2020.frx b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装汇总表2020.frx index e33a4c6..2991c62 100644 --- a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装汇总表2020.frx +++ b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装汇总表2020.frx @@ -1,5 +1,5 @@  - + using System; using System.Collections; using System.Collections.Generic; @@ -17,8 +17,7 @@ using FastReport.Utils; namespace FastReport { public class ReportScript - { - + { private void Table2_ManualBuild(object sender, EventArgs e) { DataSourceBase rowData = Report.GetDataSource("Data"); @@ -36,13 +35,13 @@ namespace FastReport // go next data source row rowData.Next(); - } - } + } + } } } - + @@ -75,118 +74,147 @@ namespace FastReport - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - + @@ -207,39 +235,39 @@ namespace FastReport - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - + @@ -260,7 +288,7 @@ namespace FastReport - + @@ -288,11 +316,11 @@ namespace FastReport - - - - - + + + + + diff --git a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装质量证明.frx b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装质量证明.frx index 9ba0aea..b061433 100644 --- a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装质量证明.frx +++ b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装质量证明.frx @@ -1,7 +1,7 @@  - + - + diff --git a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装质量证明2020.frx b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装质量证明2020.frx index 882f1f5..090e7b6 100644 --- a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装质量证明2020.frx +++ b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装质量证明2020.frx @@ -1,7 +1,7 @@  - + - + diff --git a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/封面.frx b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/封面.frx index 26d315c..71f307b 100644 --- a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/封面.frx +++ b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/封面.frx @@ -1,10 +1,10 @@  - + - + @@ -19,25 +19,30 @@ - + - + + - + + - - - + + + + - - + + + - + + diff --git a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/工业管道安装质量证明书(改造、修理).frx b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/工业管道安装质量证明书(改造、修理).frx index ba878d1..01a7254 100644 --- a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/工业管道安装质量证明书(改造、修理).frx +++ b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/工业管道安装质量证明书(改造、修理).frx @@ -1,7 +1,7 @@  - + - + @@ -30,7 +30,7 @@ - + @@ -90,19 +90,19 @@ - + - + - + @@ -145,18 +145,14 @@ - - - + - - - + diff --git a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/特种设备安装改造维修告知书.frx b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/特种设备安装改造维修告知书.frx index bba070a..11d221c 100644 --- a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/特种设备安装改造维修告知书.frx +++ b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/特种设备安装改造维修告知书.frx @@ -1,7 +1,7 @@  - + - + diff --git a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/交工技术文件说明导出模板.docx b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/交工技术文件说明导出模板.docx index a3fe723..1213d4e 100644 Binary files a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/交工技术文件说明导出模板.docx and b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/交工技术文件说明导出模板.docx differ diff --git a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/压力管道安装质量证明2020导出模板.docx b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/压力管道安装质量证明2020导出模板.docx index a26b3c8..23025ef 100644 Binary files a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/压力管道安装质量证明2020导出模板.docx and b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/压力管道安装质量证明2020导出模板.docx differ diff --git a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/封面导出模板.docx b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/封面导出模板.docx index 1a7d260..0363135 100644 Binary files a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/封面导出模板.docx and b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/封面导出模板.docx differ diff --git a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/工业管道安装汇总表2020导出模板.docx b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/工业管道安装汇总表2020导出模板.docx index e06cd84..83e411c 100644 Binary files a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/工业管道安装汇总表2020导出模板.docx and b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/工业管道安装汇总表2020导出模板.docx differ diff --git a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/工业管道安装汇总表导出模板.docx b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/工业管道安装汇总表导出模板.docx index c2b7ab2..9154872 100644 Binary files a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/工业管道安装汇总表导出模板.docx and b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/工业管道安装汇总表导出模板.docx differ diff --git a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/工业管道安装质量证明书导出模板.docx b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/工业管道安装质量证明书导出模板.docx index 0882284..937a659 100644 Binary files a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/工业管道安装质量证明书导出模板.docx and b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/工业管道安装质量证明书导出模板.docx differ diff --git a/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj b/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj index ea2bfce..90c7606 100644 --- a/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj +++ b/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj @@ -1404,7 +1404,9 @@ + + @@ -1434,9 +1436,7 @@ - - @@ -7063,6 +7063,13 @@ FileDirectory.aspx + + IndustrialPipelineInstallationQualityCertificateEdit.aspx + ASPXCodeBehind + + + IndustrialPipelineInstallationQualityCertificateEdit.aspx + IndustrialPipelineInstallationSummary2020.aspx ASPXCodeBehind @@ -7070,6 +7077,13 @@ IndustrialPipelineInstallationSummary2020.aspx + + IndustrialPipelineInstallationSummaryEdit.aspx + ASPXCodeBehind + + + IndustrialPipelineInstallationSummaryEdit.aspx + IndustrialPipelineQualityCertificate2020.aspx ASPXCodeBehind @@ -7273,13 +7287,6 @@ IndustrialPipelineInstallationQualityCertificate.aspx - - ASPXCodeBehind - IndustrialPipelineInstallationQualityCertificateEdit.aspx - - - IndustrialPipelineInstallationQualityCertificateEdit.aspx - ASPXCodeBehind IndustrialPipelineInstallationSummary.aspx @@ -7287,13 +7294,6 @@ IndustrialPipelineInstallationSummary.aspx - - ASPXCodeBehind - IndustrialPipelineInstallationSummaryEdit.aspx - - - IndustrialPipelineInstallationSummaryEdit.aspx - ASPXCodeBehind MaterialIdentificationInspectionRecord.aspx diff --git a/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx b/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx index a99b9f4..4288c32 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx +++ b/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx @@ -42,7 +42,7 @@ - + diff --git a/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx b/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx index 9a84f19..9862d3f 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx +++ b/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx @@ -39,7 +39,7 @@ - + diff --git a/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx.cs b/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx.cs index 591ecb6..6274e9e 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx.cs +++ b/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx.cs @@ -309,7 +309,7 @@ namespace FineUIPro.Web.JGZL string filePath = string.Empty; //每页显示的固定数据行数 - int rowsPerPage = 36; + int rowsPerPage = 33; string projectId = this.tvControlItem.SelectedNodeID; if (!string.IsNullOrEmpty(projectId)) @@ -352,7 +352,9 @@ namespace FineUIPro.Web.JGZL for (int i = 0; i < tb.Rows.Count; i++) { //创建行 - Row row = new Row(doc); + Row row = new Row(doc); + row.RowFormat.Height = 18; + row.RowFormat.HeightRule = HeightRule.Exactly; row.Cells.Add(CreateCell((i + 1).ToString(), doc, 27, "", "")); row.Cells.Add(CreateCell(tb.Rows[i]["FileCode"].ToString(), doc, 118, "", "")); row.Cells.Add(CreateCell(tb.Rows[i]["FileName"].ToString(), doc, 261.3, "", "")); @@ -370,6 +372,8 @@ namespace FineUIPro.Web.JGZL for (int i = 0; i < needBlankRows - 1; i++) { Row blankRow = new Row(doc); + blankRow.RowFormat.Height = 18; + blankRow.RowFormat.HeightRule = HeightRule.Exactly; // 空白行的单元格宽度和数据行保持一致 blankRow.Cells.Add(CreateCell("", doc, 27, "", "")); blankRow.Cells.Add(CreateCell("", doc, 118, "", "")); @@ -431,6 +435,11 @@ namespace FineUIPro.Web.JGZL //序号 value = " " + value; } + + Run run = new Run(doc, value); + run.Font.Size = 10.5; + run.Font.Name = "楷体"; + if (!string.IsNullOrEmpty(cellUnitLeft)) { p.ParagraphFormat.Alignment = ParagraphAlignment.Left;//表格中字体居左 @@ -441,7 +450,7 @@ namespace FineUIPro.Web.JGZL } - p.AppendChild(new Run(doc, value)); + p.AppendChild(run); cell.CellFormat.Width = cellWidth; diff --git a/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationQualityCertificate.aspx b/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationQualityCertificate.aspx index fcc1ef3..8c94b48 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationQualityCertificate.aspx +++ b/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationQualityCertificate.aspx @@ -42,8 +42,7 @@ - <%----%> - + @@ -60,12 +59,6 @@ - <%-- - - - - - --%> @@ -81,30 +74,15 @@ - <%----%> - <%----%> - <%-- - - - - - --%> - <%----%> - <%-- - - - - - --%> @@ -115,7 +93,6 @@ - <%----%> @@ -131,99 +108,18 @@ - <%----%> - <%-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --%> - <%----%> - <%-- - - - - - --%> - <%----%> diff --git a/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationQualityCertificate.aspx.cs b/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationQualityCertificate.aspx.cs index 7812327..2605de4 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationQualityCertificate.aspx.cs +++ b/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationQualityCertificate.aspx.cs @@ -41,8 +41,6 @@ namespace FineUIPro.Web.JGZL { 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"); @@ -58,12 +56,6 @@ namespace FineUIPro.Web.JGZL this.drpPipelineLevel.DataValueField = "ISC_IsoName"; this.drpPipelineLevel.DataSource = BLL.HJGL_PW_IsoInfoService.GetPipelineLevelList(this.drpProjectId.SelectedValue); this.drpPipelineLevel.DataBind(); - //管道长度 - //this.drpPipelineLength.DataTextField = "PipeLineLength"; - //this.drpPipelineLength.DataValueField = "PipeLineLength"; - //this.drpPipelineLength.DataSource = BLL.HJGL_PW_IsoInfoService.GetPipeLineLengthList(this.drpProjectId.SelectedValue); - //this.drpPipelineLength.DataBind(); - //this.BindGrid(); PageData(); } } @@ -222,80 +214,10 @@ namespace FineUIPro.Web.JGZL { if (this.tvControlItem.SelectedNodeID != "0") { - //this.BindGrid(); PageData(); } } - #endregion - - #region 数据绑定 - /// - /// 数据绑定 - /// - //private void BindGrid() - //{ - // //string projectIds = BLL.Base_ProjectService.GetStrOnProjectIds(this.CurrUser.UserId, "1"); - // string strSql = @"SELECT * from JGZL_IndustrialPipelineInstallationQualityCertificate where 1=1"; - // List listStr = new List(); - // if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID)) - // { - // strSql += " AND ProjectId = @ProjectId"; - // listStr.Add(new SqlParameter("@ProjectId", this.tvControlItem.SelectedNodeID)); - // } - // //else - // //{ - // // strSql += " AND CHARINDEX(ProjectId,@ProjectId)>0 "; - // // listStr.Add(new SqlParameter("@ProjectId", projectIds)); - // //} - // SqlParameter[] parameter = listStr.ToArray(); - // DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); - // // 2.获取当前分页数据 - // Grid1.RecordCount = tb.Rows.Count; - // //tb = GetFilteredTable(Grid1.FilteredData, tb); - // var table = this.GetPagedDataTable(Grid1, tb); - // Grid1.DataSource = table; - // Grid1.DataBind(); - //} - #endregion - - #region 分页排序 - #region 页索引改变事件 - /// - /// 页索引改变事件 - /// - /// - /// - //protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) - //{ - // BindGrid(); - //} - #endregion - - #region 排序 - /// - /// 排序 - /// - /// - /// - //protected void Grid1_Sort(object sender, GridSortEventArgs e) - //{ - // BindGrid(); - //} - #endregion - - #region 分页选择下拉改变事件 - /// - /// 分页选择下拉改变事件 - /// - /// - /// - //protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) - //{ - // Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); - // BindGrid(); - //} - #endregion - #endregion + #endregion #region 查询 /// @@ -415,148 +337,6 @@ namespace FineUIPro.Web.JGZL } #endregion - #region 维护 - /// - /// 增加 - /// - /// - /// - //protected void btnAdd_Click(object sender, EventArgs e) - //{ - // if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID)) - // { - // PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("IndustrialPipelineInstallationQualityCertificateEdit.aspx?projectId={0}", this.tvControlItem.SelectedNodeID, "新增 - "))); - // } - // else - // { - // Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning); - // return; - // } - //} - - /// - /// 双击编辑 - /// - /// - /// - //protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) - //{ - // if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.JGZL_IndustrialPipelineInstallationQualityCertificateMenuId, BLL.Const.BtnModify)) - // { - // if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID)) - // { - // if (!string.IsNullOrEmpty(this.Grid1.SelectedRowID)) - // { - // PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("IndustrialPipelineInstallationQualityCertificateEdit.aspx?certificateId={0}", this.Grid1.SelectedRowID, "编辑 - "))); - // } - // else - // { - // Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning); - // return; - // } - // } - // else - // { - // Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning); - // return; - // } - // } - // else - // { - // ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); - // } - //} - - /// - /// 右键编辑 - /// - /// - /// - //protected void btnMenuEdit_Click(object sender, EventArgs e) - //{ - // if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.JGZL_IndustrialPipelineInstallationQualityCertificateMenuId, BLL.Const.BtnModify)) - // { - // if (Grid1.SelectedRowIndexArray.Length == 0) - // { - // Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning); - // return; - // } - // PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("IndustrialPipelineInstallationQualityCertificateEdit.aspx?certificateId={0}", Grid1.SelectedRowID, "维护 - "))); - // } - // else - // { - // Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); - // } - //} - - /// - /// 右键删除 - /// - /// - /// - //protected void btnMenuDelete_Click(object sender, EventArgs e) - //{ - // if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.JGZL_IndustrialPipelineInstallationQualityCertificateMenuId, Const.BtnDelete)) - // { - // if (Grid1.SelectedRowIndexArray.Length == 0) - // { - // Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning); - // return; - // } - - // bool isShow = true; - // if (Grid1.SelectedRowIndexArray.Length > 1) - // { - // isShow = false; - // } - // bool isDelete = false; - // foreach (int rowIndex in Grid1.SelectedRowIndexArray) - // { - // string rowID = Grid1.DataKeys[rowIndex][0].ToString(); - // if (judgementDelete(rowID, isShow)) - // { - // isDelete = true; - // BLL.IndustrialPipelineInstallationQualityCertificateService.DeleteIndustrialPipelineInstallationQualityCertificateById(rowID); - // BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除工业管道安装质量证明书"); - // } - // } - // if (isDelete) - // { - // ShowNotify("删除成功!", MessageBoxIcon.Success); - // } - // this.BindGrid(); - // } - // else - // { - // Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); - // } - //} - - #region 判断是否可删除 - /// - /// 判断是否可以删除 - /// - /// - //private bool judgementDelete(string id, bool isShow) - //{ - // string content = string.Empty; - - // if (string.IsNullOrEmpty(content)) - // { - // return true; - // } - // else - // { - // if (isShow) - // { - // Alert.ShowInTop(content, MessageBoxIcon.Error); - // } - // return false; - // } - //} - #endregion - #endregion - #region 关闭弹出窗口及刷新页面 /// /// 关闭弹出窗口 diff --git a/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary.aspx b/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary.aspx index a26e8ce..ee53fbd 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary.aspx +++ b/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary.aspx @@ -42,7 +42,7 @@ - + diff --git a/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary.aspx.cs b/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary.aspx.cs index d5e1142..f9cb2ab 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary.aspx.cs +++ b/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary.aspx.cs @@ -661,244 +661,318 @@ CASE WHEN ISNUMERIC(DesignPressure)=1 THEN FORMAT(CAST(DesignPressure AS DECIMAL protected void btnOut_Click(object sender, EventArgs e) { string rootPath = Server.MapPath("~/"); - string initTemplatePath = string.Empty; - string uploadfilepath = string.Empty; - string newUrl = string.Empty; - string filePath = string.Empty; - - //每页显示的固定数据行数 - int rowsPerPage = 5; - - string projectId = this.tvControlItem.SelectedNodeID; - if (!string.IsNullOrEmpty(projectId)) + string initTemplatePath = Const.JGZL_IndustrialPipelineInstallationSummaryUrl; + string templateFullPath = Path.Combine(rootPath, initTemplatePath); + string saveTempPath = templateFullPath.Replace("工业管道安装汇总表导出模板", "工业管道安装汇总表(安装)"); + int dataRowsPerPage = 5; //每页明细数据行数 + string projectId = tvControlItem.SelectedNodeID; + if (string.IsNullOrEmpty(projectId)) { - string strSql = @"SELECT * from JGZL_IndustrialPipelineInstallationSummary where ProjectId = @ProjectId and FromType='1'"; - List listStr = new List(); - listStr.Add(new SqlParameter("@ProjectId", projectId)); - if (!string.IsNullOrEmpty(this.txtIsoNoS.Text)) - { - strSql += " And PipelineCode like @pipeLineCode"; - listStr.Add(new SqlParameter("@pipeLineCode", "%" + this.txtIsoNoS.Text + "%")); - } - SqlParameter[] parameter = listStr.ToArray(); - DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); - if (tb.Rows.Count > 0) - { - initTemplatePath = Const.JGZL_IndustrialPipelineInstallationSummaryUrl; - uploadfilepath = rootPath + initTemplatePath; - - newUrl = uploadfilepath.Replace("工业管道安装汇总表导出模板", "工业管道安装汇总表(安装)"); - if (File.Exists(newUrl)) - { - File.Delete(newUrl); - } - File.Copy(uploadfilepath, newUrl); - //更新书签内容 - Document doc = new Aspose.Words.Document(newUrl); - DocumentBuilder builder = new DocumentBuilder(doc); - - Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true); - - string certificateCode = string.Empty; - string deliveryUnit = string.Empty; - string deliveryUnitCode = string.Empty; - string certificateId = tb.Rows[0]["CertificateId"].ToString(); - var certificate = BLL.IndustrialPipelineInstallationQualityCertificateService.GetIndustrialPipelineInstallationQualityCertificateById(certificateId); - if (certificate != null) - { - certificateCode = certificate.CertificateCode; - deliveryUnit = certificate.DeliveryUnit; - deliveryUnitCode = certificate.DeliveryUnitCode; - } - - Bookmark bookmark1 = doc.Range.Bookmarks["certificateCode"]; - if (bookmark1 != null) - { - bookmark1.Text = certificateCode; - } - Bookmark bookmark2 = doc.Range.Bookmarks["deliveryUnit"]; - if (bookmark2 != null) - { - bookmark2.Text = deliveryUnit; - } - Bookmark bookmark3 = doc.Range.Bookmarks["deliveryUnitCode"]; - if (bookmark3 != null) - { - bookmark3.Text = deliveryUnitCode; - } - - // 设置表头行重复显示 - table.Rows[0].RowFormat.HeadingFormat = true; - table.Rows[1].RowFormat.HeadingFormat = true; - table.Rows[2].RowFormat.HeadingFormat = true; - - // 先记录页尾行,并从表格中移除 - //Row footerRow = table.Rows[table.Rows.Count - 1]; - //table.Rows.RemoveAt(table.Rows.Count - 1); - - for (int i = 0; i < tb.Rows.Count; i++) - { - //创建行 - Aspose.Words.Tables.Row row = new Aspose.Words.Tables.Row(doc); - //row.RowFormat.Height = 50; - //row.RowFormat.HeightRule = HeightRule.Exactly; - row.Cells.Add(CreateCell(tb.Rows[i]["PipelineCode"].ToString(), doc, 32.3, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["PipelineLevel"].ToString(), doc, 33.7, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["PipelineStartPoint"].ToString(), doc, 31.75, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["PipelineEndPoint"].ToString(), doc, 32, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["DesignPressure"].ToString(), doc, 40, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["DesignTemperature"].ToString(), doc, 36, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["Medium"].ToString(), doc, 30.6, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["Material"].ToString(), doc, 31.47, "", "")); - row.Cells.Add(CreateCell(HttpUtility.HtmlDecode(tb.Rows[i]["Specifications"].ToString()), doc, 32.3, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["Length"].ToString(), doc, 30, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["LayingMethod"].ToString(), doc, 31.49, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["WeldsNum"].ToString(), doc, 30, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["LosslessRatio"].ToString(), doc, 39, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["VoltageResistantTestMethod"].ToString(), doc, 32.3, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["VoltageResistantTestMedium"].ToString(), doc, 28.6, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["VoltageResistantTestPressure"].ToString(), doc, 38, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["LeakageTestMedium"].ToString(), doc, 37.4, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["LeakageTestPressure"].ToString(), doc, 41.67, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["CleaningMethod"].ToString(), doc, 34.3, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["CorrosionControlMethod"].ToString(), doc, 31.2, "", "")); - row.Cells.Add(CreateCell(tb.Rows[i]["InsulationMethod"].ToString(), doc, 43.9, "", "")); - - table.Rows.Insert(i + 3, row); - } - // 计算并插入空白行,填满整页 - // 计算总数据行数 - int totalDataRows = tb.Rows.Count; - // 计算需要补充的空白行数量 - int remainder = totalDataRows % rowsPerPage; - int needBlankRows = remainder == 0 ? 0 : rowsPerPage - remainder; - - // 插入空白行(和数据行格式保持一致,仅内容为空) - for (int i = 0; i < needBlankRows - 1; i++) - { - Aspose.Words.Tables.Row blankRow = new Aspose.Words.Tables.Row(doc); - blankRow.RowFormat.Height = 50; - blankRow.RowFormat.HeightRule = HeightRule.Exactly; - // 空白行的单元格宽度和数据行保持一致 - blankRow.Cells.Add(CreateCell("", doc, 32.3, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 33.7, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 31.75, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 32, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 40, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 36, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 30.6, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 31.47, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 32.3, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 30, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 31.49, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 30, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 39, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 32.3, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 28.6, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 38, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 37.4, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 41.67, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 34.3, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 31.2, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 43.9, "", "")); - - // 插入到表格最后一行 - table.Rows.Add(blankRow); - } - //把页尾行重新加回表格最后 - //table.Rows.Add(footerRow); - - //自动设置表格样式 - table.AutoFit(AutoFitBehavior.FixedColumnWidths); - table.Alignment = TableAlignment.Center; - - doc.Save(newUrl); - - string fileName = Path.GetFileName(newUrl); - FileInfo info = new FileInfo(newUrl); - long fileSize = info.Length; - Response.Clear(); - Response.ContentType = "application/x-zip-compressed"; - Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); - Response.AddHeader("Content-Length", fileSize.ToString()); - Response.TransmitFile(newUrl, 0, fileSize); - Response.Flush(); - Response.Close(); - File.Delete(newUrl); - } - else - { - Alert.ShowInTop("没有要导出的数据!", MessageBoxIcon.Warning); - return; - } - } - else - { - Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning); + Alert.ShowInTop("请先选择项目!"); return; } + string sql = @"SELECT * from JGZL_IndustrialPipelineInstallationSummary + WHERE ProjectId = @ProjectId AND FromType='1'"; + List paras = new List(); + paras.Add(new SqlParameter("@ProjectId", projectId)); + DataTable tb = SQLHelper.GetDataTableRunText(sql, paras.ToArray()); + if (tb == null || tb.Rows.Count <= 0) + { + Alert.ShowInTop("当前没有可导出的数据!"); + return; + } + //复制模板 + if (File.Exists(saveTempPath)) + { + File.Delete(saveTempPath); + } + File.Copy(templateFullPath, saveTempPath); + Document doc = new Document(saveTempPath); + DocumentBuilder builder = new DocumentBuilder(doc); + Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true); + if (table == null) + { + Alert.ShowInTop("导出模板异常,未找到汇总主表格!"); + return; + } + string certificateCode = string.Empty; + string deliveryUnit = string.Empty; + string deliveryUnitCode = string.Empty; + string certificateId = tb.Rows[0]["CertificateId"] == DBNull.Value ? "" : tb.Rows[0]["CertificateId"].ToString(); + var certificate = BLL.IndustrialPipelineInstallationQualityCertificateService.GetIndustrialPipelineInstallationQualityCertificateById(certificateId); + if (certificate != null) + { + certificateCode = certificate.CertificateCode; + deliveryUnit = certificate.DeliveryUnit; + deliveryUnitCode = certificate.DeliveryUnitCode; + } + //书签赋值交工单元 + Bookmark bookmark1 = doc.Range.Bookmarks["certificateCode"]; + if (bookmark1 != null) bookmark1.Text = certificateCode; + Bookmark bookmark2 = doc.Range.Bookmarks["deliveryUnit"]; + if (bookmark2 != null) bookmark2.Text = deliveryUnit; + Bookmark bookmark3 = doc.Range.Bookmarks["deliveryUnitCode"]; + if (bookmark3 != null) bookmark3.Text = deliveryUnitCode; + // 关闭HeadingFormat,全部走手动克隆表头 + table.Rows[0].RowFormat.HeadingFormat = false; + table.Rows[1].RowFormat.HeadingFormat = false; + table.Rows[2].RowFormat.HeadingFormat = false; + //克隆表格内表头行 + Aspose.Words.Tables.Row deliveryUnitRow = (Aspose.Words.Tables.Row)table.Rows[0].Clone(true); //交工单元行,仅首页 + Aspose.Words.Tables.Row headerRow1 = (Aspose.Words.Tables.Row)table.Rows[1].Clone(true); + Aspose.Words.Tables.Row headerRow2 = (Aspose.Words.Tables.Row)table.Rows[2].Clone(true); + // 清理模板预留空行;保留 Row0(交工单元)、Row1、Row2(列表头) + while (table.Rows.Count > 3) + { + table.Rows.RemoveAt(3); + } + int totalCount = tb.Rows.Count; + int pageRowCounter = 0; + for (int i = 0; i < totalCount; i++) + { + DataRow dr = tb.Rows[i]; + Aspose.Words.Tables.Row dataRow = BuildDataRow(dr, doc); + table.Rows.Add(dataRow); + pageRowCounter++; + // 判断:本页已满,并且不是最后一条记录 + if (pageRowCounter >= dataRowsPerPage && i != totalCount - 1) + { + //补本页空白行 + int blankNeed = dataRowsPerPage - pageRowCounter; + for (int b = 0; b < blankNeed; b++) + { + table.Rows.Add(BuildBlankRow(doc)); + } + // 1. 定位到当前表格之后,输出本页底部页码 + if (table.NextSibling == null) + { + Paragraph paraAfter = new Paragraph(doc); + table.ParentNode.InsertAfter(paraAfter, table); + } + builder.MoveTo(table.NextSibling); + builder.ParagraphFormat.Alignment = ParagraphAlignment.Center; + builder.Font.Name = "宋体"; + builder.Font.Size = 10.5; + builder.Write("共 "); + builder.InsertField(@"NUMPAGES", ""); + builder.Write(" 页 第 "); + builder.InsertField(@"PAGE", ""); + builder.Write(" 页"); + //保存当前节点(页码段落),后续DOM在它后面追加内容 + Node currentParaNode = builder.CurrentParagraph; + //插入分页符(写在当前页码段落末尾) + builder.InsertBreak(BreakType.PageBreak); + //==== DOM方式新建【续页:大标题 + 质量证明书编号】==== + //续页主标题:工业管道安装汇总表 + Paragraph titlePara = new Paragraph(doc); + titlePara.ParagraphFormat.Alignment = ParagraphAlignment.Center; + Run titleRun = new Run(doc, "工业管道安装汇总表"); + titleRun.Font.Name = "宋体"; + titleRun.Font.Size = 16; + titleRun.Font.Bold = true; + titlePara.Runs.Add(titleRun); + Paragraph certPara = new Paragraph(doc); + certPara.ParagraphFormat.Alignment = ParagraphAlignment.Left; + Run certRun = new Run(doc, "质量证明书编号:" + certificateCode); + certRun.Font.Name = "宋体"; + certRun.Font.Size = 10.5; + certPara.Runs.Add(certRun); + //新建空段落用来做间隔 + Paragraph emptyPara = new Paragraph(doc); + //新建续页表格:先加行,再设置格式 + Aspose.Words.Tables.Table newPageTable = new Aspose.Words.Tables.Table(doc); + newPageTable.Rows.Add((Aspose.Words.Tables.Row)headerRow1.Clone(true)); + newPageTable.Rows.Add((Aspose.Words.Tables.Row)headerRow2.Clone(true)); + newPageTable.Alignment = TableAlignment.Center; + newPageTable.AutoFit(AutoFitBehavior.FixedColumnWidths); + //【DOM链式向后插入:页码段落 → 分页符 → 大标题 →证书编号 →空行 →表格】 + currentParaNode.ParentNode.InsertAfter(titlePara, currentParaNode); + currentParaNode.ParentNode.InsertAfter(certPara, titlePara); + currentParaNode.ParentNode.InsertAfter(emptyPara, certPara); + currentParaNode.ParentNode.InsertAfter(newPageTable, emptyPara); + //替换table引用,后续数据写入这个新表格 + table = newPageTable; + pageRowCounter = 0; + } + } + //处理最后一页剩余数据,补齐空白行 + int remain = totalCount % dataRowsPerPage; + int lastBlankRows = remain == 0 ? 0 : dataRowsPerPage - remain; + for (int b = 0; b < lastBlankRows; b++) + { + table.Rows.Add(BuildBlankRow(doc)); + } + + // ========== 先插入填表审核签字行(表格之后,页码之前)========== + if (table.NextSibling == null) + { + Paragraph paraAfter = new Paragraph(doc); + table.ParentNode.InsertAfter(paraAfter, table); + } + builder.MoveTo(table.NextSibling); + builder.InsertParagraph(); + builder.ParagraphFormat.Alignment = ParagraphAlignment.Left; + builder.Font.Name = "宋体"; + builder.Font.Size = 10.5; + builder.Write(" 填表: 日期: 审核: 日期:"); + + // ========== 再输出页码(签字行的下方)========== + builder.InsertParagraph(); + builder.ParagraphFormat.Alignment = ParagraphAlignment.Center; + builder.Font.Name = "宋体"; + builder.Font.Size = 10.5; + builder.Write("共 "); + builder.InsertField(@"NUMPAGES", ""); + builder.Write(" 页 第 "); + builder.InsertField(@"PAGE", ""); + builder.Write(" 页"); + + doc.UpdatePageLayout(); + doc.UpdateFields(); + doc.Save(saveTempPath); + //下载 + Response.Clear(); + Response.ContentType = "application/octet-stream"; + Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("工业管道安装汇总表.doc")); + Response.TransmitFile(saveTempPath); + Response.Flush(); + Response.End(); + File.Delete(saveTempPath); } - - public static Cell CreateCell(String value, Document doc, double cellWidth, string cellMerge = "", string CenterPage = "", string cellUnitLeft = "") + /// 构建明细数据行 + private Aspose.Words.Tables.Row BuildDataRow(DataRow dr, Document doc) { - Cell cell = new Cell(doc); - Paragraph p = new Paragraph(doc); - - if (!string.IsNullOrEmpty(CenterPage)) + Aspose.Words.Tables.Row row = new Aspose.Words.Tables.Row(doc); + row.RowFormat.Height = 47; + row.RowFormat.HeightRule = HeightRule.Exactly; + string GetCellValue(object obj) { - //序号,在最开始就拼接空格 - value = " " + value; + if (obj == DBNull.Value) return ""; + return obj.ToString().Replace("\r", "").Replace("\n", "").Trim(); } - - Run run = new Run(doc, value); - run.Font.Size = 8; + string pipeCode = GetCellValue(dr["PipelineCode"]); + string pipeLevel = GetCellValue(dr["PipelineLevel"]); + string startPoint = GetCellValue(dr["PipelineStartPoint"]); + string endPoint = GetCellValue(dr["PipelineEndPoint"]); + string desPressure = TrimEndZero(dr["DesignPressure"]); + string desTemp = TrimEndZero(dr["DesignTemperature"]); + string medium = GetCellValue(dr["Medium"]); + string material = GetCellValue(dr["Material"]); + string spec = HttpUtility.HtmlDecode(GetCellValue(dr["Specifications"])); + string length = TrimEndZero(dr["Length"]); + string layMethod = GetCellValue(dr["LayingMethod"]); + string weldNum = GetCellValue(dr["WeldsNum"]); + string losslessRatio = GetCellValue(dr["LosslessRatio"]); + string pressTestMethod = GetCellValue(dr["VoltageResistantTestMethod"]); + string pressTestMedium = GetCellValue(dr["VoltageResistantTestMedium"]); + string pressTestPressure = GetCellValue(dr["VoltageResistantTestPressure"]); + string leakMedium = GetCellValue(dr["LeakageTestMedium"]); + string leakPressure = GetCellValue(dr["LeakageTestPressure"]); + string cleanMethod = GetCellValue(dr["CleaningMethod"]); + string corrosion = GetCellValue(dr["CorrosionControlMethod"]); + string insulation = GetCellValue(dr["InsulationMethod"]); + row.Cells.Add(CreateCell(pipeCode, doc, 32.3, "", "c")); + row.Cells.Add(CreateCell(pipeLevel, doc, 33.7, "", "c")); + row.Cells.Add(CreateCell(startPoint, doc, 31.75, "", "c")); + row.Cells.Add(CreateCell(endPoint, doc, 32, "", "c")); + row.Cells.Add(CreateCell(desPressure, doc, 40, "", "c")); + row.Cells.Add(CreateCell(desTemp, doc, 36, "", "c")); + row.Cells.Add(CreateCell(medium, doc, 30.6, "", "c")); + row.Cells.Add(CreateCell(material, doc, 31.47, "", "c")); + row.Cells.Add(CreateCell(spec, doc, 32.3, "", "c")); + row.Cells.Add(CreateCell(length, doc, 30, "", "c")); + row.Cells.Add(CreateCell(layMethod, doc, 31.49, "", "c")); + row.Cells.Add(CreateCell(weldNum, doc, 30, "", "c")); + row.Cells.Add(CreateCell(losslessRatio, doc, 39, "", "c")); + row.Cells.Add(CreateCell(pressTestMethod, doc, 32.3, "", "c")); + row.Cells.Add(CreateCell(pressTestMedium, doc, 28.6, "", "c")); + row.Cells.Add(CreateCell(pressTestPressure, doc, 38, "", "c")); + row.Cells.Add(CreateCell(leakMedium, doc, 37.4, "", "c")); + row.Cells.Add(CreateCell(leakPressure, doc, 41.67, "", "c")); + row.Cells.Add(CreateCell(cleanMethod, doc, 34.3, "", "c")); + row.Cells.Add(CreateCell(corrosion, doc, 31.2, "", "c")); + row.Cells.Add(CreateCell(insulation, doc, 43.9, "", "c")); + return row; + } + /// 空白补行 + private Aspose.Words.Tables.Row BuildBlankRow(Document doc) + { + Aspose.Words.Tables.Row blankRow = new Aspose.Words.Tables.Row(doc); + blankRow.RowFormat.Height = 47; + blankRow.RowFormat.HeightRule = HeightRule.Exactly; + blankRow.Cells.Add(CreateCell("", doc, 32.3, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 33.7, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 31.75, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 32, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 40, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 36, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 30.6, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 31.47, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 32.3, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 30, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 31.49, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 30, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 39, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 32.3, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 28.6, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 38, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 37.4, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 41.67, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 34.3, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 31.2, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 43.9, "", "")); + return blankRow; + } + private Aspose.Words.Tables.Cell CreateCell(string text, Document doc, double width, string mergeDir = "", string vertAlign = "") + { + Aspose.Words.Tables.Cell cell = new Aspose.Words.Tables.Cell(doc); + cell.CellFormat.Width = width; + + //单元格内边距,让文字贴近边框 + cell.CellFormat.TopPadding = 1.5; + cell.CellFormat.BottomPadding = 1.5; + cell.CellFormat.LeftPadding = 1.5; + cell.CellFormat.RightPadding = 1.5; + + Paragraph para = new Paragraph(doc); + Run run = new Run(doc, text); run.Font.Name = "楷体"; + run.Font.Size = 8; + para.Runs.Add(run); - if (!string.IsNullOrEmpty(cellMerge)) - { - if (cellMerge == "0") - { - cell.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.First;//竖直方向合并的第一个单元格 - } - else - { - cell.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.Previous;//竖直方向合并的后续单元格 - } - } - else - { - cell.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None; - } + //清除段落自带空白 + para.ParagraphFormat.SpaceBefore = 0; + para.ParagraphFormat.SpaceAfter = 0; + para.ParagraphFormat.LineSpacingRule = LineSpacingRule.AtLeast; + para.ParagraphFormat.LineSpacing = 8; - if (!string.IsNullOrEmpty(cellUnitLeft)) - { - p.ParagraphFormat.Alignment = ParagraphAlignment.Left;//表格中字体居左 - } - else - { - p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//表格中字体居中 - } - - // 把带字体样式的run加入段落 - p.AppendChild(run); - - cell.CellFormat.Width = cellWidth; - cell.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center; - cell.CellFormat.Borders.LineWidth = 0.75; - - // 单元格内边距 - cell.CellFormat.LeftPadding = 1; - cell.CellFormat.RightPadding = 1; - cell.CellFormat.TopPadding = 1; - cell.CellFormat.BottomPadding = 1; - - //清除段落段前段后间距 - p.ParagraphFormat.SpaceBefore = 0; - p.ParagraphFormat.SpaceAfter = 0; - - cell.AppendChild(p); + para.ParagraphFormat.Alignment = ParagraphAlignment.Center; + cell.Paragraphs.Add(para); + if (!string.IsNullOrEmpty(vertAlign)) + cell.CellFormat.VerticalAlignment = CellVerticalAlignment.Center; + if (mergeDir == "hStart") + cell.CellFormat.HorizontalMerge = CellMerge.First; + else if (mergeDir == "hContinue") + cell.CellFormat.HorizontalMerge = CellMerge.Previous; return cell; } + + /// + /// 去掉小数末尾无效0 + /// + public static string TrimEndZero(object val) + { + if (val == null || val == DBNull.Value) + return ""; + + string s = val.ToString().Trim(); + if (!decimal.TryParse(s, out decimal num)) + return s; // 不是数字原样返回 + + // 转成字符串自动去除末尾0,.NET decimal.ToString()会自动处理 + return num.ToString("G29"); + } #endregion + } } \ No newline at end of file diff --git a/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary2020.aspx b/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary2020.aspx index 213be87..21a391f 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary2020.aspx +++ b/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary2020.aspx @@ -42,7 +42,7 @@ - + diff --git a/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary2020.aspx.cs b/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary2020.aspx.cs index da74b0b..307c841 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary2020.aspx.cs +++ b/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineInstallationSummary2020.aspx.cs @@ -1,7 +1,9 @@ using Aspose.Words; +using Aspose.Words.Layout; using Aspose.Words.Tables; using BLL; using FastReport.Table; +using FineUIPro.Web.HJGLServer.BaseInfo; using Model; using Newtonsoft.Json.Linq; using NPOI.SS.Formula.Functions; @@ -17,6 +19,8 @@ using System.Web.Services; using System.Web.UI; using System.Web.UI.WebControls; using static System.Windows.Forms.VisualStyles.VisualStyleElement; +using Row = Aspose.Words.Tables.Row; +using Table = Aspose.Words.Tables.Table; namespace FineUIPro.Web.JGZL { @@ -656,6 +660,255 @@ CASE WHEN ISNUMERIC(DesignPressure)=1 THEN FORMAT(CAST(DesignPressure AS DECIMAL } #endregion + //#region 导出按钮 + ///// 导出按钮 + ///// + ///// + ///// + //protected void btnOut_Click(object sender, EventArgs e) + //{ + // string rootPath = Server.MapPath("~/"); + // string initTemplatePath = string.Empty; + // string uploadfilepath = string.Empty; + // string newUrl = string.Empty; + // string filePath = string.Empty; + + // //每页显示的固定数据行数 + // int rowsPerPage = 8; + + // string projectId = this.tvControlItem.SelectedNodeID; + // if (!string.IsNullOrEmpty(projectId)) + // { + // string strSql = @"SELECT * from JGZL_IndustrialPipelineInstallationSummary where ProjectId = @ProjectId and FromType='2'"; + // List listStr = new List(); + // listStr.Add(new SqlParameter("@ProjectId", projectId)); + // if (!string.IsNullOrEmpty(this.txtIsoNoS.Text)) + // { + // strSql += " And PipelineCode like @pipeLineCode"; + // listStr.Add(new SqlParameter("@pipeLineCode", "%" + this.txtIsoNoS.Text + "%")); + // } + // SqlParameter[] parameter = listStr.ToArray(); + // DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); + // if (tb.Rows.Count > 0) + // { + // initTemplatePath = Const.JGZL_IndustrialPipelineInstallationSummary2020Url; + // uploadfilepath = rootPath + initTemplatePath; + + // newUrl = uploadfilepath.Replace("工业管道安装汇总表2020导出模板", "压力管道安装汇总表(2020版)"); + // if (File.Exists(newUrl)) + // { + // File.Delete(newUrl); + // } + // File.Copy(uploadfilepath, newUrl); + // //更新书签内容 + // Document doc = new Aspose.Words.Document(newUrl); + // DocumentBuilder builder = new DocumentBuilder(doc); + + // Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true); + + // string certificateCode = string.Empty; + // string deliveryUnit = string.Empty; + // string deliveryUnitCode = string.Empty; + // string certificateId = tb.Rows[0]["CertificateId"].ToString(); + // var certificate = BLL.IndustrialPipelineInstallationQualityCertificateService.GetIndustrialPipelineInstallationQualityCertificateById(certificateId); + // if (certificate != null) + // { + // certificateCode = certificate.CertificateCode; + // deliveryUnit = certificate.DeliveryUnit; + // deliveryUnitCode = certificate.DeliveryUnitCode; + // } + + // Bookmark bookmark1 = doc.Range.Bookmarks["certificateCode"]; + // if (bookmark1 != null) + // { + // bookmark1.Text = certificateCode; + // } + // Bookmark bookmark2 = doc.Range.Bookmarks["deliveryUnit"]; + // if (bookmark2 != null) + // { + // bookmark2.Text = deliveryUnit; + // } + // Bookmark bookmark3 = doc.Range.Bookmarks["deliveryUnitCode"]; + // if (bookmark3 != null) + // { + // bookmark3.Text = deliveryUnitCode; + // } + + // // 设置表头行重复显示 + // table.Rows[0].RowFormat.HeadingFormat = true; + // table.Rows[1].RowFormat.HeadingFormat = true; + // table.Rows[2].RowFormat.HeadingFormat = true; + + // // ====固定表格布局===== + // table.AutoFit(AutoFitBehavior.FixedColumnWidths); + // table.AllowAutoFit = false; + // table.Alignment = TableAlignment.Center; + + // // 先记录页尾行,并从表格中移除 + // //Row footerRow = table.Rows[table.Rows.Count - 1]; + // //table.Rows.RemoveAt(table.Rows.Count - 1); + + // for (int i = 0; i < tb.Rows.Count; i++) + // { + // //创建行 + // Aspose.Words.Tables.Row row = new Aspose.Words.Tables.Row(doc); + // row.Cells.Add(CreateCell((i + 1).ToString(), doc, 22.68, "", ""));//序号 + // row.Cells.Add(CreateCell(tb.Rows[i]["PipelineCode"].ToString(), doc, 65.49, "", ""));//单线号 + // row.Cells.Add(CreateCell(tb.Rows[i]["PipelineLevel"].ToString(), doc, 37.14, "", ""));//管道级别 + // row.Cells.Add(CreateCell(tb.Rows[i]["DesignPressure"].ToString(), doc, 27.78, "", ""));//设计压力 + // row.Cells.Add(CreateCell(tb.Rows[i]["DesignTemperature"].ToString(), doc, 28.06, "", ""));//设计温度 + // row.Cells.Add(CreateCell(tb.Rows[i]["OperatingTemperature"].ToString(), doc, 28, "", ""));//操作温度 + // row.Cells.Add(CreateCell(tb.Rows[i]["Medium"].ToString(), doc, 34.87, "", ""));//输送介质 + // row.Cells.Add(CreateCell(tb.Rows[i]["Material"].ToString(), doc, 43.66, "", ""));//管道材质牌号及标准 + // row.Cells.Add(CreateCell(HttpUtility.HtmlDecode(tb.Rows[i]["Specifications"].ToString()), doc, 59.82, "", ""));//管道规格(外径×壁厚mm) + // row.Cells.Add(CreateCell(tb.Rows[i]["Length"].ToString(), doc, 34.58, "", ""));//管道长度(m) + // row.Cells.Add(CreateCell(tb.Rows[i]["LayingMethod"].ToString(), doc, 33.74, "", ""));//铺设方式 + // row.Cells.Add(CreateCell(tb.Rows[i]["WeldsNum"].ToString(), doc, 27, "", ""));//焊口数量 + // row.Cells.Add(CreateCell(tb.Rows[i]["LosslessRatio"].ToString(), doc, 45.93, "", ""));//检测方法/比例(%) + // row.Cells.Add(CreateCell(tb.Rows[i]["VoltageResistantTestMedium"].ToString(), doc, 37.14, "", ""));//压力试验-介质 + // row.Cells.Add(CreateCell(tb.Rows[i]["VoltageResistantTestPressure"].ToString(), doc, 30.62, "", ""));//压力试验-压力 + // row.Cells.Add(CreateCell(string.Format("{0:yyyy.MM.dd}", tb.Rows[i]["VoltageResistantTestDate"]), doc, 48.76, "", ""));//压力试验-日期 + // row.Cells.Add(CreateCell(tb.Rows[i]["LeakageTestMedium"].ToString(), doc, 25.23, "", ""));//泄漏性试验-介质 + // row.Cells.Add(CreateCell(tb.Rows[i]["LeakageTestPressure"].ToString(), doc, 28.92, "", ""));//泄漏性试验-压力 + // row.Cells.Add(CreateCell(string.Format("{0:yyyy.MM.dd}", tb.Rows[i]["LeakageTestDate"]), doc, 48.76, "", ""));//泄漏性试验-日期 + // row.Cells.Add(CreateCell(tb.Rows[i]["CleaningMethod"].ToString(), doc, 26.08, "", ""));//吹洗方法 + // row.Cells.Add(CreateCell(tb.Rows[i]["CorrosionControlMethod"].ToString(), doc, 56.7, "", ""));//防腐方式 + // row.Cells.Add(CreateCell(tb.Rows[i]["InsulationMethod"].ToString(), doc, 22.11, "", ""));//保温(绝热)方式 + + // table.Rows.Insert(i + 3, row); + // } + // // 计算并插入空白行,填满整页 + // // 计算总数据行数 + // int totalDataRows = tb.Rows.Count; + // // 计算需要补充的空白行数量 + // int remainder = totalDataRows % rowsPerPage; + // int needBlankRows = remainder == 0 ? 0 : rowsPerPage - remainder; + + // // 插入空白行(和数据行格式保持一致,仅内容为空) + // for (int i = 0; i < needBlankRows - 1; i++) + // { + // Aspose.Words.Tables.Row blankRow = new Aspose.Words.Tables.Row(doc); + // blankRow.RowFormat.Height = 33; + // blankRow.RowFormat.HeightRule = HeightRule.Exactly; + // // 空白行的单元格宽度和数据行保持一致 + // blankRow.Cells.Add(CreateCell("", doc, 22.68, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 65.49, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 37.14, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 27.78, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 28.06, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 28, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 34.87, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 43.66, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 59.82, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 34.58, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 33.74, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 27, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 45.93, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 37.14, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 30.62, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 48.76, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 25.23, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 28.92, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 48.76, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 26.08, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 56.7, "", "")); + // blankRow.Cells.Add(CreateCell("", doc, 22.11, "", "")); + // // 插入到表格最后一行 + // table.Rows.Add(blankRow); + // } + // //把页尾行重新加回表格最后 + // //table.Rows.Add(footerRow); + + // doc.Save(newUrl); + + // string fileName = Path.GetFileName(newUrl); + // FileInfo info = new FileInfo(newUrl); + // long fileSize = info.Length; + // Response.Clear(); + // Response.ContentType = "application/x-zip-compressed"; + // Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); + // Response.AddHeader("Content-Length", fileSize.ToString()); + // Response.TransmitFile(newUrl, 0, fileSize); + // Response.Flush(); + // Response.Close(); + // File.Delete(newUrl); + // } + // else + // { + // Alert.ShowInTop("没有要导出的数据!", MessageBoxIcon.Warning); + // return; + // } + // } + // else + // { + // Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning); + // return; + // } + //} + + //public static Cell CreateCell(String value, Document doc, double cellWidth, string cellMerge = "", string CenterPage = "", string cellUnitLeft = "") + //{ + // Cell cell = new Cell(doc); + // Paragraph p = new Paragraph(doc); + + // if (!string.IsNullOrEmpty(CenterPage)) + // { + // //序号,在最开始就拼接空格 + // value = " " + value; + // } + + // Run run = new Run(doc, value); + // run.Font.Size = 8; + // run.Font.Name = "楷体"; + + // if (!string.IsNullOrEmpty(cellMerge)) + // { + // if (cellMerge == "0") + // { + // cell.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.First;//竖直方向合并的第一个单元格 + // } + // else + // { + // cell.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.Previous;//竖直方向合并的后续单元格 + // } + // } + // else + // { + // cell.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None; + // } + + // if (!string.IsNullOrEmpty(cellUnitLeft)) + // { + // p.ParagraphFormat.Alignment = ParagraphAlignment.Left;//表格中字体居左 + // } + // else + // { + // p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//表格中字体居中 + // } + + // // 把带字体样式的run加入段落 + // p.AppendChild(run); + + // cell.CellFormat.Width = cellWidth; + // cell.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center; + // cell.CellFormat.Borders.LineWidth = 0.75; + + // // 单元格内边距 + // cell.CellFormat.LeftPadding = 1; + // cell.CellFormat.RightPadding = 1; + // cell.CellFormat.TopPadding = 1; + // cell.CellFormat.BottomPadding = 1; + + // //清除段落段前段后间距 + // p.ParagraphFormat.SpaceBefore = 0; + // p.ParagraphFormat.SpaceAfter = 0; + + // cell.AppendChild(p); + // return cell; + //} + + //#endregion + #region 导出按钮 /// 导出按钮 /// @@ -667,11 +920,9 @@ CASE WHEN ISNUMERIC(DesignPressure)=1 THEN FORMAT(CAST(DesignPressure AS DECIMAL string initTemplatePath = string.Empty; string uploadfilepath = string.Empty; string newUrl = string.Empty; - string filePath = string.Empty; - - //每页显示的固定数据行数 - int rowsPerPage = 8; + //每页业务数据7行 + int rowsPerPage = 7; string projectId = this.tvControlItem.SelectedNodeID; if (!string.IsNullOrEmpty(projectId)) { @@ -689,19 +940,17 @@ CASE WHEN ISNUMERIC(DesignPressure)=1 THEN FORMAT(CAST(DesignPressure AS DECIMAL { initTemplatePath = Const.JGZL_IndustrialPipelineInstallationSummary2020Url; uploadfilepath = rootPath + initTemplatePath; - newUrl = uploadfilepath.Replace("工业管道安装汇总表2020导出模板", "压力管道安装汇总表(2020版)"); if (File.Exists(newUrl)) { File.Delete(newUrl); } File.Copy(uploadfilepath, newUrl); - //更新书签内容 + Document doc = new Aspose.Words.Document(newUrl); DocumentBuilder builder = new DocumentBuilder(doc); - Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true); - + //填充业务数据 string certificateCode = string.Empty; string deliveryUnit = string.Empty; string deliveryUnitCode = string.Empty; @@ -714,114 +963,184 @@ CASE WHEN ISNUMERIC(DesignPressure)=1 THEN FORMAT(CAST(DesignPressure AS DECIMAL deliveryUnitCode = certificate.DeliveryUnitCode; } - Bookmark bookmark1 = doc.Range.Bookmarks["certificateCode"]; - if (bookmark1 != null) + //取出模板原始表格,用于克隆表头行 + Table templateTable = doc.GetChild(NodeType.Table, 0, true) as Table; + Row templateUnitRow = (Row)templateTable.Rows[0].Clone(true); //交工单元名称+交工单元编号行(仅第一页) + Row templateTableHeader1 = (Row)templateTable.Rows[1].Clone(true); + Row templateTableHeader2 = (Row)templateTable.Rows[2].Clone(true); + + //直接替换交工单元行单元格内容 + Cell unitNameCell = templateUnitRow.Cells[0]; + unitNameCell.FirstParagraph.Runs.Clear(); + unitNameCell.FirstParagraph.AppendChild(new Run(doc, $"交工单元名称:{deliveryUnit}")); + + Cell unitCodeCell = templateUnitRow.Cells[1]; + unitCodeCell.FirstParagraph.Runs.Clear(); + unitCodeCell.FirstParagraph.AppendChild(new Run(doc, $"交工单元编号:{deliveryUnitCode}")); + + doc.FirstSection.Body.RemoveAllChildren(); + + int total = tb.Rows.Count; + int pageCount = (int)Math.Ceiling((double)total / rowsPerPage); + + for (int pageIndex = 0; pageIndex < pageCount; pageIndex++) { - bookmark1.Text = certificateCode; + bool isFirstPage = pageIndex == 0; + bool isLastPage = pageIndex == pageCount - 1; + + builder.MoveToDocumentEnd(); + + if (!isFirstPage) + { + builder.InsertBreak(BreakType.PageBreak); + builder.MoveToDocumentEnd(); + } + + //================ 每页顶部三行================ + //1.第一行:固定文字 ZDS‑T6.38.047.A/0.2020 居右 + builder.ParagraphFormat.SpaceBefore = 0; + builder.ParagraphFormat.SpaceAfter = 1; + builder.ParagraphFormat.Alignment = ParagraphAlignment.Right; + builder.Font.Size = 15; + builder.Font.Name = "Times New Roman"; + builder.Font.Bold = true; + builder.Write("ZDS‑T6.38.047.A/0.2020"); + builder.InsertParagraph(); + + //2.第二行:大标题 二、压力管道安装汇总表 居中 + builder.ParagraphFormat.SpaceBefore = 0; + builder.ParagraphFormat.SpaceAfter = 1; + builder.ParagraphFormat.Alignment = ParagraphAlignment.Center; + builder.Font.Size = 16; + builder.Font.Name = "宋体"; + builder.Font.Bold = true; + builder.Write("二、压力管道安装汇总表"); + builder.InsertParagraph(); + + //3.第三行:证明书编号 居右,下面紧接表格,SpaceAfter=1极小间距 + builder.ParagraphFormat.SpaceBefore = 0; + builder.ParagraphFormat.SpaceAfter = 1; + builder.ParagraphFormat.Alignment = ParagraphAlignment.Right; + builder.Font.Size = 10.5; + builder.Font.Name = "宋体"; + builder.Font.Bold = false; + builder.Write("证明书编号:" + certificateCode + " "); + //builder.InsertParagraph(); + //===================================================== + + //================ 构建本页表格 ================= + Table pageTable = new Table(doc); + + //第一页才加入交工单元名称编号行,第二页及以后不加 + if (isFirstPage) + { + pageTable.Rows.Add((Row)templateUnitRow.Clone(true)); + } + //所有页面都加入2行列标题表头 + pageTable.Rows.Add((Row)templateTableHeader1.Clone(true)); + pageTable.Rows.Add((Row)templateTableHeader2.Clone(true)); + + //已经添加行之后,再设置表格格式,避免空表格AutoFit报错 + pageTable.AllowAutoFit = false; + pageTable.AutoFit(AutoFitBehavior.FixedColumnWidths); + pageTable.Alignment = TableAlignment.Center; + + int startIdx = pageIndex * rowsPerPage; + int endIdx = Math.Min(startIdx + rowsPerPage, total); + int pageDataCnt = endIdx - startIdx; + + //填充业务数据行 + for (int i = startIdx; i < endIdx; i++) + { + DataRow dr = tb.Rows[i]; + Aspose.Words.Tables.Row dataRow = new Aspose.Words.Tables.Row(doc); + dataRow.RowFormat.Height = 40; + dataRow.RowFormat.HeightRule = HeightRule.Exactly; + dataRow.RowFormat.AllowBreakAcrossPages = false; + + dataRow.Cells.Add(CreateCell((i + 1).ToString(), doc, 22.68, "", ""));//序号 + dataRow.Cells.Add(CreateCell(dr["PipelineCode"].ToString(), doc, 65.49, "", ""));//单线号 + dataRow.Cells.Add(CreateCell(dr["PipelineLevel"].ToString(), doc, 37.14, "", ""));//管道级别 + dataRow.Cells.Add(CreateCell(dr["DesignPressure"].ToString(), doc, 27.78, "", ""));//设计压力 + dataRow.Cells.Add(CreateCell(dr["DesignTemperature"].ToString(), doc, 28.06, "", ""));//设计温度 + dataRow.Cells.Add(CreateCell(dr["OperatingTemperature"].ToString(), doc, 28, "", ""));//操作温度 + dataRow.Cells.Add(CreateCell(dr["Medium"].ToString(), doc, 34.87, "", ""));//输送介质 + dataRow.Cells.Add(CreateCell(dr["Material"].ToString(), doc, 43.66, "", ""));//管道材质牌号及标准 + dataRow.Cells.Add(CreateCell(HttpUtility.HtmlDecode(dr["Specifications"].ToString()), doc, 59.82, "", ""));//管道规格 + dataRow.Cells.Add(CreateCell(dr["Length"].ToString(), doc, 34.58, "", ""));//管道长度(m) + dataRow.Cells.Add(CreateCell(dr["LayingMethod"].ToString(), doc, 33.74, "", ""));//铺设方式 + dataRow.Cells.Add(CreateCell(dr["WeldsNum"].ToString(), doc, 27, "", ""));//焊口数量 + dataRow.Cells.Add(CreateCell(dr["LosslessRatio"].ToString(), doc, 45.93, "", ""));//检测方法/比例(%) + dataRow.Cells.Add(CreateCell(FormatDateStr(dr["VoltageResistantTestMedium"]), doc, 37.14, "", ""));//压力试验-介质 + dataRow.Cells.Add(CreateCell(FormatDateStr(dr["VoltageResistantTestPressure"]), doc, 30.62, "", ""));//压力试验-压力 + dataRow.Cells.Add(CreateCell(FormatDateStr(dr["VoltageResistantTestDate"]), doc, 48.76, "", ""));//压力试验-日期 + dataRow.Cells.Add(CreateCell(FormatDateStr(dr["LeakageTestMedium"]), doc, 25.23, "", ""));//泄漏性试验-介质 + dataRow.Cells.Add(CreateCell(FormatDateStr(dr["LeakageTestPressure"]), doc, 28.92, "", ""));//泄漏性试验-压力 + dataRow.Cells.Add(CreateCell(FormatDateStr(dr["LeakageTestDate"]), doc, 48.76, "", ""));//泄漏性试验-日期 + dataRow.Cells.Add(CreateCell(dr["CleaningMethod"].ToString(), doc, 26.08, "", ""));//吹洗方法 + dataRow.Cells.Add(CreateCell(dr["CorrosionControlMethod"].ToString(), doc, 56.7, "", ""));//防腐方式 + dataRow.Cells.Add(CreateCell(dr["InsulationMethod"].ToString(), doc, 22.11, "", ""));//保温(绝热)方式 + + pageTable.Rows.Add(dataRow); + } + + //不足7条补空白行 + int blankCount = rowsPerPage - pageDataCnt; + for (int b = 0; b < blankCount; b++) + { + Aspose.Words.Tables.Row blankRow = new Aspose.Words.Tables.Row(doc); + blankRow.RowFormat.Height = 40; + blankRow.RowFormat.HeightRule = HeightRule.Exactly; + blankRow.RowFormat.AllowBreakAcrossPages = false; + + blankRow.Cells.Add(CreateCell("", doc, 22.68, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 65.49, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 37.14, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 27.78, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 28.06, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 28, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 34.87, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 43.66, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 59.82, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 34.58, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 33.74, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 27, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 45.93, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 37.14, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 30.62, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 48.76, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 25.23, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 28.92, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 48.76, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 26.08, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 56.7, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 22.11, "", "")); + + pageTable.Rows.Add(blankRow); + } + + //把本页表格追加到文档正文 + doc.FirstSection.Body.AppendChild(pageTable); + + //仅最后一页:表格外部输出签字行 + if (isLastPage) + { + Paragraph signPara = new Paragraph(doc); + Run signRun = new Run(doc, " 填表: 日期: 审核: 日期: "); + signRun.Font.Size = 10.5; + signRun.Font.Name = "宋体"; + signPara.AppendChild(signRun); + signPara.ParagraphFormat.SpaceBefore = 6; + doc.FirstSection.Body.AppendChild(signPara); + } } - Bookmark bookmark2 = doc.Range.Bookmarks["deliveryUnit"]; - if (bookmark2 != null) - { - bookmark2.Text = deliveryUnit; - } - Bookmark bookmark3 = doc.Range.Bookmarks["deliveryUnitCode"]; - if (bookmark3 != null) - { - bookmark3.Text = deliveryUnitCode; - } - - // 设置表头行重复显示 - table.Rows[0].RowFormat.HeadingFormat = true; - table.Rows[1].RowFormat.HeadingFormat = true; - table.Rows[2].RowFormat.HeadingFormat = true; - - // ====固定表格布局===== - table.AutoFit(AutoFitBehavior.FixedColumnWidths); - table.AllowAutoFit = false; - table.Alignment = TableAlignment.Center; - - // 先记录页尾行,并从表格中移除 - //Row footerRow = table.Rows[table.Rows.Count - 1]; - //table.Rows.RemoveAt(table.Rows.Count - 1); - - for (int i = 0; i < tb.Rows.Count; i++) - { - //创建行 - Aspose.Words.Tables.Row row = new Aspose.Words.Tables.Row(doc); - row.Cells.Add(CreateCell((i + 1).ToString(), doc, 22.68, "", ""));//序号 - row.Cells.Add(CreateCell(tb.Rows[i]["PipelineCode"].ToString(), doc, 65.49, "", ""));//单线号 - row.Cells.Add(CreateCell(tb.Rows[i]["PipelineLevel"].ToString(), doc, 37.14, "", ""));//管道级别 - row.Cells.Add(CreateCell(tb.Rows[i]["DesignPressure"].ToString(), doc, 27.78, "", ""));//设计压力 - row.Cells.Add(CreateCell(tb.Rows[i]["DesignTemperature"].ToString(), doc, 28.06, "", ""));//设计温度 - row.Cells.Add(CreateCell(tb.Rows[i]["OperatingTemperature"].ToString(), doc, 28, "", ""));//操作温度 - row.Cells.Add(CreateCell(tb.Rows[i]["Medium"].ToString(), doc, 34.87, "", ""));//输送介质 - row.Cells.Add(CreateCell(tb.Rows[i]["Material"].ToString(), doc, 43.66, "", ""));//管道材质牌号及标准 - row.Cells.Add(CreateCell(HttpUtility.HtmlDecode(tb.Rows[i]["Specifications"].ToString()), doc, 59.82, "", ""));//管道规格(外径×壁厚mm) - row.Cells.Add(CreateCell(tb.Rows[i]["Length"].ToString(), doc, 34.58, "", ""));//管道长度(m) - row.Cells.Add(CreateCell(tb.Rows[i]["LayingMethod"].ToString(), doc, 33.74, "", ""));//铺设方式 - row.Cells.Add(CreateCell(tb.Rows[i]["WeldsNum"].ToString(), doc, 27, "", ""));//焊口数量 - row.Cells.Add(CreateCell(tb.Rows[i]["LosslessRatio"].ToString(), doc, 45.93, "", ""));//检测方法/比例(%) - row.Cells.Add(CreateCell(tb.Rows[i]["VoltageResistantTestMedium"].ToString(), doc, 37.14, "", ""));//压力试验-介质 - row.Cells.Add(CreateCell(tb.Rows[i]["VoltageResistantTestPressure"].ToString(), doc, 30.62, "", ""));//压力试验-压力 - row.Cells.Add(CreateCell(string.Format("{0:yyyy.MM.dd}", tb.Rows[i]["VoltageResistantTestDate"]), doc, 48.76, "", ""));//压力试验-日期 - row.Cells.Add(CreateCell(tb.Rows[i]["LeakageTestMedium"].ToString(), doc, 25.23, "", ""));//泄漏性试验-介质 - row.Cells.Add(CreateCell(tb.Rows[i]["LeakageTestPressure"].ToString(), doc, 28.92, "", ""));//泄漏性试验-压力 - row.Cells.Add(CreateCell(string.Format("{0:yyyy.MM.dd}", tb.Rows[i]["LeakageTestDate"]), doc, 48.76, "", ""));//泄漏性试验-日期 - row.Cells.Add(CreateCell(tb.Rows[i]["CleaningMethod"].ToString(), doc, 26.08, "", ""));//吹洗方法 - row.Cells.Add(CreateCell(tb.Rows[i]["CorrosionControlMethod"].ToString(), doc, 56.7, "", ""));//防腐方式 - row.Cells.Add(CreateCell(tb.Rows[i]["InsulationMethod"].ToString(), doc, 22.11, "", ""));//保温(绝热)方式 - - table.Rows.Insert(i + 3, row); - } - // 计算并插入空白行,填满整页 - // 计算总数据行数 - int totalDataRows = tb.Rows.Count; - // 计算需要补充的空白行数量 - int remainder = totalDataRows % rowsPerPage; - int needBlankRows = remainder == 0 ? 0 : rowsPerPage - remainder; - - // 插入空白行(和数据行格式保持一致,仅内容为空) - for (int i = 0; i < needBlankRows - 1; i++) - { - Aspose.Words.Tables.Row blankRow = new Aspose.Words.Tables.Row(doc); - blankRow.RowFormat.Height = 33; - blankRow.RowFormat.HeightRule = HeightRule.Exactly; - // 空白行的单元格宽度和数据行保持一致 - blankRow.Cells.Add(CreateCell("", doc, 22.68, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 65.49, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 37.14, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 27.78, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 28.06, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 28, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 34.87, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 43.66, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 59.82, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 34.58, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 33.74, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 27, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 45.93, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 37.14, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 30.62, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 48.76, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 25.23, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 28.92, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 48.76, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 26.08, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 56.7, "", "")); - blankRow.Cells.Add(CreateCell("", doc, 22.11, "", "")); - // 插入到表格最后一行 - table.Rows.Add(blankRow); - } - //把页尾行重新加回表格最后 - //table.Rows.Add(footerRow); doc.Save(newUrl); - string fileName = Path.GetFileName(newUrl); FileInfo info = new FileInfo(newUrl); long fileSize = info.Length; Response.Clear(); - Response.ContentType = "application/x-zip-compressed"; + Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); Response.AddHeader("Content-Length", fileSize.ToString()); Response.TransmitFile(newUrl, 0, fileSize); @@ -842,67 +1161,68 @@ CASE WHEN ISNUMERIC(DesignPressure)=1 THEN FORMAT(CAST(DesignPressure AS DECIMAL } } - public static Cell CreateCell(String value, Document doc, double cellWidth, string cellMerge = "", string CenterPage = "", string cellUnitLeft = "") + private Aspose.Words.Tables.Cell CreateCell(String value, Aspose.Words.Document doc, double cellWidth, string cellMerge = "", string CenterPage = "", string cellUnitLeft = "") { - Cell cell = new Cell(doc); - Paragraph p = new Paragraph(doc); - + Aspose.Words.Tables.Cell cell = new Aspose.Words.Tables.Cell(doc); + Aspose.Words.Paragraph p = new Aspose.Words.Paragraph(doc); if (!string.IsNullOrEmpty(CenterPage)) { - //序号,在最开始就拼接空格 value = " " + value; } - - Run run = new Run(doc, value); + Aspose.Words.Run run = new Aspose.Words.Run(doc, value); run.Font.Size = 8; run.Font.Name = "楷体"; - if (!string.IsNullOrEmpty(cellMerge)) { if (cellMerge == "0") { - cell.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.First;//竖直方向合并的第一个单元格 + cell.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.First; } else { - cell.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.Previous;//竖直方向合并的后续单元格 + cell.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.Previous; } } else { cell.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None; } - if (!string.IsNullOrEmpty(cellUnitLeft)) { - p.ParagraphFormat.Alignment = ParagraphAlignment.Left;//表格中字体居左 + p.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left; } else { - p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//表格中字体居中 + p.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Center; } - - // 把带字体样式的run加入段落 p.AppendChild(run); - - cell.CellFormat.Width = cellWidth; + if (cellWidth > 0) + { + cell.CellFormat.Width = cellWidth; + } cell.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center; cell.CellFormat.Borders.LineWidth = 0.75; - - // 单元格内边距 cell.CellFormat.LeftPadding = 1; cell.CellFormat.RightPadding = 1; cell.CellFormat.TopPadding = 1; cell.CellFormat.BottomPadding = 1; - - //清除段落段前段后间距 p.ParagraphFormat.SpaceBefore = 0; p.ParagraphFormat.SpaceAfter = 0; - cell.AppendChild(p); return cell; } + private string FormatDateStr(object objVal) + { + if (objVal == DBNull.Value || objVal == null || string.IsNullOrWhiteSpace(objVal.ToString())) + return ""; + DateTime dt; + if (DateTime.TryParse(objVal.ToString(), out dt)) + { + return dt.ToString("yyyy.MM.dd"); + } + return objVal.ToString(); + } #endregion } } \ No newline at end of file diff --git a/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineQualityCertificate2020.aspx b/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineQualityCertificate2020.aspx index 32310ba..2052046 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineQualityCertificate2020.aspx +++ b/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineQualityCertificate2020.aspx @@ -42,7 +42,7 @@ - + diff --git a/HJGL_DS/FineUIPro.Web/JGZL/ModRepairQualityCertificate.aspx b/HJGL_DS/FineUIPro.Web/JGZL/ModRepairQualityCertificate.aspx index 5b13c26..0259788 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/ModRepairQualityCertificate.aspx +++ b/HJGL_DS/FineUIPro.Web/JGZL/ModRepairQualityCertificate.aspx @@ -44,7 +44,7 @@ OnClick="btnSave_Click"> - + diff --git a/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx b/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx index 8e447b4..ba1d416 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx +++ b/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx @@ -43,7 +43,7 @@ OnClick="btnSave_Click"> <%----%> - +