1000 lines
48 KiB
C#
1000 lines
48 KiB
C#
using Aspose.Words;
|
||
using Aspose.Words.Tables;
|
||
using BLL;
|
||
using FineUIPro.Web.common.BaseInfo;
|
||
using Model;
|
||
using Newtonsoft.Json.Linq;
|
||
using NPOI.SS.Formula.Functions;
|
||
using Org.BouncyCastle.Asn1.IsisMtt;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Web;
|
||
using System.Web.Services;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||
|
||
namespace FineUIPro.Web.JGZL
|
||
{
|
||
public partial class IndustrialPipelineInstallationSummary : PageBase
|
||
{
|
||
#region 定义项
|
||
/// <summary>
|
||
/// 主键
|
||
/// </summary>
|
||
private string SummaryId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["SummaryId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["SummaryId"] = value;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 项目Id
|
||
/// </summary>
|
||
private string ProjectId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["ProjectId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["ProjectId"] = value;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 外键—CertificateId
|
||
/// </summary>
|
||
public 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.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
||
|
||
this.drpProjectId.DataTextField = "ProjectCode";
|
||
this.drpProjectId.DataValueField = "ProjectId";
|
||
this.drpProjectId.DataSource = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
|
||
this.drpProjectId.DataBind();
|
||
Funs.FineUIPleaseSelect(this.drpProjectId);
|
||
|
||
this.drpProjectId.SelectedValue = this.CurrUser.LoginProjectId;
|
||
this.InitTreeMenu();//加载树
|
||
this.tvControlItem.SelectedNodeID = this.drpProjectId.SelectedValue;
|
||
|
||
//获取下拉选择项本项目下所有工业管道安装质量证明书信息
|
||
IndustrialPipelineInstallationQualityCertificateService.InitIndustrialPipelineInstallationQualityCertificateDownList(this.drpCertificateCode, this.tvControlItem.SelectedNodeID, "1", false);
|
||
if (!string.IsNullOrEmpty(this.drpCertificateCode.SelectedValue) && this.drpCertificateCode.SelectedValue != BLL.Const._Null)
|
||
{
|
||
this.CertificateId = this.drpCertificateCode.SelectedValue;
|
||
var certificate = BLL.IndustrialPipelineInstallationQualityCertificateService.GetIndustrialPipelineInstallationQualityCertificateById(this.CertificateId);
|
||
if (certificate != null)
|
||
{
|
||
this.txtDeliveryUnit.Text = certificate.DeliveryUnit;
|
||
this.txtDeliveryUnitCode.Text = certificate.DeliveryUnitCode;
|
||
}
|
||
}
|
||
DataIsoInfo();
|
||
BindGrid();
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
private void DataIsoInfo()
|
||
{
|
||
|
||
var isoInfo = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByProjectId(this.tvControlItem.SelectedNodeID);
|
||
if (isoInfo.Count > 0)
|
||
{
|
||
if (!string.IsNullOrEmpty(this.drpCertificateCode.SelectedValue))
|
||
{
|
||
foreach (var item in isoInfo)
|
||
{
|
||
var summary = BLL.IndustrialPipelineInstallationSummaryService.GetIndustrialPipelineInstallationSummaryByPipelineCode(item.ISO_IsoNo, "1");
|
||
if (summary == null)
|
||
{
|
||
Model.JGZL_IndustrialPipelineInstallationSummary newSummary = new JGZL_IndustrialPipelineInstallationSummary();
|
||
newSummary.SummaryId = SQLHelper.GetNewID(typeof(Model.JGZL_IndustrialPipelineInstallationSummary));
|
||
newSummary.ProjectId = this.tvControlItem.SelectedNodeID;
|
||
if (!string.IsNullOrEmpty(this.drpCertificateCode.SelectedValue))
|
||
{
|
||
newSummary.CertificateId = this.drpCertificateCode.SelectedValue;
|
||
}
|
||
newSummary.PipelineCode = item.ISO_IsoNo;
|
||
if (!string.IsNullOrEmpty(item.ISC_ID))
|
||
{
|
||
newSummary.PipelineLevel = BLL.HJGL_PipingClassService.GetPipingClassByPipingClassId(item.ISC_ID).ISC_IsoName;
|
||
}
|
||
newSummary.DesignPressure = item.ISO_DesignPress.HasValue ? item.ISO_DesignPress.Value.ToString("#.00") : "";
|
||
newSummary.DesignTemperature = item.ISO_DesignTemperature.HasValue ? item.ISO_DesignTemperature.Value.ToString("#.00") : "";
|
||
if (!string.IsNullOrEmpty(item.SER_ID))
|
||
{
|
||
newSummary.Medium = BLL.HJGL_MediumService.GetServiceBySERID(item.SER_ID).SER_Name;
|
||
}
|
||
if (!string.IsNullOrEmpty(item.STE_ID))
|
||
{
|
||
newSummary.Material = BLL.HJGL_MaterialService.GetSteelBySteID(item.STE_ID).STE_Code;
|
||
}
|
||
var jointInfo = (from x in Funs.DB.HJGL_PW_JointInfo where x.ISO_ID == item.ISO_ID select x).FirstOrDefault();
|
||
if (jointInfo != null)
|
||
{
|
||
newSummary.Specifications = HttpUtility.HtmlDecode(jointInfo.JOT_JointDesc);
|
||
}
|
||
newSummary.Length = item.PipeLineLength.HasValue ? item.PipeLineLength.Value.ToString("#.00") : "";
|
||
newSummary.WeldsNum = BLL.HJGL_PW_JointInfoService.GetJointCountByIsoId(item.ISO_ID).ToString();
|
||
if (!string.IsNullOrEmpty(item.Joty_B_Rate))
|
||
{
|
||
newSummary.LosslessRatio = HJGL_DetectionService.GetNDTRateByNDTRID(item.Joty_B_Rate).NDTR_Name;//无损检测比例
|
||
}
|
||
//newSummary.VoltageResistantTestMethod = "水压";//耐压试验方法
|
||
newSummary.VoltageResistantTestMedium = "水";//耐压试验介质
|
||
newSummary.LeakageTestMedium = "空气";//泄漏试验介质
|
||
newSummary.CleaningMethod = "压缩空气吹扫";//吹扫、清洗方法
|
||
newSummary.VoltageResistantTestPressure = item.ISO_TestPress.HasValue ? item.ISO_TestPress.Value.ToString(("0.##")) + "MPa" : "";//耐压试验压力
|
||
newSummary.LeakageTestPressure = item.LeakageTest + "MPa";//泄漏试验压力
|
||
newSummary.CorrosionControlMethod = item.ISO_Paint;//腐蚀控制方式
|
||
newSummary.VoltageResistantTestMethod = "水压试验";//耐压试验方法
|
||
newSummary.FromType = "1";
|
||
BLL.IndustrialPipelineInstallationSummaryService.AddIndustrialPipelineInstallationSummary(newSummary);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("请先编辑工业管道安装质量证明书!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
#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")
|
||
{
|
||
DataIsoInfo();
|
||
this.BindGrid();
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 数据绑定
|
||
/// <summary>
|
||
/// 数据绑定
|
||
/// </summary>
|
||
private void BindGrid()
|
||
{
|
||
string strSql = @"select SummaryId, CertificateId, ProjectId, PipelineCode, PipelineLevel, PipelineStartPoint, PipelineEndPoint,
|
||
CASE WHEN ISNUMERIC(DesignPressure)=1 THEN FORMAT(CAST(DesignPressure AS DECIMAL(18,6)), 'G29')
|
||
ELSE DesignPressure
|
||
END AS DesignPressure,
|
||
CASE WHEN ISNUMERIC(DesignTemperature)=1 THEN FORMAT(CAST(DesignTemperature AS DECIMAL(18,6)), 'G29')
|
||
ELSE DesignTemperature
|
||
END AS DesignTemperature,
|
||
Medium, Material, Specifications,
|
||
CASE WHEN ISNUMERIC(Length)=1 THEN FORMAT(CAST(Length AS DECIMAL(18,6)), 'G29')
|
||
ELSE Length
|
||
END AS Length,
|
||
LayingMethod, WeldsNum, LosslessRatio,
|
||
VoltageResistantTestMethod, VoltageResistantTestMedium, VoltageResistantTestPressure,
|
||
LeakageTestMedium, LeakageTestPressure, CleaningMethod, CorrosionControlMethod, InsulationMethod,
|
||
Remark, CompileMan, CompileDate, Reviewer, RevieweDate, OperatingTemperature, VoltageResistantTestDate,
|
||
LeakageTestDate,FromType from JGZL_IndustrialPipelineInstallationSummary
|
||
WHERE FromType='1' ";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
||
{
|
||
strSql += " AND ProjectId = @ProjectId";
|
||
listStr.Add(new SqlParameter("@ProjectId", this.tvControlItem.SelectedNodeID));
|
||
}
|
||
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);
|
||
// 2.获取当前分页数据
|
||
Grid1.RecordCount = tb.Rows.Count;
|
||
var table = this.GetPagedDataTable(Grid1, tb);
|
||
Grid1.DataSource = table;
|
||
Grid1.DataBind();
|
||
}
|
||
#endregion
|
||
|
||
#region 分页排序
|
||
#region 页索引改变事件
|
||
/// <summary>
|
||
/// 页索引改变事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 排序
|
||
/// <summary>
|
||
/// 排序
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 分页选择下拉改变事件
|
||
/// <summary>
|
||
/// 分页选择下拉改变事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
#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();
|
||
DataIsoInfo();
|
||
BindGrid();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||
{
|
||
this.BindGrid();
|
||
}
|
||
#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();
|
||
|
||
string strSql = @"SELECT * from JGZL_IndustrialPipelineInstallationSummary where ProjectId = @ProjectId and FromType='1'";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
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)
|
||
{
|
||
DataTable dt = new DataTable();
|
||
dt.TableName = "Data";
|
||
dt.Columns.Add("Num");
|
||
dt.Columns.Add("PipelineCode");
|
||
dt.Columns.Add("PipelineLevel");
|
||
dt.Columns.Add("DesignPressure");
|
||
dt.Columns.Add("DesignTemperature");
|
||
dt.Columns.Add("OperatingTemperature");
|
||
dt.Columns.Add("Medium");
|
||
dt.Columns.Add("Material");
|
||
dt.Columns.Add("Specifications");
|
||
dt.Columns.Add("Length");
|
||
dt.Columns.Add("LayingMethod");
|
||
dt.Columns.Add("WeldsNum");
|
||
dt.Columns.Add("LosslessRatio");
|
||
dt.Columns.Add("VoltageResistantTestMedium");
|
||
dt.Columns.Add("VoltageResistantTestPressure");
|
||
dt.Columns.Add("VoltageResistantTestDate");
|
||
dt.Columns.Add("LeakageTestMedium");
|
||
dt.Columns.Add("LeakageTestPressure");
|
||
dt.Columns.Add("LeakageTestDate");
|
||
dt.Columns.Add("CleaningMethod");
|
||
dt.Columns.Add("CorrosionControlMethod");
|
||
dt.Columns.Add("InsulationMethod");
|
||
dt.Columns.Add("PipelineStartPoint");
|
||
dt.Columns.Add("PipelineEndPoint");
|
||
dt.Columns.Add("Remark");
|
||
|
||
DataRow[] rows = tb.DefaultView.ToTable().Select();
|
||
int i = 0;
|
||
foreach (var row in rows)
|
||
{
|
||
string pipeLineClass = string.Empty;
|
||
string isoNo = row["PipelineCode"].ToString();
|
||
var isoInfo = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoNo(isoNo, projectId);
|
||
if (isoInfo != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(isoInfo.PipeLineClass) && isoInfo.PipeLineClass != "/")
|
||
{
|
||
pipeLineClass = isoInfo.PipeLineClass + "/";
|
||
}
|
||
}
|
||
var newRow = dt.NewRow();
|
||
newRow["Num"] = (i + 1).ToString();
|
||
newRow["PipelineCode"] = isoNo;
|
||
newRow["PipelineLevel"] = pipeLineClass + row["PipelineLevel"].ToString();
|
||
newRow["DesignPressure"] = row["DesignPressure"].ToString();
|
||
newRow["DesignTemperature"] = row["DesignTemperature"].ToString();
|
||
newRow["OperatingTemperature"] = row["OperatingTemperature"].ToString();
|
||
newRow["Medium"] = row["Medium"].ToString();
|
||
newRow["Material"] = row["Material"].ToString();
|
||
newRow["Specifications"] = HttpUtility.HtmlDecode(row["Specifications"].ToString());
|
||
newRow["Length"] = row["Length"].ToString();
|
||
newRow["LayingMethod"] = row["LayingMethod"].ToString();
|
||
newRow["WeldsNum"] = row["WeldsNum"].ToString();
|
||
newRow["LosslessRatio"] = row["LosslessRatio"].ToString();
|
||
newRow["VoltageResistantTestMedium"] = row["VoltageResistantTestMedium"].ToString();
|
||
newRow["VoltageResistantTestPressure"] = row["VoltageResistantTestPressure"].ToString();
|
||
string VoltageResistantTestDate = string.Format("{0:yyyy.MM.dd}", row["VoltageResistantTestDate"]);
|
||
newRow["VoltageResistantTestDate"] = VoltageResistantTestDate;
|
||
newRow["LeakageTestMedium"] = row["LeakageTestMedium"].ToString();
|
||
newRow["LeakageTestPressure"] = row["LeakageTestPressure"].ToString();
|
||
string LeakageTestDate = string.Format("{0:yyyy.MM.dd}", row["LeakageTestDate"]);
|
||
newRow["LeakageTestDate"] = LeakageTestDate;
|
||
newRow["CleaningMethod"] = row["CleaningMethod"].ToString();
|
||
newRow["CorrosionControlMethod"] = row["CorrosionControlMethod"].ToString();
|
||
newRow["InsulationMethod"] = row["InsulationMethod"].ToString();
|
||
newRow["PipelineStartPoint"] = row["PipelineStartPoint"].ToString();
|
||
newRow["PipelineEndPoint"] = row["PipelineEndPoint"].ToString();
|
||
newRow["Remark"] = row["Remark"].ToString();
|
||
dt.Rows.Add(newRow);
|
||
i++;
|
||
}
|
||
BLL.Common.FastReportService.AddFastreportTable(dt);
|
||
|
||
string certificateCode = string.Empty;
|
||
string deliveryUnit = string.Empty;
|
||
string deliveryUnitCode = string.Empty;
|
||
string certificateId = rows[0]["CertificateId"].ToString();
|
||
var certificate = BLL.IndustrialPipelineInstallationQualityCertificateService.GetIndustrialPipelineInstallationQualityCertificateById(certificateId);
|
||
if (certificate != null)
|
||
{
|
||
certificateCode = certificate.CertificateCode;
|
||
deliveryUnit = certificate.DeliveryUnit;
|
||
deliveryUnitCode = certificate.DeliveryUnitCode;
|
||
}
|
||
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
||
keyValuePairs.Add("CertificateCode", certificateCode);
|
||
keyValuePairs.Add("DeliveryUnit", deliveryUnit);
|
||
keyValuePairs.Add("DeliveryUnitCode", deliveryUnitCode);
|
||
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
|
||
|
||
initTemplatePath = "File\\Fastreport\\JGZL\\压力管道安装汇总表.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 维护
|
||
/// <summary>
|
||
/// 增加
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnAdd_Click(object sender, EventArgs e)
|
||
{
|
||
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
||
{
|
||
JArray teamGroupData = Grid1.GetMergedData();
|
||
List<JObject> list = new List<JObject>();
|
||
foreach (JObject teamGroupRow in teamGroupData)
|
||
{
|
||
JObject values = teamGroupRow.Value<JObject>("values");
|
||
list.Add(values);
|
||
}
|
||
|
||
JObject defaultObj = new JObject
|
||
{
|
||
{ "SummaryId", Guid.NewGuid() },
|
||
{ "CertificateId", this.drpCertificateCode.SelectedValue },
|
||
{ "ProjectId", this.tvControlItem.SelectedNodeID },
|
||
{ "PipelineCode", "" },
|
||
{ "PipelineLevel", "" },
|
||
{ "PipelineStartPoint", "" },
|
||
{ "PipelineEndPoint", "" },
|
||
{ "DesignPressure", "" },
|
||
{ "DesignTemperature", "" },
|
||
{ "Medium", "" },
|
||
{ "Material", "" },
|
||
{ "Specifications", "" },
|
||
{ "Length", "" },
|
||
{ "LayingMethod", "" },
|
||
{ "WeldsNum", "" },
|
||
{ "LosslessRatio", "" },
|
||
{ "VoltageResistantTestMedium", "" },
|
||
{ "VoltageResistantTestPressure", "" },
|
||
{ "LeakageTestMedium", "" },
|
||
{ "LeakageTestPressure", "" },
|
||
{ "CleaningMethod", "" },
|
||
{ "CorrosionControlMethod", "" },
|
||
{ "InsulationMethod", "" },
|
||
{ "OperatingTemperature", "" },
|
||
{ "VoltageResistantTestDate", "" },
|
||
{ "LeakageTestDate", "" },
|
||
{ "Remark", "" },
|
||
{ "FromType", "1" },
|
||
{
|
||
"Delete3",
|
||
String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>",
|
||
GetDeleteScriptGrid1(), IconHelper.GetResolvedIconUrl(Icon.Delete))
|
||
}
|
||
};
|
||
list.Add(defaultObj);
|
||
Grid1.DataSource = list;
|
||
Grid1.DataBind();
|
||
//PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("IndustrialPipelineInstallationSummaryEdit.aspx?projectId={0}", this.tvControlItem.SelectedNodeID, "新增 - ")));
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
|
||
protected void Grid1_PreDataBound(object sender, EventArgs e)
|
||
{
|
||
// 设置LinkButtonField的点击客户端事件
|
||
LinkButtonField deleteField = Grid1.FindColumn("Delete3") as LinkButtonField;
|
||
deleteField.OnClientClick = GetDeleteScriptGrid1();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除提示
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private string GetDeleteScriptGrid1()
|
||
{
|
||
return Confirm.GetShowReference("删除选中行?", String.Empty, MessageBoxIcon.Question,
|
||
Grid1.GetDeleteSelectedRowsReference(), String.Empty);
|
||
}
|
||
#endregion
|
||
|
||
#region 选择质量证明书编号
|
||
/// <summary>
|
||
/// 选择质量证明书编号
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void drpCertificateCode_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
this.txtDeliveryUnit.Text = string.Empty;
|
||
this.txtDeliveryUnitCode.Text = string.Empty;
|
||
if (!string.IsNullOrWhiteSpace(this.drpCertificateCode.SelectedValue))
|
||
{
|
||
//this.CertificateId = this.drpCertificateCode.SelectedValue;
|
||
|
||
#region 质量证明书
|
||
var certificate = BLL.IndustrialPipelineInstallationQualityCertificateService.GetIndustrialPipelineInstallationQualityCertificateById(this.drpCertificateCode.SelectedValue);
|
||
if (certificate != null)
|
||
{
|
||
this.txtDeliveryUnit.Text = certificate.DeliveryUnit;
|
||
this.txtDeliveryUnitCode.Text = certificate.DeliveryUnitCode;
|
||
}
|
||
#endregion
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 保存
|
||
/// <summary>
|
||
/// 保存按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId,
|
||
Const.JGZL_IndustrialPipelineInstallationSummaryMenuId, Const.BtnSave))
|
||
{
|
||
if (string.IsNullOrEmpty(this.drpCertificateCode.SelectedValue))
|
||
{
|
||
Alert.ShowInTop("请选择质量证明书编号!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
saveItem();
|
||
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
|
||
void saveItem()
|
||
{
|
||
BLL.IndustrialPipelineInstallationSummaryService.DeleteIndustrialPipelineInstallationSummaryByProjectId(this.tvControlItem.SelectedNodeID, "1");
|
||
List<Model.JGZL_IndustrialPipelineInstallationSummary> detailLists = new List<Model.JGZL_IndustrialPipelineInstallationSummary>();
|
||
JArray teamGroupData = Grid1.GetMergedData();
|
||
foreach (JObject teamGroupRow in teamGroupData)
|
||
{
|
||
JObject values = teamGroupRow.Value<JObject>("values");
|
||
int rowIndex = teamGroupRow.Value<int>("index");
|
||
Model.JGZL_IndustrialPipelineInstallationSummary newDetail = new Model.JGZL_IndustrialPipelineInstallationSummary
|
||
{
|
||
SummaryId = values.Value<string>("SummaryId"),
|
||
ProjectId = this.tvControlItem.SelectedNodeID,
|
||
CertificateId = this.drpCertificateCode.SelectedValue,
|
||
PipelineCode = values.Value<string>("PipelineCode"),
|
||
PipelineLevel = values.Value<string>("PipelineLevel"),
|
||
PipelineStartPoint = values.Value<string>("PipelineStartPoint"),
|
||
PipelineEndPoint = values.Value<string>("PipelineEndPoint"),
|
||
DesignPressure = values.Value<string>("DesignPressure"),
|
||
DesignTemperature = values.Value<string>("DesignTemperature"),
|
||
Medium = values.Value<string>("Medium"),
|
||
Material = values.Value<string>("Material"),
|
||
Specifications = HttpUtility.HtmlDecode(values.Value<string>("Specifications").Replace('×', 'x')),
|
||
Length = values.Value<string>("Length"),
|
||
LayingMethod = values.Value<string>("LayingMethod"),
|
||
WeldsNum = values.Value<string>("WeldsNum"),
|
||
LosslessRatio = values.Value<string>("LosslessRatio"),
|
||
VoltageResistantTestMethod = values.Value<string>("VoltageResistantTestMethod"),
|
||
VoltageResistantTestMedium = values.Value<string>("VoltageResistantTestMedium"),
|
||
VoltageResistantTestPressure = values.Value<string>("VoltageResistantTestPressure"),
|
||
LeakageTestMedium = values.Value<string>("LeakageTestMedium"),
|
||
LeakageTestPressure = values.Value<string>("LeakageTestPressure"),
|
||
CleaningMethod = values.Value<string>("CleaningMethod"),
|
||
CorrosionControlMethod = values.Value<string>("CorrosionControlMethod"),
|
||
InsulationMethod = values.Value<string>("InsulationMethod"),
|
||
FromType = "1"
|
||
};
|
||
detailLists.Add(newDetail);
|
||
}
|
||
try
|
||
{
|
||
if (detailLists.Count > 0)
|
||
{
|
||
Funs.DB.JGZL_IndustrialPipelineInstallationSummary.InsertAllOnSubmit(detailLists);
|
||
}
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
catch (Exception)
|
||
{
|
||
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 = Const.JGZL_IndustrialPipelineInstallationSummaryUrl;
|
||
string templateFullPath = Path.Combine(rootPath, initTemplatePath);
|
||
string saveTempPath = templateFullPath.Replace("工业管道安装汇总表导出模板", "工业管道安装汇总表(安装)");
|
||
int dataRowsPerPage = 5; //每页明细数据行数
|
||
string projectId = tvControlItem.SelectedNodeID;
|
||
if (string.IsNullOrEmpty(projectId))
|
||
{
|
||
Alert.ShowInTop("请先选择项目!");
|
||
return;
|
||
}
|
||
string sql = @"SELECT * from JGZL_IndustrialPipelineInstallationSummary
|
||
WHERE ProjectId = @ProjectId AND FromType='1'";
|
||
List<SqlParameter> paras = new List<SqlParameter>();
|
||
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);
|
||
}
|
||
/// <summary>构建明细数据行</summary>
|
||
private Aspose.Words.Tables.Row BuildDataRow(DataRow dr, Document doc)
|
||
{
|
||
Aspose.Words.Tables.Row row = new Aspose.Words.Tables.Row(doc);
|
||
row.RowFormat.Height = 47;
|
||
row.RowFormat.HeightRule = HeightRule.Exactly;
|
||
string GetCellValue(object obj)
|
||
{
|
||
if (obj == DBNull.Value) return "";
|
||
return obj.ToString().Replace("\r", "").Replace("\n", "").Trim();
|
||
}
|
||
|
||
string pipeLineClass = string.Empty;
|
||
string isoNo = dr["PipelineCode"].ToString();
|
||
var isoInfo = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoNo(isoNo, this.tvControlItem.SelectedNodeID);
|
||
if (isoInfo != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(isoInfo.PipeLineClass) && isoInfo.PipeLineClass != "/")
|
||
{
|
||
pipeLineClass = isoInfo.PipeLineClass + "/";
|
||
}
|
||
}
|
||
string pipeCode = GetCellValue(dr["PipelineCode"]);
|
||
string pipeLevel = GetCellValue(pipeLineClass + 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;
|
||
}
|
||
/// <summary>空白补行</summary>
|
||
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);
|
||
|
||
//清除段落自带空白
|
||
para.ParagraphFormat.SpaceBefore = 0;
|
||
para.ParagraphFormat.SpaceAfter = 0;
|
||
para.ParagraphFormat.LineSpacingRule = LineSpacingRule.AtLeast;
|
||
para.ParagraphFormat.LineSpacing = 8;
|
||
|
||
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;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 去掉小数末尾无效0
|
||
/// </summary>
|
||
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
|
||
|
||
}
|
||
} |