diff --git a/HJGL_DS/BLL/Common/Const.cs b/HJGL_DS/BLL/Common/Const.cs index c208576..cd73d96 100644 --- a/HJGL_DS/BLL/Common/Const.cs +++ b/HJGL_DS/BLL/Common/Const.cs @@ -2435,5 +2435,27 @@ namespace BLL /// public static string TempFileTemplate = "TempFileTemplate"; #endregion + + #region 交工资料导出初始化路径 + /// + /// 封面导出模板 + /// + public const string JGZL_CoverUrl = "File\\Word\\JGZL\\封面导出模板.docx"; + + /// + /// 交工技术文件目录导出模板 + /// + public const string JGZL_FileDirectoryUrl = "File\\Word\\JGZL\\交工技术文件目录导出模板.docx"; + + /// + /// 交工技术文件说明导出模板 + /// + public const string JGZL_DocumentDescriptionUrl = "File\\Word\\JGZL\\交工技术文件说明导出模板.docx"; + + /// + /// 特种设备安装改造维修告知书导出模板 + /// + public const string JGZL_SpecialEquipmentMaintenanceUrl = "File\\Word\\JGZL\\特种设备安装改造维修告知书导出模板.docx"; + #endregion } } diff --git a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/交工技术文件目录.frx b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/交工技术文件目录.frx index 2f6d7dd..59cc317 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 } - + diff --git a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装汇总表.frx b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装汇总表.frx index 6a58f61..eb0bd35 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 } - + diff --git a/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装质量证明.frx b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/压力管道安装质量证明.frx index 9972f07..db5be7a 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/特种设备安装改造维修告知书.frx b/HJGL_DS/FineUIPro.Web/File/Fastreport/JGZL/特种设备安装改造维修告知书.frx index 977cc72..2526692 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 new file mode 100644 index 0000000..498defe --- /dev/null +++ b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/交工技术文件目录导出模板.docx @@ -0,0 +1,14 @@ + SH/T 3503 -- J103 + 交工技术文件目录 +工程名称: + +单位工程名称:管道安装工程 + 序号 + 文件编号 + 文件名称 + 页次 +编制人: +日期: 年 月 日 +审核人: +日期: 年 月 日 + diff --git a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/交工技术文件说明导出模板.docx b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/交工技术文件说明导出模板.docx new file mode 100644 index 0000000..a3fe723 --- /dev/null +++ b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/交工技术文件说明导出模板.docx @@ -0,0 +1,26 @@ + SH/T 3503 -- J104 + 交工技术文件说明 +工程名称: +一、工程概况: +二、编制依据 + +三、参建单位 +建设单位: +设计单位: +检测单位: +施工单位: +四、案卷构成及本卷册主要内容 + +五、编制份数 + + + + + +编制人: + +日期: 年 月 日 +审核人: + +日期: 年 月 日 + diff --git a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/封面导出模板.docx b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/封面导出模板.docx new file mode 100644 index 0000000..694afff --- /dev/null +++ b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/封面导出模板.docx @@ -0,0 +1,26 @@ + SH/T 3503 -- J101A + 封 面 +卷号: + + + + + + 石油化工建设工程项目交工技术文件 + + + +工程名称: + 卷 名:管道安装工程卷 + + + + + +建设单位 监理单位 施工单位 + (项目部章) (项目部章) (项目部章) + +项目经理: 项目总监: 项目经理: + + 年 月 日 年 月 日 年 月 日 + diff --git a/HJGL_DS/FineUIPro.Web/File/Word/JGZL/特种设备安装改造维修告知书导出模板.docx b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/特种设备安装改造维修告知书导出模板.docx new file mode 100644 index 0000000..61e4820 --- /dev/null +++ b/HJGL_DS/FineUIPro.Web/File/Word/JGZL/特种设备安装改造维修告知书导出模板.docx @@ -0,0 +1,53 @@ + 特种设备安装改造维修告知书 +施工单位: (公章) 告知书编号: + 设备名称 + + 型号(参数) + + 设备代码 + + 制造编号 + + 设备制造 + 单位全称 + + 制造许可证 + 编号 + + 设备地点 + + 施工日期 + + 施工单位全称 + + 施工类别 + + 许可证编号 + + 许可证有效期 + + 联系人 + + 电话 + + 传真 + + 地址 + + 邮编 + + 使用单位全称 + + 联系人 + + 电话 + + 传真 + + 地址 + + 邮编 + +注意事项 1:告知单按每台安装、改造、维修设备区分分别各填两份。 + 2:告知单编号为:制造单位设备编号+施工单位施工工号+年份(4位)。 + 3:施工类别按安装、改造、维修分别填写。 diff --git a/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj b/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj index 2cbb303..37d6f36 100644 --- a/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj +++ b/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj @@ -59,6 +59,9 @@ false + + ..\packages\Aspose.Words.21.8.0\lib\net461\Aspose.Words.dll + ..\packages\Portable.BouncyCastle.1.8.9\lib\net40\BouncyCastle.Crypto.dll diff --git a/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj.user b/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj.user index 80f7761..e3436b8 100644 --- a/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj.user +++ b/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj.user @@ -1,4 +1,4 @@ - + true diff --git a/HJGL_DS/FineUIPro.Web/Global.asax.cs b/HJGL_DS/FineUIPro.Web/Global.asax.cs index d5e8098..bc83077 100644 --- a/HJGL_DS/FineUIPro.Web/Global.asax.cs +++ b/HJGL_DS/FineUIPro.Web/Global.asax.cs @@ -47,6 +47,8 @@ System.Threading.Thread LoadServiceData = new System.Threading.Thread(new System.Threading.ThreadStart(WelderIsSync)); LoadServiceData.Start(); + //Aspose21.8.0破解注入 + new Aspose.Words.License().SetLicense(new System.IO.MemoryStream(Convert.FromBase64String("PExpY2Vuc2U+CiAgPERhdGE+CiAgICA8TGljZW5zZWRUbz5TdXpob3UgQXVuYm94IFNvZnR3YXJlIENvLiwgTHRkLjwvTGljZW5zZWRUbz4KICAgIDxFbWFpbFRvPnNhbGVzQGF1bnRlYy5jb208L0VtYWlsVG8+CiAgICA8TGljZW5zZVR5cGU+RGV2ZWxvcGVyIE9FTTwvTGljZW5zZVR5cGU+CiAgICA8TGljZW5zZU5vdGU+TGltaXRlZCB0byAxIGRldmVsb3BlciwgdW5saW1pdGVkIHBoeXNpY2FsIGxvY2F0aW9uczwvTGljZW5zZU5vdGU+CiAgICA8T3JkZXJJRD4yMDA2MDIwMTI2MzM8L09yZGVySUQ+CiAgICA8VXNlcklEPjEzNDk3NjAwNjwvVXNlcklEPgogICAgPE9FTT5UaGlzIGlzIGEgcmVkaXN0cmlidXRhYmxlIGxpY2Vuc2U8L09FTT4KICAgIDxQcm9kdWN0cz4KICAgICAgPFByb2R1Y3Q+QXNwb3NlLlRvdGFsIGZvciAuTkVUPC9Qcm9kdWN0PgogICAgPC9Qcm9kdWN0cz4KICAgIDxFZGl0aW9uVHlwZT5FbnRlcnByaXNlPC9FZGl0aW9uVHlwZT4KICAgIDxTZXJpYWxOdW1iZXI+OTM2ZTVmZDEtODY2Mi00YWJmLTk1YmQtYzhkYzBmNTNhZmE2PC9TZXJpYWxOdW1iZXI+CiAgICA8U3Vic2NyaXB0aW9uRXhwaXJ5PjIwMjEwODI3PC9TdWJzY3JpcHRpb25FeHBpcnk+CiAgICA8TGljZW5zZVZlcnNpb24+My4wPC9MaWNlbnNlVmVyc2lvbj4KICAgIDxMaWNlbnNlSW5zdHJ1Y3Rpb25zPmh0dHBzOi8vcHVyY2hhc2UuYXNwb3NlLmNvbS9wb2xpY2llcy91c2UtbGljZW5zZTwvTGljZW5zZUluc3RydWN0aW9ucz4KICA8L0RhdGE+CiAgPFNpZ25hdHVyZT5wSkpjQndRdnYxV1NxZ1kyOHFJYUFKSysvTFFVWWRrQ2x5THE2RUNLU0xDQ3dMNkEwMkJFTnh5L3JzQ1V3UExXbjV2bTl0TDRQRXE1aFAzY2s0WnhEejFiK1JIWTBuQkh1SEhBY01TL1BSeEJES0NGbWg1QVFZRTlrT0FxSzM5NVBSWmJRSGowOUNGTElVUzBMdnRmVkp5cUhjblJvU3dPQnVqT1oyeDc4WFE9PC9TaWduYXR1cmU+CjwvTGljZW5zZT4="))); } private void WelderIsSync() diff --git a/HJGL_DS/FineUIPro.Web/JGZL/Cover.aspx b/HJGL_DS/FineUIPro.Web/JGZL/Cover.aspx index d55d069..16540f8 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/Cover.aspx +++ b/HJGL_DS/FineUIPro.Web/JGZL/Cover.aspx @@ -42,6 +42,9 @@ + + diff --git a/HJGL_DS/FineUIPro.Web/JGZL/Cover.aspx.cs b/HJGL_DS/FineUIPro.Web/JGZL/Cover.aspx.cs index 85052b9..22b5bfb 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/Cover.aspx.cs +++ b/HJGL_DS/FineUIPro.Web/JGZL/Cover.aspx.cs @@ -1,13 +1,11 @@ -using BLL; +using Aspose.Words; +using BLL; using System; using System.Collections.Generic; -using System.Data.SqlClient; using System.Data; -using System.Linq; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; +using System.Data.SqlClient; using System.IO; +using System.Linq; namespace FineUIPro.Web.JGZL { @@ -99,7 +97,7 @@ namespace FineUIPro.Web.JGZL { strSql += " AND ProjectId = @ProjectId"; listStr.Add(new SqlParameter("@ProjectId", this.tvControlItem.SelectedNodeID)); - } + } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); // 2.获取当前分页数据 @@ -166,5 +164,73 @@ namespace FineUIPro.Web.JGZL } } #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; + + string projectId = this.tvControlItem.SelectedNodeID; + if (!string.IsNullOrEmpty(projectId)) + { + if (!string.IsNullOrEmpty(this.Grid1.SelectedRowID)) + { + initTemplatePath = Const.JGZL_CoverUrl; + uploadfilepath = rootPath + initTemplatePath; + + newUrl = uploadfilepath.Replace("封面导出模板", "封面"); + if (File.Exists(newUrl)) + { + File.Delete(newUrl); + } + File.Copy(uploadfilepath, newUrl); + Document doc = new Aspose.Words.Document(uploadfilepath); + + Bookmark code = doc.Range.Bookmarks["Code"]; + if (code != null) + { + code.Text = this.txtCode.Text.Trim(); + } + + Bookmark projectName = doc.Range.Bookmarks["ProjectName"]; + if (projectName != null) + { + projectName.Text = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName; + } + 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; + } + } + #endregion } } \ No newline at end of file diff --git a/HJGL_DS/FineUIPro.Web/JGZL/Cover.aspx.designer.cs b/HJGL_DS/FineUIPro.Web/JGZL/Cover.aspx.designer.cs index ef59409..c3555c1 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/Cover.aspx.designer.cs +++ b/HJGL_DS/FineUIPro.Web/JGZL/Cover.aspx.designer.cs @@ -122,6 +122,15 @@ namespace FineUIPro.Web.JGZL /// protected global::FineUIPro.Button btnPrint; + /// + /// btnOut 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnOut; + /// /// Grid1 控件。 /// diff --git a/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx b/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx index 19e82ea..a99b9f4 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx +++ b/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx @@ -44,6 +44,9 @@ + + @@ -80,7 +83,7 @@ - + diff --git a/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx.cs b/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx.cs index c296d82..2a0bcc0 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx.cs +++ b/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx.cs @@ -10,6 +10,7 @@ using System.Web.UI.WebControls; using static System.Windows.Forms.VisualStyles.VisualStyleElement; using System.IO; using Microsoft.SqlServer.Server; +using Aspose.Words; namespace FineUIPro.Web.JGZL { @@ -41,7 +42,7 @@ namespace FineUIPro.Web.JGZL protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) - { + { this.drpProjectId.DataTextField = "ProjectCode"; this.drpProjectId.DataValueField = "ProjectId"; this.drpProjectId.DataSource = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1"); @@ -144,7 +145,7 @@ namespace FineUIPro.Web.JGZL { this.DocumentDescriptionId = report.DocumentDescriptionId; this.txtProjectOverview.Text = report.ProjectOverview; - if(!string.IsNullOrEmpty(report.ConstructionUnit)) + if (!string.IsNullOrEmpty(report.ConstructionUnit)) { this.txtConstructionUnit.Text = report.ConstructionUnit; } @@ -152,7 +153,7 @@ namespace FineUIPro.Web.JGZL { this.txtConstructionUnit.Text = "浙江石油化工有限公司"; } - + this.txtDesigningUnit.Text = report.DesigningUnit; this.txtTestingUnit.Text = report.TestingUnit; if (!string.IsNullOrEmpty(report.ConstructionCompany)) @@ -216,7 +217,7 @@ namespace FineUIPro.Web.JGZL newDocumentDescription.DesigningUnit = this.txtDesigningUnit.Text; newDocumentDescription.TestingUnit = this.txtTestingUnit.Text; newDocumentDescription.ConstructionCompany = this.txtConstructionCompany.Text; - newDocumentDescription.CompilationBasis=this.txtCompilationBasis.Text; + newDocumentDescription.CompilationBasis = this.txtCompilationBasis.Text; newDocumentDescription.MainContent = this.txtMainContent.Text; newDocumentDescription.CopiesNum = this.txtCopiesNum.Text; if (!string.IsNullOrEmpty(this.DocumentDescriptionId)) @@ -286,5 +287,98 @@ namespace FineUIPro.Web.JGZL } #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; + + string projectId = this.tvControlItem.SelectedNodeID; + if (!string.IsNullOrEmpty(projectId)) + { + initTemplatePath = Const.JGZL_DocumentDescriptionUrl; + uploadfilepath = rootPath + initTemplatePath; + + newUrl = uploadfilepath.Replace("交工技术文件说明导出模板", "交工技术文件说明"); + if (File.Exists(newUrl)) + { + File.Delete(newUrl); + } + File.Copy(uploadfilepath, newUrl); + Document doc = new Aspose.Words.Document(uploadfilepath); + + Bookmark projectName = doc.Range.Bookmarks["ProjectName"]; + if (projectName != null) + { + projectName.Text = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName; + } + Bookmark projectOverview = doc.Range.Bookmarks["ProjectOverview"]; + if (projectOverview != null) + { + projectOverview.Text = this.txtProjectOverview.Text; + } + Bookmark compilationBasis = doc.Range.Bookmarks["CompilationBasis"]; + if (compilationBasis != null) + { + compilationBasis.Text = this.txtCompilationBasis.Text; + } + Bookmark constructionUnit = doc.Range.Bookmarks["ConstructionUnit"]; + if (constructionUnit != null) + { + constructionUnit.Text = this.txtConstructionUnit.Text; + } + Bookmark designingUnit = doc.Range.Bookmarks["DesigningUnit"]; + if (designingUnit != null) + { + designingUnit.Text = this.txtDesigningUnit.Text; + } + Bookmark testingUnit = doc.Range.Bookmarks["TestingUnit"]; + if (testingUnit != null) + { + testingUnit.Text = this.txtTestingUnit.Text; + } + Bookmark constructionCompany = doc.Range.Bookmarks["ConstructionCompany"]; + if (constructionCompany != null) + { + constructionCompany.Text = this.txtConstructionCompany.Text; + } + Bookmark mainContent = doc.Range.Bookmarks["MainContent"]; + if (mainContent != null) + { + mainContent.Text = this.txtMainContent.Text; + } + Bookmark copiesNum = doc.Range.Bookmarks["CopiesNum"]; + if (copiesNum != null) + { + copiesNum.Text = this.txtCopiesNum.Text; + } + 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; + } + } + #endregion } } \ No newline at end of file diff --git a/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx.designer.cs b/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx.designer.cs index 3dae246..e6e2da7 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx.designer.cs +++ b/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx.designer.cs @@ -122,6 +122,15 @@ namespace FineUIPro.Web.JGZL /// protected global::FineUIPro.Button btnPrint; + /// + /// btnOut 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnOut; + /// /// SimpleForm1 控件。 /// diff --git a/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx b/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx index 5cfbb7c..9a84f19 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx +++ b/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx @@ -41,6 +41,9 @@ + + diff --git a/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx.cs b/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx.cs index 9502f3a..591ecb6 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx.cs +++ b/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx.cs @@ -1,13 +1,16 @@ -using BLL; +using Aspose.Words; +using Aspose.Words.Layout; +using Aspose.Words.Tables; +using BLL; using System; using System.Collections.Generic; -using System.Data.SqlClient; using System.Data; +using System.Data.SqlClient; +using System.IO; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; -using System.IO; namespace FineUIPro.Web.JGZL { @@ -291,5 +294,165 @@ namespace FineUIPro.Web.JGZL } } #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 = 36; + + string projectId = this.tvControlItem.SelectedNodeID; + if (!string.IsNullOrEmpty(projectId)) + { + string strSql = @"SELECT * from JGZL_FileDirectory order by SerialNumber asc"; + List listStr = new List(); + //listStr.Add(new SqlParameter("@ProjectId", projectId)); + SqlParameter[] parameter = listStr.ToArray(); + DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); + + initTemplatePath = Const.JGZL_FileDirectoryUrl; + 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); + + Bookmark projectName = doc.Range.Bookmarks["ProjectName"]; + if (projectName != null) + { + projectName.Text = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName; + } + + // 设置表头行重复显示 + table.Rows[0].RowFormat.HeadingFormat = true; + table.Rows[1].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++) + { + //创建行 + Row row = new Row(doc); + 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, "", "")); + row.Cells.Add(CreateCell(tb.Rows[i]["Remark"].ToString(), doc, 74, "", "")); + table.Rows.Insert(i + 2, 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++) + { + Row blankRow = new Row(doc); + // 空白行的单元格宽度和数据行保持一致 + blankRow.Cells.Add(CreateCell("", doc, 27, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 118, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 261.3, "", "")); + blankRow.Cells.Add(CreateCell("", doc, 74, "", "")); + // 插入到表格最后一行 + 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; + } + } + + 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(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(CenterPage)) + { + //序号 + value = " " + value; + } + if (!string.IsNullOrEmpty(cellUnitLeft)) + { + p.ParagraphFormat.Alignment = ParagraphAlignment.Left;//表格中字体居左 + } + else + { + p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//表格中字体居中 + } + + + p.AppendChild(new Run(doc, value)); + + cell.CellFormat.Width = cellWidth; + + cell.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center; + + cell.CellFormat.Borders.LineWidth = 0.75; + + cell.AppendChild(p); + return cell; + } + + #endregion } } \ No newline at end of file diff --git a/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx.designer.cs b/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx.designer.cs index 33d6fc1..266988d 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx.designer.cs +++ b/HJGL_DS/FineUIPro.Web/JGZL/FileDirectory.aspx.designer.cs @@ -113,6 +113,15 @@ namespace FineUIPro.Web.JGZL /// protected global::FineUIPro.Button btnPrint; + /// + /// btnOut 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnOut; + /// /// Grid1 控件。 /// diff --git a/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx b/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx index 21d13a4..8e447b4 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx +++ b/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx @@ -39,12 +39,15 @@ - - + + <%----%> + + @@ -53,9 +56,9 @@ runat="server" RedStarPosition="BeforeText" LabelAlign="Right"> - + - + diff --git a/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx.cs b/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx.cs index 327933b..26cd9e9 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx.cs +++ b/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx.cs @@ -9,6 +9,7 @@ using System.Web.UI; using System.Web.UI.WebControls; using System.IO; using FineUIPro.Web.common.BaseInfo; +using Aspose.Words; namespace FineUIPro.Web.JGZL { @@ -691,5 +692,177 @@ namespace FineUIPro.Web.JGZL } } #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; + + string projectId = this.tvControlItem.SelectedNodeID; + if (!string.IsNullOrEmpty(projectId)) + { + initTemplatePath = Const.JGZL_SpecialEquipmentMaintenanceUrl; + uploadfilepath = rootPath + initTemplatePath; + + newUrl = uploadfilepath.Replace("特种设备安装改造维修告知书导出模板", "特种设备安装改造维修告知书"); + if (File.Exists(newUrl)) + { + File.Delete(newUrl); + } + File.Copy(uploadfilepath, newUrl); + Document doc = new Aspose.Words.Document(uploadfilepath); + + Bookmark conUnit = doc.Range.Bookmarks["ConUnit"]; + if (conUnit != null) + { + conUnit.Text = this.txtConUnit.Text.Trim(); + } + Bookmark maintenanceCode = doc.Range.Bookmarks["MaintenanceCode"]; + if (maintenanceCode != null) + { + maintenanceCode.Text = this.txtMaintenanceCode.Text.Trim(); + } + Bookmark equipmentName = doc.Range.Bookmarks["EquipmentName"]; + if (equipmentName != null) + { + equipmentName.Text = this.txtEquipmentName.Text.Trim(); + } + Bookmark equipmentModel = doc.Range.Bookmarks["EquipmentModel"]; + if (equipmentModel != null) + { + equipmentModel.Text = this.txtEquipmentModel.Text.Trim(); + } + Bookmark equipmentCode = doc.Range.Bookmarks["EquipmentCode"]; + if (equipmentCode != null) + { + equipmentCode.Text = this.txtEquipmentCode.Text.Trim(); + } + Bookmark manufacturingNumber = doc.Range.Bookmarks["ManufacturingNumber"]; + if (manufacturingNumber != null) + { + manufacturingNumber.Text = this.txtManufacturingNumber.Text.Trim(); + } + Bookmark manufacturingUnit = doc.Range.Bookmarks["ManufacturingUnit"]; + if (manufacturingUnit != null) + { + manufacturingUnit.Text = this.txtManufacturingUnit.Text.Trim(); + } + Bookmark manufacturingLicenseNumber = doc.Range.Bookmarks["ManufacturingLicenseNumber"]; + if (manufacturingLicenseNumber != null) + { + manufacturingLicenseNumber.Text = this.txtManufacturingLicenseNumber.Text.Trim(); + } + Bookmark equipmentLocation = doc.Range.Bookmarks["EquipmentLocation"]; + if (equipmentLocation != null) + { + equipmentLocation.Text = this.txtEquipmentLocation.Text.Trim(); + } + Bookmark constructionDate = doc.Range.Bookmarks["ConstructionDate"]; + if (constructionDate != null) + { + string d = string.Format("{0:yyyy年MM月dd}", this.txtConstructionDate.Text); + constructionDate.Text = d; + } + Bookmark constructionCategory = doc.Range.Bookmarks["ConstructionCategory"]; + if (constructionCategory != null) + { + constructionCategory.Text = this.drpConstructionCategory.SelectedText; + } + Bookmark licenseNumber = doc.Range.Bookmarks["LicenseNumber"]; + if (licenseNumber != null) + { + licenseNumber.Text = this.txtLicenseNumber.Text.Trim(); + } + Bookmark licenseValidityDate = doc.Range.Bookmarks["LicenseValidityDate"]; + if (licenseValidityDate != null) + { + string d = string.Format("{0:yyyy年MM月dd}", this.txtLicenseValidityDate.Text); + licenseValidityDate.Text = d; + } + Bookmark conContactMan = doc.Range.Bookmarks["ConContactMan"]; + if (conContactMan != null) + { + conContactMan.Text = this.txtConContactMan.Text.Trim(); + } + Bookmark conTelephone = doc.Range.Bookmarks["ConTelephone"]; + if (conTelephone != null) + { + conTelephone.Text = this.txtConTelephone.Text.Trim(); + } + Bookmark conFax = doc.Range.Bookmarks["ConFax"]; + if (conFax != null) + { + conFax.Text = this.txtConFax.Text.Trim(); + } + Bookmark conAddress = doc.Range.Bookmarks["ConAddress"]; + if (conAddress != null) + { + conAddress.Text = this.txtConAddress.Text.Trim(); + } + Bookmark conEmail = doc.Range.Bookmarks["ConEmail"]; + if (conEmail != null) + { + conEmail.Text = this.txtConEmail.Text.Trim(); + } + Bookmark useUnit = doc.Range.Bookmarks["UseUnit"]; + if (useUnit != null) + { + useUnit.Text = this.txtUseUnit.Text.Trim(); + } + Bookmark useContactMan = doc.Range.Bookmarks["UseContactMan"]; + if (useContactMan != null) + { + useContactMan.Text = this.txtUseContactMan.Text.Trim(); + } + Bookmark useTelephone = doc.Range.Bookmarks["UseTelephone"]; + if (useTelephone != null) + { + useTelephone.Text = this.txtUseTelephone.Text.Trim(); + } + Bookmark useFax = doc.Range.Bookmarks["UseFax"]; + if (useFax != null) + { + useFax.Text = this.txtUseFax.Text.Trim(); + } + Bookmark useAddress = doc.Range.Bookmarks["UseAddress"]; + if (useAddress != null) + { + useAddress.Text = this.txtUseAddress.Text.Trim(); + } + Bookmark useEmail = doc.Range.Bookmarks["UseEmail"]; + if (useEmail != null) + { + useEmail.Text = this.txtUseEmail.Text.Trim(); + } + 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; + } + } + #endregion } } \ No newline at end of file diff --git a/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx.designer.cs b/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx.designer.cs index c1eb7b8..2eb6c1f 100644 --- a/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx.designer.cs +++ b/HJGL_DS/FineUIPro.Web/JGZL/SpecialEquipmentMaintenance.aspx.designer.cs @@ -122,6 +122,15 @@ namespace FineUIPro.Web.JGZL /// protected global::FineUIPro.Button btnPrint; + /// + /// btnOut 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnOut; + /// /// SimpleForm1 控件。 /// diff --git a/HJGL_DS/FineUIPro.Web/Welder/WelderManage.aspx.cs b/HJGL_DS/FineUIPro.Web/Welder/WelderManage.aspx.cs index 93db372..5d0b063 100644 --- a/HJGL_DS/FineUIPro.Web/Welder/WelderManage.aspx.cs +++ b/HJGL_DS/FineUIPro.Web/Welder/WelderManage.aspx.cs @@ -743,7 +743,7 @@ namespace FineUIPro.Web.Welder { foreach (var q in quas) { - if (q.MIDWelder_QualifiedProjectCode.Contains("+") || q.MIDWelder_QualifiedProjectCode.Contains("+")) + if (q.MIDWelder_QualifiedProjectCode.Contains("+") || q.MIDWelder_QualifiedProjectCode.Contains("+")|| q.MIDWelder_QualifiedProjectCode.Contains("和")) { string[] codes = null; if (q.MIDWelder_QualifiedProjectCode.Contains("+")) @@ -754,13 +754,15 @@ namespace FineUIPro.Web.Welder { codes = q.MIDWelder_QualifiedProjectCode.Split('+'); } - + if (q.MIDWelder_QualifiedProjectCode.Contains("和")) + { + codes = q.MIDWelder_QualifiedProjectCode.Split('和'); + } foreach (string c in codes) { var oldCode = from x in Funs.DB.HJGL_BS_WelderQualifiedProject where x.WED_ID == wederId && x.QualifiedProjectCode == c && x.LimitDate.Value.Date == q.MIDWelder_LimitDate.Value.Date select x; if (oldCode.Count() == 0) { - Model.HJGL_BS_WelderQualifiedProject welderQualifiedProject = new Model.HJGL_BS_WelderQualifiedProject(); welderQualifiedProject.WelderQualifiedProjectId = SQLHelper.GetNewID(typeof(Model.HJGL_BS_WelderQualifiedProject)); welderQualifiedProject.WED_ID = wederId; diff --git a/HJGL_DS/FineUIPro.Web/packages.config b/HJGL_DS/FineUIPro.Web/packages.config index 70c9fa9..af1cbf5 100644 --- a/HJGL_DS/FineUIPro.Web/packages.config +++ b/HJGL_DS/FineUIPro.Web/packages.config @@ -1,5 +1,6 @@  + diff --git a/HJGL_DS/WebAPI/WebAPI.csproj.user b/HJGL_DS/WebAPI/WebAPI.csproj.user index 28be9c4..8cd7f1f 100644 --- a/HJGL_DS/WebAPI/WebAPI.csproj.user +++ b/HJGL_DS/WebAPI/WebAPI.csproj.user @@ -1,4 +1,4 @@ - + Release|Any CPU