Files
HJGL_DS/HJGL_DS/FineUIPro.Web/JGZL/IndustrialPipelineQualityCertificate2020.aspx.cs
T
2026-10-09 16:48:18 +08:00

548 lines
27 KiB
C#

using Aspose.Words;
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.JGZL
{
public partial class IndustrialPipelineQualityCertificate2020 : PageBase
{
#region 定义变量
/// <summary>
/// 主键
/// </summary>
private string CertificateId
{
get
{
return (string)ViewState["CertificateId"];
}
set
{
ViewState["CertificateId"] = value;
}
}
#endregion
#region 加载页面
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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");
this.drpProjectId.DataBind();
Funs.FineUIPleaseSelect(this.drpProjectId);
this.drpProjectId.SelectedValue = this.CurrUser.LoginProjectId;
this.InitTreeMenu();//加载树
this.tvControlItem.SelectedNodeID = this.drpProjectId.SelectedValue;
//管道类别
this.drpPipelineLevel.DataTextField = "ISC_IsoName";
this.drpPipelineLevel.DataValueField = "ISC_IsoName";
this.drpPipelineLevel.DataSource = BLL.HJGL_PW_IsoInfoService.GetPipelineLevelList(this.drpProjectId.SelectedValue);
this.drpPipelineLevel.DataBind();
PageData();
}
}
private void EmptyText()
{
txtCertificateCode.Text = string.Empty;
txtDeliveryUnit.Text = string.Empty;
txtDeliveryUnitCode.Text = string.Empty;
txtInstallStartDate.Text = string.Empty;
txtInstallEndDate.Text = string.Empty;
drpPipelineLevel.SelectedValue = BLL.Const._Null;
this.txtPipelineLength.Text = string.Empty;
txtDesignUnit.Text = string.Empty;
txtDesignLicenseCode.Text = string.Empty;
txtSupervisoryAndInspectionAgency.Text = string.Empty;
txtQualificationCertificateCode.Text = string.Empty;
txtLosslessTestingAgency.Text = string.Empty;
txtInstitutionalApprovalCertificate.Text = string.Empty;
txtInstallationInspection.Text = string.Empty;
txtConstructionUnit.Text = string.Empty;
txtSpecialEquipmentProductionLicenseCode.Text = string.Empty;
drpRemark.SelectedValue = string.Empty;
}
private void PageData()
{
EmptyText();
string projectId = this.tvControlItem.SelectedNodeID;
if (!string.IsNullOrEmpty(projectId))
{
var pro = BLL.Base_ProjectService.GetProjectByProjectId(projectId);
if (pro != null)
{
var report = BLL.IndustrialPipelineInstallationQualityCertificateService.GetIndustrialPipelineInstallationQualityCertificateByProjectId(projectId, "2");
if (report != null)
{
this.CertificateId = report.CertificateId;
this.txtCertificateCode.Text = report.CertificateCode;
this.txtDeliveryUnit.Text = report.DeliveryUnit;
this.txtDeliveryUnitCode.Text = report.DeliveryUnitCode;
this.txtInstallStartDate.Text = report.InstallStartDate.HasValue ? string.Format("{0:yyyy年MM月dd日}", report.InstallStartDate) : "";
this.txtInstallEndDate.Text = report.InstallEndDate.HasValue ? string.Format("{0:yyyy年MM月dd日}", report.InstallEndDate) : "";
if (!string.IsNullOrEmpty(report.PipelineLevel))
{
this.drpPipelineLevel.SelectedValue = report.PipelineLevel;
}
this.txtPipelineLength.Text = report.PipelineLength;
this.txtDesignUnit.Text = report.DesignUnit;
this.txtDesignLicenseCode.Text = report.DesignLicenseCode;
this.txtSupervisoryAndInspectionAgency.Text = report.SupervisoryAndInspectionAgency;
this.txtQualificationCertificateCode.Text = report.QualificationCertificateCode;
this.txtLosslessTestingAgency.Text = report.LosslessTestingAgency;
this.txtInstitutionalApprovalCertificate.Text = report.InstitutionalApprovalCertificate;
if (!string.IsNullOrEmpty(report.InstallationInspection))
{
this.txtInstallationInspection.Text = report.InstallationInspection;
}
else
{
this.txtInstallationInspection.Text = "浙江省特种设备科学研究院";
}
if (!string.IsNullOrEmpty(report.ConstructionUnit))
{
this.txtConstructionUnit.Text = report.ConstructionUnit;
}
else
{
this.txtConstructionUnit.Text = "浙江石油化工有限公司";
}
if (!string.IsNullOrEmpty(report.Remark))
{
this.drpRemark.SelectedValue = report.Remark;
}
if (!string.IsNullOrEmpty(report.SpecialEquipmentProductionLicenseCode))
{
this.txtSpecialEquipmentProductionLicenseCode.Text = report.SpecialEquipmentProductionLicenseCode;
}
else
{
this.txtSpecialEquipmentProductionLicenseCode.Text = "TS3833339-2028";
}
}
else
{
this.CertificateId = string.Empty;
this.txtCertificateCode.Text = "0XXX-31330921MA2A2R3F6G-" + DateTime.Now.Year;
var insta = (from x in Funs.DB.Project_Installation where x.ProjectId == this.CurrUser.LoginProjectId select x).FirstOrDefault();
if (insta != null)
{
this.txtDeliveryUnit.Text = insta.InstallationName;
this.txtDeliveryUnitCode.Text = insta.InstallationCode;
}
this.txtInstallationInspection.Text = "浙江省特种设备科学研究院";
this.txtConstructionUnit.Text = "浙江石油化工有限公司";
this.txtSpecialEquipmentProductionLicenseCode.Text = "TS3833339-2028";
var pipeLineLength = BLL.HJGL_PW_IsoInfoService.GetPipeLineLengthList(this.tvControlItem.SelectedNodeID);
if (pipeLineLength != null)
{
this.txtPipelineLength.Text = pipeLineLength.Value.ToString(".##");
}
}
}
}
}
#endregion
#region 加载树项目
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "项目";
rootNode.ToolTip = "项目";
rootNode.NodeID = "0";
rootNode.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode);
List<Model.Base_Project> projects = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
if (this.drpProjectId.SelectedValue != BLL.Const._Null)
{
projects = projects.Where(e => e.ProjectId == this.drpProjectId.SelectedValue).ToList();
}
foreach (var item in projects)
{
TreeNode rootProjectNode = new TreeNode();//定义根节点
rootProjectNode.Text = item.ProjectCode;
rootProjectNode.NodeID = item.ProjectId;
rootProjectNode.EnableClickEvent = true;
rootProjectNode.Expanded = true;
rootProjectNode.ToolTip = item.ProjectName;
rootProjectNode.CommandName = "项目名称";
rootNode.Nodes.Add(rootProjectNode);
}
}
#endregion
#region 点击TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
if (this.tvControlItem.SelectedNodeID != "0")
{
//this.BindGrid();
PageData();
}
}
#endregion
#region 查询
///<summary>
///查询
///</summary>
///<param name="sender"></param>
///<param name="e"></param>
protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
{
this.tvControlItem.SelectedNodeID = this.drpProjectId.SelectedValue;
this.InitTreeMenu();
PageData();
}
#endregion
#region 打印
/// <summary>
/// 打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrint_Click(object sender, EventArgs e)
{
string projectId = this.tvControlItem.SelectedNodeID;
if (projectId != null)
{
string initTemplatePath = "";
string rootPath = Server.MapPath("~/");
BLL.Common.FastReportService.ResetData();
var report = BLL.IndustrialPipelineInstallationQualityCertificateService.GetIndustrialPipelineInstallationQualityCertificateByProjectId(projectId, "2");
if (report != null)
{
DataTable dt = new DataTable();
dt.TableName = "Data";
dt.Columns.Add("CertificateCode");
dt.Columns.Add("EngineeringName");
dt.Columns.Add("EngineeringCode");
dt.Columns.Add("DeliveryUnit");
dt.Columns.Add("DeliveryUnitCode");
dt.Columns.Add("InstallStartDate");
dt.Columns.Add("InstallEndDate");
dt.Columns.Add("PipelineLevel");
dt.Columns.Add("PipelineLength");
dt.Columns.Add("DesignUnit");
dt.Columns.Add("DesignLicenseCode");
dt.Columns.Add("SupervisoryAndInspectionAgency");
dt.Columns.Add("QualificationCertificateCode");
dt.Columns.Add("LosslessTestingAgency");
dt.Columns.Add("InstitutionalApprovalCertificate");
dt.Columns.Add("InstallationInspection");
dt.Columns.Add("ConstructionUnit");
dt.Columns.Add("SpecialEquipmentProductionLicenseCode");
dt.Columns.Add("Remark");
var newRow = dt.NewRow();
newRow["CertificateCode"] = report.CertificateCode;
newRow["EngineeringName"] = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName;
newRow["EngineeringCode"] = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectCode;
newRow["DeliveryUnit"] = report.DeliveryUnit;
newRow["DeliveryUnitCode"] = report.DeliveryUnitCode;
string InstallStartDate = report.InstallStartDate.HasValue ? string.Format("{0:yyyy年MM月dd日}", report.InstallStartDate) : "";
newRow["InstallStartDate"] = InstallStartDate;
string InstallEndDate = report.InstallEndDate.HasValue ? string.Format("{0:yyyy年MM月dd日}", report.InstallEndDate) : "";
newRow["InstallEndDate"] = InstallEndDate;
newRow["PipelineLevel"] = report.PipelineLevel;
newRow["PipelineLength"] = report.PipelineLength;
newRow["DesignUnit"] = report.DesignUnit;
newRow["DesignLicenseCode"] = report.DesignLicenseCode;
newRow["SupervisoryAndInspectionAgency"] = report.SupervisoryAndInspectionAgency;
newRow["QualificationCertificateCode"] = report.QualificationCertificateCode;
newRow["LosslessTestingAgency"] = report.LosslessTestingAgency;
newRow["InstitutionalApprovalCertificate"] = report.InstitutionalApprovalCertificate;
newRow["InstallationInspection"] = report.InstallationInspection;
newRow["ConstructionUnit"] = report.ConstructionUnit;
newRow["SpecialEquipmentProductionLicenseCode"] = report.SpecialEquipmentProductionLicenseCode;
newRow["Remark"] = " 本压力管道的安装经质量检验,符合《工业管道安装技术规程》(TSG 31-2025)、设计文件和" + report.Remark + "要求。";
dt.Rows.Add(newRow);
BLL.Common.FastReportService.AddFastreportTable(dt);
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
//keyValuePairs.Add("ProjectName", BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName);
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
initTemplatePath = "File\\Fastreport\\JGZL\\压力管道安装质量证明2020.frx";
if (File.Exists(rootPath + initTemplatePath))
{
PageContext.RegisterStartupScript(WindowPrint.GetShowReference(String.Format("../common/ReportPrint/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
}
}
else
{
Alert.ShowInTop("请先保存记录!", MessageBoxIcon.Warning);
return;
}
}
else
{
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#region 保存
protected void btnSave_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.JGZL_IndustrialPipelineQualityCertificate2020MenuId, Const.BtnSave))
{
string projectId = this.tvControlItem.SelectedNodeID;
if (!string.IsNullOrEmpty(projectId))
{
Model.JGZL_IndustrialPipelineInstallationQualityCertificate newReport = new Model.JGZL_IndustrialPipelineInstallationQualityCertificate();
newReport.CertificateCode = this.txtCertificateCode.Text.Trim();
newReport.SpecialEquipmentProductionLicenseCode = this.txtSpecialEquipmentProductionLicenseCode.Text.Trim();
newReport.DeliveryUnit = this.txtDeliveryUnit.Text.Trim();
newReport.DeliveryUnitCode = this.txtDeliveryUnitCode.Text.Trim();
newReport.InstallStartDate = Funs.GetNewDateTime(this.txtInstallStartDate.Text.Trim());
newReport.InstallEndDate = Funs.GetNewDateTime(this.txtInstallEndDate.Text.Trim());
if (!string.IsNullOrEmpty(drpPipelineLevel.SelectedValue))
{
newReport.PipelineLevel = this.drpPipelineLevel.SelectedValue;
}
newReport.PipelineLength = this.txtPipelineLength.Text.Trim();
newReport.DesignUnit = this.txtDesignUnit.Text.Trim();
newReport.LosslessTestingAgency = this.txtLosslessTestingAgency.Text.Trim();
newReport.SupervisoryAndInspectionAgency = this.txtSupervisoryAndInspectionAgency.Text.Trim();
newReport.ConstructionUnit = this.txtConstructionUnit.Text.Trim();
newReport.Remark = drpRemark.SelectedValue;
newReport.DesignLicenseCode = this.txtDesignLicenseCode.Text.Trim();
newReport.QualificationCertificateCode = this.txtQualificationCertificateCode.Text.Trim();
newReport.InstitutionalApprovalCertificate = this.txtInstitutionalApprovalCertificate.Text.Trim();
newReport.InstallationInspection = this.txtInstallationInspection.Text.Trim();
if (!string.IsNullOrEmpty(this.CertificateId))
{
newReport.CertificateId = this.CertificateId;
BLL.IndustrialPipelineInstallationQualityCertificateService.UpdateIndustrialPipelineInstallationQualityCertificate(newReport);
}
else
{
newReport.FromType = "2";//2020版
newReport.ProjectId = projectId;
newReport.CompileMan = this.CurrUser.UserId;
newReport.CompileDate = DateTime.Now;
newReport.Reviewer = this.CurrUser.UserId;
newReport.RevieweDate = DateTime.Now;
newReport.CertificateId = SQLHelper.GetNewID(typeof(Model.JGZL_IndustrialPipelineInstallationQualityCertificate));
this.CertificateId = newReport.CertificateId;
BLL.IndustrialPipelineInstallationQualityCertificateService.AddIndustrialPipelineInstallationQualityCertificate(newReport);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
//PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
PageData();
}
else
{
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
return;
}
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
#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))
{
var report = BLL.IndustrialPipelineInstallationQualityCertificateService.GetIndustrialPipelineInstallationQualityCertificateByProjectId(projectId, "2");
if (report != null)
{
initTemplatePath = Const.JGZL_IndustrialPipelineQualityCertificate2020Url;
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(uploadfilepath);
Bookmark certificateCode = doc.Range.Bookmarks["CertificateCode"];
if (certificateCode != null)
{
certificateCode.Text = report.CertificateCode;
}
Bookmark engineeringName = doc.Range.Bookmarks["EngineeringName"];
if (engineeringName != null)
{
engineeringName.Text = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName;
}
Bookmark engineeringCode = doc.Range.Bookmarks["EngineeringCode"];
if (engineeringCode != null)
{
engineeringCode.Text = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectCode;
}
Bookmark deliveryUnit = doc.Range.Bookmarks["DeliveryUnit"];
if (deliveryUnit != null)
{
deliveryUnit.Text = report.DeliveryUnit;
}
Bookmark deliveryUnitCode = doc.Range.Bookmarks["DeliveryUnitCode"];
if (deliveryUnitCode != null)
{
deliveryUnitCode.Text = report.DeliveryUnitCode;
}
Bookmark installStartDate = doc.Range.Bookmarks["InstallStartDate"];
if (installStartDate != null)
{
installStartDate.Text = report.InstallStartDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.InstallStartDate) : "";
}
Bookmark installEndDate = doc.Range.Bookmarks["InstallEndDate"];
if (installEndDate != null)
{
installEndDate.Text = report.InstallEndDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.InstallEndDate) : "";
}
Bookmark pipelineLevel = doc.Range.Bookmarks["PipelineLevel"];
if (pipelineLevel != null)
{
if (report.PipelineLevel != null)
{
pipelineLevel.Text = report.PipelineLevel;
}
}
Bookmark pipelineLength = doc.Range.Bookmarks["PipelineLength"];
if (pipelineLength != null)
{
if (report.PipelineLength != null)
{
pipelineLength.Text = report.PipelineLength;
}
}
Bookmark designUnit = doc.Range.Bookmarks["DesignUnit"];
if (designUnit != null)
{
designUnit.Text = report.DesignUnit;
}
Bookmark designLicenseCode = doc.Range.Bookmarks["DesignLicenseCode"];
if (designLicenseCode != null)
{
designLicenseCode.Text = report.DesignLicenseCode;
}
Bookmark supervisoryAndInspectionAgency = doc.Range.Bookmarks["SupervisoryAndInspectionAgency"];
if (supervisoryAndInspectionAgency != null)
{
if (report.SupervisoryAndInspectionAgency != null)
{
supervisoryAndInspectionAgency.Text = report.SupervisoryAndInspectionAgency;
}
}
Bookmark qualificationCertificateCode = doc.Range.Bookmarks["QualificationCertificateCode"];
if (qualificationCertificateCode != null)
{
qualificationCertificateCode.Text = report.QualificationCertificateCode;
}
Bookmark losslessTestingAgency = doc.Range.Bookmarks["LosslessTestingAgency"];
if (losslessTestingAgency != null)
{
losslessTestingAgency.Text = report.LosslessTestingAgency;
}
Bookmark institutionalApprovalCertificate = doc.Range.Bookmarks["InstitutionalApprovalCertificate"];
if (institutionalApprovalCertificate != null)
{
institutionalApprovalCertificate.Text = report.InstitutionalApprovalCertificate;
}
Bookmark installationInspection = doc.Range.Bookmarks["InstallationInspection"];
if (installationInspection != null)
{
installationInspection.Text = report.InstallationInspection;
}
Bookmark constructionUnit = doc.Range.Bookmarks["ConstructionUnit"];
if (constructionUnit != null)
{
constructionUnit.Text = report.ConstructionUnit;
}
Bookmark remark = doc.Range.Bookmarks["Remark"];
if (remark != null)
{
remark.Text = report.Remark;
}
Bookmark specialEquipmentProductionLicenseCode = doc.Range.Bookmarks["SpecialEquipmentProductionLicenseCode"];
if (specialEquipmentProductionLicenseCode != null)
{
specialEquipmentProductionLicenseCode.Text = report.SpecialEquipmentProductionLicenseCode;
}
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
}
}