20260408 交工资料导出
This commit is contained in:
@@ -2544,6 +2544,11 @@ namespace BLL
|
||||
/// </summary>
|
||||
public const string JGZL_QualifiedWelderUrl = "File\\Word\\JGZL\\合格焊工登记表导出模板.docx";
|
||||
|
||||
/// <summary>
|
||||
/// 管道系统压力试验条件确认记录导出模板
|
||||
/// </summary>
|
||||
public const string JGZL_PressureTestOfPipelineSystemConfirmationRecordUrl = "File\\Word\\JGZL\\管道系统压力试验条件确认记录导出模板.docx";
|
||||
|
||||
/// <summary>
|
||||
/// 工序交接记录导出模板
|
||||
/// </summary>
|
||||
@@ -2574,6 +2579,11 @@ namespace BLL
|
||||
/// 隔热工程质量验收记录导出模板
|
||||
/// </summary>
|
||||
public const string JGZL_InsulationAcceptanceRecordUrl = "File\\Word\\JGZL\\隔热工程质量验收记录导出模板.docx";
|
||||
|
||||
/// <summary>
|
||||
/// 档案资料移交表导出模板
|
||||
/// </summary>
|
||||
public const string JGZL_ArchivalTransferUrl = "File\\Word\\JGZL\\档案资料移交表导出模板.docx";
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -44,6 +44,9 @@
|
||||
</f:Button>
|
||||
<f:Button ID="btnPrint" Text="档案移交表打印" Icon="Printer" runat="server" OnClick="btnPrint_Click">
|
||||
</f:Button>
|
||||
<f:Button ID="btnOut" OnClick="btnOut_Click" runat="server" Text="导出" ToolTip="导出Word" Icon="FolderUp"
|
||||
EnableAjax="false" DisableControlBeforePostBack="false">
|
||||
</f:Button>
|
||||
</Items>
|
||||
</f:Toolbar>
|
||||
</Toolbars>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BLL;
|
||||
using Aspose.Words;
|
||||
using BLL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -261,5 +262,79 @@ namespace FineUIPro.Web.JGZL
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 导出按钮
|
||||
/// 导出按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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_ArchivalTransferUrl;
|
||||
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 projectCode = doc.Range.Bookmarks["ProjectCode"];
|
||||
if (projectCode != null)
|
||||
{
|
||||
projectCode.Text = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectCode;
|
||||
}
|
||||
Bookmark transferringDepart = doc.Range.Bookmarks["TransferringDepart"];
|
||||
if (transferringDepart != null)
|
||||
{
|
||||
transferringDepart.Text = this.txtTransferringDepart.Text.Trim();
|
||||
}
|
||||
Bookmark fileNames = doc.Range.Bookmarks["FileName"];
|
||||
if (fileNames != null)
|
||||
{
|
||||
fileNames.Text = this.txtFileName.Text.Trim();
|
||||
}
|
||||
Bookmark quantity = doc.Range.Bookmarks["Quantity"];
|
||||
if (quantity != null)
|
||||
{
|
||||
quantity.Text = this.txtQuantity.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
|
||||
}
|
||||
}
|
||||
@@ -122,6 +122,15 @@ namespace FineUIPro.Web.JGZL
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Button btnPrint;
|
||||
|
||||
/// <summary>
|
||||
/// btnOut 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Button btnOut;
|
||||
|
||||
/// <summary>
|
||||
/// SimpleForm1 控件。
|
||||
/// </summary>
|
||||
|
||||
@@ -44,6 +44,9 @@
|
||||
<%--<f:Button ID="btnAdd" runat="server" Icon="Add" Text="增加" OnClick="btnAdd_Click"></f:Button>--%>
|
||||
<f:Button ID="btnPrint" Text="管道系统压力试验条件确认记录打印" Icon="Printer" runat="server" OnClick="btnPrint_Click">
|
||||
</f:Button>
|
||||
<f:Button ID="btnOut" OnClick="btnOut_Click" runat="server" Text="导出" ToolTip="导出Word" Icon="FolderUp"
|
||||
EnableAjax="false" DisableControlBeforePostBack="false">
|
||||
</f:Button>
|
||||
</Items>
|
||||
</f:Toolbar>
|
||||
</Toolbars>
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Data;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Aspose.Words;
|
||||
|
||||
namespace FineUIPro.Web.JGZL
|
||||
{
|
||||
@@ -98,7 +99,7 @@ namespace FineUIPro.Web.JGZL
|
||||
{
|
||||
this.txtSystemName.Text = "材质";
|
||||
}
|
||||
this.txtRemark.Text = record.Remark;
|
||||
this.txtRemark.Text = record.Remark;
|
||||
BindGrid();
|
||||
}
|
||||
else
|
||||
@@ -280,7 +281,7 @@ namespace FineUIPro.Web.JGZL
|
||||
{
|
||||
var record = BLL.PressureTestOfPipelineSystemConfirmationRecordService.GetPressureTestOfPipelineSystemConfirmationRecordByProjectId(this.tvControlItem.SelectedNodeID);
|
||||
if (record != null)
|
||||
{
|
||||
{
|
||||
this.BindGrid();
|
||||
}
|
||||
else
|
||||
@@ -689,5 +690,133 @@ namespace FineUIPro.Web.JGZL
|
||||
}
|
||||
this.txtSystemName.Text = serName;
|
||||
}
|
||||
|
||||
#region 导出按钮
|
||||
/// 导出按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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_PressureTestOfPipelineSystemConfirmationRecordUrl;
|
||||
uploadfilepath = rootPath + initTemplatePath;
|
||||
|
||||
newUrl = uploadfilepath.Replace("管道系统压力试验条件确认记录导出模板", "管道系统压力试验条件确认记录");
|
||||
if (File.Exists(newUrl))
|
||||
{
|
||||
File.Delete(newUrl);
|
||||
}
|
||||
File.Copy(uploadfilepath, newUrl);
|
||||
Document doc = new Aspose.Words.Document(uploadfilepath);
|
||||
|
||||
var report = (from x in Funs.DB.JGZL_PressureTestOfPipelineSystemConfirmationRecord where x.ProjectId == projectId select x);
|
||||
if (report != null)
|
||||
{
|
||||
Bookmark projectName = doc.Range.Bookmarks["ProjectName"];
|
||||
if (projectName != null)
|
||||
{
|
||||
projectName.Text = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName;
|
||||
}
|
||||
Bookmark systemName = doc.Range.Bookmarks["SystemName"];
|
||||
if (systemName != null)
|
||||
{
|
||||
systemName.Text = report.FirstOrDefault().SystemName;
|
||||
}
|
||||
Bookmark systemCode = doc.Range.Bookmarks["SystemCode"];
|
||||
if (systemCode != null)
|
||||
{
|
||||
systemCode.Text = report.FirstOrDefault().SystemCode;
|
||||
}
|
||||
Bookmark checkItem1 = doc.Range.Bookmarks["CheckItem1"];
|
||||
if (checkItem1 != null)
|
||||
{
|
||||
checkItem1.Text = report.Where(x => x.CheckItem1 == "01").FirstOrDefault().CheckItem3;
|
||||
}
|
||||
Bookmark checkItem2 = doc.Range.Bookmarks["CheckItem2"];
|
||||
if (checkItem2 != null)
|
||||
{
|
||||
checkItem2.Text = report.Where(x => x.CheckItem1 == "02").FirstOrDefault().CheckItem3;
|
||||
}
|
||||
Bookmark checkItem3 = doc.Range.Bookmarks["CheckItem3"];
|
||||
if (checkItem3 != null)
|
||||
{
|
||||
checkItem3.Text = report.Where(x => x.CheckItem1 == "03").FirstOrDefault().CheckItem3;
|
||||
}
|
||||
Bookmark checkItem4 = doc.Range.Bookmarks["CheckItem4"];
|
||||
if (checkItem4 != null)
|
||||
{
|
||||
checkItem4.Text = report.Where(x => x.CheckItem1 == "04").FirstOrDefault().CheckItem3;
|
||||
}
|
||||
Bookmark checkItem5 = doc.Range.Bookmarks["CheckItem5"];
|
||||
if (checkItem5 != null)
|
||||
{
|
||||
checkItem5.Text = report.Where(x => x.CheckItem1 == "05").FirstOrDefault().CheckItem3;
|
||||
}
|
||||
Bookmark checkItem6 = doc.Range.Bookmarks["CheckItem6"];
|
||||
if (checkItem6 != null)
|
||||
{
|
||||
checkItem6.Text = report.Where(x => x.CheckItem1 == "06").FirstOrDefault().CheckItem3;
|
||||
}
|
||||
Bookmark checkItem7 = doc.Range.Bookmarks["CheckItem7"];
|
||||
if (checkItem7 != null)
|
||||
{
|
||||
checkItem7.Text = report.Where(x => x.CheckItem1 == "07").FirstOrDefault().CheckItem3;
|
||||
}
|
||||
Bookmark checkItem8 = doc.Range.Bookmarks["CheckItem8"];
|
||||
if (checkItem8 != null)
|
||||
{
|
||||
checkItem8.Text = report.Where(x => x.CheckItem1 == "08").FirstOrDefault().CheckItem3;
|
||||
}
|
||||
Bookmark checkItem9 = doc.Range.Bookmarks["CheckItem9"];
|
||||
if (checkItem9 != null)
|
||||
{
|
||||
checkItem9.Text = report.Where(x => x.CheckItem1 == "09").FirstOrDefault().CheckItem3;
|
||||
}
|
||||
Bookmark checkItem10 = doc.Range.Bookmarks["CheckItem10"];
|
||||
if (checkItem10 != null)
|
||||
{
|
||||
checkItem10.Text = report.Where(x => x.CheckItem1 == "10").FirstOrDefault().CheckItem3;
|
||||
}
|
||||
Bookmark checkItem11 = doc.Range.Bookmarks["CheckItem11"];
|
||||
if (checkItem11 != null)
|
||||
{
|
||||
checkItem11.Text = report.Where(x => x.CheckItem1 == "11").FirstOrDefault().CheckItem3;
|
||||
}
|
||||
Bookmark checkItem12 = doc.Range.Bookmarks["CheckItem12"];
|
||||
if (checkItem12 != null)
|
||||
{
|
||||
checkItem12.Text = report.Where(x => x.CheckItem1 == "12").FirstOrDefault().CheckItem3;
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
Generated
+9
@@ -131,6 +131,15 @@ namespace FineUIPro.Web.JGZL
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Button btnPrint;
|
||||
|
||||
/// <summary>
|
||||
/// btnOut 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Button btnOut;
|
||||
|
||||
/// <summary>
|
||||
/// Toolbar4 控件。
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user