CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/CQMS/ManageReportNew/MonthReport.aspx.cs

3203 lines
165 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.UI;
using System.Web.UI.WebControls;
using Aspose.Words;
using Aspose.Words.Tables;
using BLL;
namespace FineUIPro.Web.CQMS.ManageReportNew
{
public partial class MonthReport : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
GetButtonPower();
}
}
public void BindGrid()
{
string strSql = @"select Id, Sortid, StartDate, EndDate, ProjectId,ReportType
from Report_WeekAndMonthReport_New C
where C.ReportType='1' AND C.ProjectId = @ProjectId";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb.Rows.Count;
tb = GetFilteredTable(Grid1.FilteredData, tb);
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
/// <summary>
/// 格式化字符串
/// </summary>
/// <param name="reportId"></param>
/// <returns></returns>
protected static string ConvertDate(object reportId)
{
string date = string.Empty;
if (reportId != null)
{
var r = BLL.WeekAndMonthReportNewService.Detail(reportId.ToString());
if (r != null)
{
date = string.Format("{0:yyyy-MM-dd}", r.StartDate) + " 至 " + string.Format("{0:yyyy-MM-dd}", r.EndDate);
}
}
return date;
}
/// <summary>
/// Grid行双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MonthReportEdit.aspx?reportId=" + Grid1.SelectedRowID, "添加 - ")));
}
protected void btnNew_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MonthReportEdit.aspx", "添加 - ")));
}
protected void btnMenuModify_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MonthReportEdit.aspx?reportId=" + Grid1.SelectedRowID, "添加 - ")));
}
protected void btnMenuView_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MonthReportEdit.aspx?view=view&reportId=" + Grid1.SelectedRowID, "查看 - ")));
}
protected void btnMenuDel_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length > 0)
{
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
//本月质量目标管理情况
CqmsTargetService.Delete(rowID);
TextBoxContentService.Delete(rowID);
Report_CQMS_MonthReportItemService.DeleteReportItemByReportId(rowID);
WeekAndMonthReportNewService.Delete(rowID);
}
BindGrid();
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
}
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
if (Request.Params["value"] == BLL.Const._Null)
{
return;
}
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.MonthReportNewMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnModify))
{
this.btnMenuModify.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnDelete))
{
this.btnMenuDel.Hidden = false;
}
}
}
#endregion
#region
/**
* 创建列值
* @param value 要插入的值
* @param doc Document对象
* @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 = 1.5;
cell.AppendChild(p);
return cell;
}
protected void btnPrinter_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string Id = Grid1.SelectedRowID;//质量月报的主键
try
{
string rootPath = Server.MapPath("~/");
string initTemplatePath = string.Empty;
string uploadfilepath = string.Empty;
string newUrl = string.Empty;
string filePath = string.Empty;
Model.SGGLDB db = Funs.DB;
initTemplatePath = Const.MonthReportNewTemplateUrl;
uploadfilepath = rootPath + initTemplatePath;
//newUrl = uploadfilepath.Replace(".doc", "(" + Funs.GetNewFileName() + ")" + ".doc");
//名称XX项目质量月报第几期
//根据id获取质量月报主表数据
var weekModel = db.Report_WeekAndMonthReport_New.FirstOrDefault(x => x.Id == Id);
var startDate = Convert.ToDateTime(weekModel.StartDate);
var endDate = Convert.ToDateTime(weekModel.EndDate);
//获取project
var pModel = db.Base_Project.FirstOrDefault(x => x.ProjectId == weekModel.ProjectId);
var urlHz = startDate.ToString("yyyyMMdd")+"-"
+ endDate.ToString("yyyyMMdd");
newUrl = uploadfilepath.Replace("项目质量月报", pModel.ShortName + "项目质量月报(第"+ weekModel.SortId + "期)"+ urlHz);
if (File.Exists(newUrl))
{
File.Delete(newUrl);
}
File.Copy(uploadfilepath, newUrl);
//更新书签内容
Document doc = new Aspose.Words.Document(newUrl);
DocumentBuilder builder = new DocumentBuilder(doc);
#region
//业主单位
var unitsYz = (from x in db.Base_Unit
join y in db.Project_ProjectUnit
on x.UnitId equals y.UnitId
where y.ProjectId == this.CurrUser.LoginProjectId && y.UnitType == BLL.Const.ProjectUnitType_4
orderby x.UnitName
select x).FirstOrDefault();
Bookmark bkmark = doc.Range.Bookmarks["username"];
if (bkmark != null) {
if (unitsYz != null)
{
bkmark.Text = unitsYz.UnitName;
}
//var uModel = db.Sys_User.FirstOrDefault(x => x.UserId == weekModel.CreateMan);
//if (uModel!=null)
//{
// bkmark.Text = uModel.UserName;
//}
}
bkmark= doc.Range.Bookmarks["projectNo"];
if (bkmark!=null)
{
bkmark.Text = pModel.ProjectCode;
}
bkmark = doc.Range.Bookmarks["createdate"];
if (bkmark!=null)
{
bkmark.Text = weekModel.CreateDate.ToString().Split(' ')[0].Replace('/', '.');
}
bkmark = doc.Range.Bookmarks["projectname"];
if (bkmark != null)
{
bkmark.Text = pModel.ProjectName;
}
bkmark = doc.Range.Bookmarks["quamanagername"];
if (bkmark != null) {
//var zlName = "";
////根据项目获取质量经理
//var puserList = db.Project_ProjectUser.Where(x => x.ProjectId == weekModel.ProjectId && x.RoleId.Contains(BLL.Const.QAManager)).ToList();
//foreach (var item in puserList)
//{
// zlName+= db.Sys_User.FirstOrDefault(x => x.UserId == item.UserId).UserName+",";
//}
var getPUser = Funs.DB.Project_ProjectUser.Where(x => x.ProjectId == weekModel.ProjectId);
////质量经理
var qa = getPUser.FirstOrDefault(x => x.RoleId.Contains(BLL.Const.QAManager));
bkmark.Text = db.Sys_User.FirstOrDefault(x => x.UserId == qa.UserId).UserName;
}
bkmark = doc.Range.Bookmarks["reportAlldate"];
//20XX年XX月XX日至20XX年XX月XX日
if (bkmark != null)
{
var sdate = Convert.ToDateTime(weekModel.StartDate);
var edate = Convert.ToDateTime(weekModel.EndDate);
bkmark.Text = sdate.Year+"年"+ sdate.Month +"月"+ sdate.Day+"日至"+
edate.Year + "年" + edate.Month + "月" + edate.Day + "日";
}
bkmark = doc.Range.Bookmarks["reportindex"];
if (bkmark!=null)
{
bkmark.Text = weekModel.SortId;
}
bkmark = doc.Range.Bookmarks["fromcode"];
//fromcode,项目号-RM-PQM-顺序号
if (bkmark!=null)
{
bkmark.Text = pModel.ProjectCode + "-RM-PQM-" + weekModel.SortId;
}
#endregion
#region
//获取word文档中的第二个表格
int whileIndex = 1;
Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 1, true);
bool isYm = true;
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2)!="序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else{
isYm = false;
}
}
var cqrmTargetList = db.Report_CqmsTarget.Where(x => x.ReportId == Id).OrderBy(x => x.SortId);
int numberIndex = 1;
foreach (var item in cqrmTargetList)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width,"","1"));
row.Cells.Add(CreateCell(item.ProStage, doc, table.FirstRow.Cells[1].CellFormat.Width,"","", "unit"));
row.Cells.Add(CreateCell(item.ProDescribe, doc, table.FirstRow.Cells[2].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.TargetValue, doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthPer, doc, table.FirstRow.Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[5].CellFormat.Width, "", "", "unit"));
table.Rows.Insert(numberIndex, row);
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
#endregion
#region
var txtReportList = Funs.DB.Report_TextBoxContent.Where(x => x.ReportId == Id).ToList();
bkmark = doc.Range.Bookmarks["Content1"];
if (bkmark != null)
{
bkmark.Text= txtReportList.FirstOrDefault(x => x.ContentType == "0").ContentText;
}
bkmark = doc.Range.Bookmarks["Content2"];
if (bkmark != null)
{
bkmark.Text = txtReportList.FirstOrDefault(x => x.ContentType == "1").ContentText;
}
bkmark = doc.Range.Bookmarks["Content3"];
if (bkmark != null)
{
bkmark.Text = txtReportList.FirstOrDefault(x => x.ContentType == "2").ContentText;
}
bkmark = doc.Range.Bookmarks["Content8"];
if (bkmark != null)
{
bkmark.Text = txtReportList.FirstOrDefault(x => x.ContentType == "8").ContentText;
}
#endregion
var ContuructionAllList = db.Report_Construction_Plan.Where(x => x.ReportId == Id).OrderBy(x=>x.UnitOrMajor).ToList();
#region 3.
#region
var ybsgfaList = ContuructionAllList.Where(x => x.ReType == "0").ToList();
if (ybsgfaList.Count > 0)
{
isYm = true;
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0;
foreach (var item in ybsgfaList)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.UnitOrMajor, doc, table.FirstRow.Cells[1].CellFormat.Width,"","","unit"));
row.Cells.Add(CreateCell(item.Quantity1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.Quantity2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[4].CellFormat.Width, "", "", "unit"));
table.Rows.Insert(numberIndex, row);
num1 += item.Quantity1;
num2 += item.Quantity2;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region
var wdsgfaList = ContuructionAllList.Where(x => x.ReType == "1").ToList();
if (wdsgfaList.Count > 0)
{
isYm = true;
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0, num3=0;
foreach (var item in wdsgfaList)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.UnitOrMajor, doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.Quantity1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.Quantity2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.Quantity3.ToString(), doc, table.FirstRow.Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[5].CellFormat.Width, "", "", "unit"));
table.Rows.Insert(numberIndex, row);
num1 += item.Quantity1;
num2 += item.Quantity2;
num3+= item.Quantity3;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
//创建行
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num3.ToString(), doc, table.FirstRow.Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[5].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region ITP
var itpList = ContuructionAllList.Where(x => x.ReType == "2").ToList();
if (itpList.Count > 0)
{
isYm = true;
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0;
foreach (var item in itpList)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.UnitOrMajor, doc, table.FirstRow.Cells[1].CellFormat.Width));
row.Cells.Add(CreateCell(item.Quantity1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.Quantity2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, row);
num1 += item.Quantity1;
num2 += item.Quantity2;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
//创建行
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#endregion
#region
var sjjdList = ContuructionAllList.Where(x => x.ReType == "3").ToList();
if (sjjdList.Count > 0)
{
isYm = true;
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0;
foreach (var item in sjjdList)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.UnitOrMajor, doc, table.FirstRow.Cells[1].CellFormat.Width));
row.Cells.Add(CreateCell(item.Quantity1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.Quantity2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, row);
num1 += item.Quantity1;
num2 += item.Quantity2;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
//创建行
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region
var tzhsList = ContuructionAllList.Where(x => x.ReType == "4").ToList();
if (tzhsList.Count > 0)
{
isYm = true;
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0;
foreach (var item in tzhsList)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.UnitOrMajor, doc, table.FirstRow.Cells[1].CellFormat.Width));
row.Cells.Add(CreateCell(item.Quantity1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.Quantity2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, row);
num1 += item.Quantity1;
num2 += item.Quantity2;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
//创建行
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 6.
int Quantity1Sum = 0, Quantity2Sum = 0, Quantity3Sum = 0, Quantity4Sum = 0, Quantity5Sum = 0, Quantity6Sum = 0;
DateTime projectStartDate = Convert.ToDateTime("2015-01-01");
List<Model.CheckStatisc> StatisticsList = new List<Model.CheckStatisc>();
Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
if (project != null)
{
if (project.StartDate != null)
{
projectStartDate = Convert.ToDateTime(project.StartDate);
}
}
int i = 1;
var cNProfessionals = from x in Funs.DB.Base_CNProfessional where x.CNProfessionalId != BLL.Const.CNProfessionalConstructId
&& x.CNProfessionalId != BLL.Const.ComprehensiveId
orderby x.SortIndex select x;
foreach (var item in cNProfessionals)
{
//专业下所有集合
List<Model.Comprehensive_DesignChangeOrder> totalManagementList = BLL.DesignChangeOrderService.GetDesignChangeOrderListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, item.CNProfessionalId, projectStartDate, DateTime.Now);
//专业下当期集合
List<Model.Comprehensive_DesignChangeOrder> managementList = BLL.DesignChangeOrderService.GetDesignChangeOrderListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, item.CNProfessionalId, startDate, endDate);
Model.CheckStatisc checkStatisc = new Model.CheckStatisc();
checkStatisc.Num = i;
checkStatisc.WorkName = item.ProfessionalName;
checkStatisc.CheckNum = managementList.Count();
checkStatisc.TotalCheckNum = totalManagementList.Count();
checkStatisc.OKNum = managementList.Count(x => x.ApprovalDate != null);
checkStatisc.TotalOKNum = totalManagementList.Count(x => x.ApprovalDate != null);
checkStatisc.OneOKRate = managementList.Count(x => x.ImplementationFrontState == "已完成").ToString(); //当期完成数
checkStatisc.TotalOneOKRate = totalManagementList.Count(x => x.ImplementationFrontState == "已完成").ToString(); //累计完成数
StatisticsList.Add(checkStatisc);
Quantity1Sum += checkStatisc.CheckNum;
Quantity2Sum += checkStatisc.TotalCheckNum;
Quantity3Sum += checkStatisc.OKNum;
Quantity4Sum += checkStatisc.TotalOKNum;
Quantity5Sum += Convert.ToInt32(checkStatisc.OneOKRate);
Quantity6Sum += Convert.ToInt32(checkStatisc.TotalOneOKRate);
}
if (StatisticsList.Count>0)
{
isYm = true;
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 2;
//需要插入的table
foreach (var item in StatisticsList)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell((numberIndex-1).ToString(), doc, table.Rows[0].Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.WorkName, doc, table.Rows[0].Cells[1].CellFormat.Width));
row.Cells.Add(CreateCell(item.CheckNum.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalCheckNum.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.OKNum.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalOKNum.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
row.Cells.Add(CreateCell(item.OneOKRate.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalOneOKRate.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex, row);
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
//创建行
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.Rows[0].Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.Rows[0].Cells[1].CellFormat.Width));
rowhj.Cells.Add(CreateCell(Quantity1Sum.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(Quantity2Sum.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(Quantity3Sum.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell(Quantity4Sum.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
rowhj.Cells.Add(CreateCell(Quantity5Sum.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
rowhj.Cells.Add(CreateCell(Quantity6Sum.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 7.1
Quantity1Sum = 0; Quantity2Sum = 0; Quantity3Sum = 0; Quantity4Sum = 0; Quantity5Sum = 0; Quantity6Sum = 0;
int Quantity7Sum = 0, Quantity8Sum = 0;
List<Model.PassWelderStatisc> PassWelderList = new List<Model.PassWelderStatisc>();
if (project != null)
{
if (project.StartDate != null)
{
projectStartDate = Convert.ToDateTime(project.StartDate);
}
}
i = 1;
var units = from x in Funs.DB.Project_ProjectUnit
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitType == BLL.Const.ProjectUnitType_2
orderby y.UnitCode
select new { x.UnitId, y.UnitName };
foreach (var item in units)
{
var query = from c in db.Comprehensive_InspectionPerson
join u in db.Base_Unit on c.UnitId equals u.UnitId into unitJoin
from u in unitJoin.DefaultIfEmpty()
join cn in db.Base_CNProfessional on c.CNProfessionalId equals cn.CNProfessionalId into cnJoin
from cn in cnJoin.DefaultIfEmpty()
join p in db.Base_Post on c.PostId equals p.PostId into postJoin
from p in postJoin.DefaultIfEmpty()
where c.ProjectId == this.CurrUser.LoginProjectId && c.UnitId == item.UnitId
select new
{
c.InspectionPersonId,
c.ProjectId,
u.UnitId,
u.UnitName,
c.PersonName,
c.ApprovalTime,
cn.ProfessionalName,
p.PostName
};
//单位下所有集合
// List<Model.BS_Welder> totalWelderList = BLL.PersonManageService.GetWelderListByUnitId(this.CurrUser.LoginProjectId, item.UnitId);
//List<Model.BS_Welder> welderList = BLL.PersonManageService.GetWelderListByUnitIdAndDate(this.CurrUser.LoginProjectId, item.UnitId, startDate, endDate);
var totalWelderList = query.ToList();
var welderList = query
.Where(x => (x.ApprovalTime >= Convert.ToDateTime(startDate) && x.ApprovalTime <= Convert.ToDateTime(endDate)));
Model.PassWelderStatisc passWelderStatisc = new Model.PassWelderStatisc();
passWelderStatisc.Num = i;
passWelderStatisc.UnitName = item.UnitName;
passWelderStatisc.PipeMountGuard = welderList.Count(x => x.ProfessionalName == "管道" && x.PostName == "焊工");
passWelderStatisc.PipeTotal = totalWelderList.Count(x => x.ProfessionalName == "管道" && x.PostName == "焊工");
passWelderStatisc.SteelStructureMountGuard = welderList.Count(x => x.ProfessionalName == "土建" && x.PostName == "焊工");
passWelderStatisc.SteelStructureTotal = totalWelderList.Count(x => x.ProfessionalName == "土建" && x.PostName == "焊工");
passWelderStatisc.EquipmentMountGuard = welderList.Count(x => x.ProfessionalName == "设备" && x.PostName == "焊工");
passWelderStatisc.EquipmentTotal = totalWelderList.Count(x => x.ProfessionalName == "设备" && x.PostName == "焊工");
passWelderStatisc.OtherMountGuard = welderList.Count(x => x.ProfessionalName != "管道" && x.ProfessionalName != "土建" && x.ProfessionalName != "设备" && x.PostName == "焊工");
passWelderStatisc.OtherTotal = totalWelderList.Count(x => x.ProfessionalName != "管道" && x.ProfessionalName != "土建" && x.ProfessionalName != "设备" && x.PostName == "焊工");
PassWelderList.Add(passWelderStatisc);
i++;
Quantity1Sum += passWelderStatisc.PipeMountGuard;
Quantity2Sum += passWelderStatisc.PipeTotal;
Quantity3Sum += passWelderStatisc.SteelStructureMountGuard;
Quantity4Sum += passWelderStatisc.SteelStructureTotal;
Quantity5Sum += passWelderStatisc.EquipmentMountGuard;
Quantity6Sum += passWelderStatisc.EquipmentTotal;
Quantity7Sum += passWelderStatisc.OtherMountGuard;
Quantity8Sum += passWelderStatisc.OtherTotal;
}
if (PassWelderList.Count>0)
{
isYm = true;
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 2;
//需要插入的table
foreach (var item in PassWelderList)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell((numberIndex - 1).ToString(), doc, table.Rows[0].Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.UnitName, doc, table.Rows[0].Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.PipeMountGuard.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.PipeTotal.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.SteelStructureMountGuard.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.SteelStructureTotal.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
row.Cells.Add(CreateCell(item.EquipmentMountGuard.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
row.Cells.Add(CreateCell(item.EquipmentTotal.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
row.Cells.Add(CreateCell(item.OtherMountGuard.ToString(), doc, table.Rows[1].Cells[8].CellFormat.Width));
row.Cells.Add(CreateCell(item.OtherTotal.ToString(), doc, table.Rows[1].Cells[9].CellFormat.Width));
table.Rows.Insert(numberIndex, row);
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
//创建行
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.Rows[0].Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.Rows[0].Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(Quantity1Sum.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(Quantity2Sum.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(Quantity3Sum.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell(Quantity4Sum.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
rowhj.Cells.Add(CreateCell(Quantity5Sum.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
rowhj.Cells.Add(CreateCell(Quantity6Sum.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
rowhj.Cells.Add(CreateCell(Quantity7Sum.ToString(), doc, table.Rows[1].Cells[8].CellFormat.Width));
rowhj.Cells.Add(CreateCell(Quantity8Sum.ToString(), doc, table.Rows[1].Cells[9].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 7.2PQR/WPS报验情况
var pqrList = ContuructionAllList.Where(x => x.ReType == "5").ToList();
if (pqrList.Count > 0)
{
isYm = true;
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0;
foreach (var item in pqrList)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.UnitOrMajor, doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.Quantity1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.Quantity2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, row);
num1 += item.Quantity1;
num2 += item.Quantity2;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
//创建行
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
else {
isYm = true;
numberIndex = 1;
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
//创建合计
Row rowhj = new Row(doc);
double numcount0 = table.FirstRow.Cells[0].CellFormat.Width;
double numcount1 = table.FirstRow.Cells[1].CellFormat.Width;
double numcount2 = table.FirstRow.Cells[2].CellFormat.Width;
double numcount3 = table.FirstRow.Cells[3].CellFormat.Width;
double numcount4 = table.FirstRow.Cells[4].CellFormat.Width;
double numcount = numcount0 + numcount1 + numcount2 + numcount3 + numcount4;
rowhj.Cells.Add(CreateCell("暂无数据", doc, numcount));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 7.3
var NondestructiveTestlist = new List<Model.ProcessControl_NondestructiveTest_New>();
//加载所有施工分包单位
units = from x in Funs.DB.Project_ProjectUnit
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
where x.ProjectId == this.CurrUser.LoginProjectId && (x.UnitType == BLL.Const.ProjectUnitType_2)
orderby y.UnitCode
select new { x.UnitId, y.UnitName };
int? totalNum0 = 0, totalNum1 = 0;//拍片数量合计
foreach (var item in units)
{
int? num0 = 0, num1 = 0;//拍片数量小计
var query = from c in db.ProcessControl_NondestructiveTest_New
join u in db.Base_Unit on c.UnitId equals u.UnitId
where c.ProjectId == this.CurrUser.LoginProjectId && c.UnitId == item.UnitId
&& c.CreateDate >= Convert.ToDateTime(startDate) && c.CreateDate <= Convert.ToDateTime(endDate)
orderby c.CreateDate descending
select new
{
c.CreateDate,
c.ProjectId,
u.UnitId,
u.UnitName,
c.ProfessionalName,
c.MonthQuantity,
c.TotalQuantity,
c.MonthRate,
c.TotalRate
};
if (query.ToList().Count > 0)
{
//加载工艺管道
var gygdModel = query.FirstOrDefault(x => x.ProfessionalName == "工艺管道");
var model = new Model.ProcessControl_NondestructiveTest_New();
model.Id = Guid.NewGuid().ToString();
model.CreateMan = item.UnitName;//用作存储施工单位名称
model.ProfessionalName = "工艺管道";
if (gygdModel != null)
{
model.MonthQuantity = gygdModel.MonthQuantity;
model.TotalQuantity = gygdModel.TotalQuantity;
model.MonthRate = gygdModel.MonthRate + "%";
model.TotalRate = gygdModel.TotalRate + "%";
#region
//小计
num0 += gygdModel.MonthQuantity;
num1 += gygdModel.TotalQuantity;
//合计
totalNum0 += gygdModel.MonthQuantity;
totalNum1 += gygdModel.TotalQuantity;
#endregion
NondestructiveTestlist.Add(model);
}
else
{
model.MonthQuantity = 0;
model.TotalQuantity = 0;
model.MonthRate = "0%";
model.TotalRate = "0%";
NondestructiveTestlist.Add(model);
}
//地管
gygdModel = query.FirstOrDefault(x => x.ProfessionalName == "地管");
model = new Model.ProcessControl_NondestructiveTest_New();
model.Id = Guid.NewGuid().ToString();
model.CreateMan = item.UnitName;//用作存储施工单位名称
model.ProfessionalName = "地管";
if (gygdModel != null)
{
model.MonthQuantity = gygdModel.MonthQuantity;
model.TotalQuantity = gygdModel.TotalQuantity;
model.MonthRate = gygdModel.MonthRate + "%";
model.TotalRate = gygdModel.TotalRate + "%";
#region
//小计
num0 += gygdModel.MonthQuantity;
num1 += gygdModel.TotalQuantity;
//合计
totalNum0 += gygdModel.MonthQuantity;
totalNum1 += gygdModel.TotalQuantity;
#endregion
NondestructiveTestlist.Add(model);
}
else
{
model.MonthQuantity = 0;
model.TotalQuantity = 0;
model.MonthRate = "0%";
model.TotalRate = "0%";
NondestructiveTestlist.Add(model);
}
//非标
gygdModel = query.FirstOrDefault(x => x.ProfessionalName == "非标");
model = new Model.ProcessControl_NondestructiveTest_New();
model.Id = Guid.NewGuid().ToString();
model.CreateMan = item.UnitName;//用作存储施工单位名称
model.ProfessionalName = "非标";
if (gygdModel != null)
{
model.MonthQuantity = gygdModel.MonthQuantity;
model.TotalQuantity = gygdModel.TotalQuantity;
model.MonthRate = gygdModel.MonthRate + "%";
model.TotalRate = gygdModel.TotalRate + "%";
#region
//小计
num0 += gygdModel.MonthQuantity;
num1 += gygdModel.TotalQuantity;
//合计
totalNum0 += gygdModel.MonthQuantity;
totalNum1 += gygdModel.TotalQuantity;
#endregion
NondestructiveTestlist.Add(model);
}
else
{
model.MonthQuantity = 0;
model.TotalQuantity = 0;
model.MonthRate = "0%";
model.TotalRate = "0%";
NondestructiveTestlist.Add(model);
}
//小计
model = new Model.ProcessControl_NondestructiveTest_New();
model.Id = Guid.NewGuid().ToString();
model.CreateMan = item.UnitName;//用作存储施工单位名称
model.ProfessionalName = "小计";
model.MonthQuantity = num0;
model.TotalQuantity = num1;
model.MonthRate = "";
model.TotalRate = "";
NondestructiveTestlist.Add(model);
}
}
if (NondestructiveTestlist.Count > 0)
{
isYm = true;
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
//需要插入的table
var Unitname = "";
int pageCount = 1;
foreach (var item in NondestructiveTestlist)
{
//创建行
Row row = new Row(doc);
//如果是第一列,或者
if (numberIndex == 1 || Unitname != item.CreateMan)
{
if (Unitname != item.CreateMan && numberIndex != 1)
{
pageCount += 1;
}
row.Cells.Add(CreateCell((pageCount).ToString(), doc, table.Rows[0].Cells[0].CellFormat.Width, "0", "1"));
row.Cells.Add(CreateCell(item.CreateMan, doc, table.Rows[0].Cells[1].CellFormat.Width, "0", "", "unit"));
Unitname = item.CreateMan;
}
else
{
row.Cells.Add(CreateCell((pageCount).ToString(), doc, table.Rows[0].Cells[0].CellFormat.Width, "1", "1"));
row.Cells.Add(CreateCell(item.CreateMan, doc, table.Rows[0].Cells[1].CellFormat.Width, "1", "", "unit"));
Unitname = item.CreateMan;
}
row.Cells.Add(CreateCell(item.ProfessionalName.ToString(), doc, table.Rows[0].Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthQuantity.ToString(), doc, table.Rows[0].Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalQuantity.ToString(), doc, table.Rows[0].Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthRate.ToString(), doc, table.Rows[0].Cells[5].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalRate.ToString(), doc, table.Rows[0].Cells[6].CellFormat.Width));
table.Rows.Insert(numberIndex, row);
numberIndex += 1;
if (Unitname != item.CreateMan)
{
pageCount += 1;
}
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
//创建行
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.Rows[0].Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.Rows[0].Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell("", doc, table.Rows[0].Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(totalNum0.ToString(), doc, table.Rows[0].Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(totalNum1.ToString(), doc, table.Rows[0].Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.Rows[0].Cells[5].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.Rows[0].Cells[6].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
else {
isYm = true;
numberIndex = 1;
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
//创建合计
Row rowhj = new Row(doc);
double numcount0 = table.Rows[0].Cells[0].CellFormat.Width;
double numcount1 = table.Rows[0].Cells[1].CellFormat.Width;
double numcount2 = table.Rows[0].Cells[2].CellFormat.Width;
double numcount3 = table.Rows[0].Cells[3].CellFormat.Width;
double numcount4 = table.Rows[0].Cells[4].CellFormat.Width;
double numcount5 = table.Rows[0].Cells[5].CellFormat.Width;
double numcount6 = table.Rows[0].Cells[6].CellFormat.Width;
double numcount = numcount0 + numcount1 + numcount2 + numcount3 + numcount4 + numcount5 + numcount6;
rowhj.Cells.Add(CreateCell("暂无数据", doc, numcount));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 8.
var sbclbyList = ContuructionAllList.Where(x => x.ReType == "6").ToList();
if (sbclbyList.Count > 0)
{
isYm = true;
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
//获取到第一列是序号的列
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0;
foreach (var item in sbclbyList)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.UnitOrMajor, doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.Quantity1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.Quantity2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.QuaRate.ToString(), doc, table.FirstRow.Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[5].CellFormat.Width));
table.Rows.Insert(numberIndex, row);
num1 += item.Quantity1;
num2 += item.Quantity2;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
//创建行
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[5].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
else {
isYm = true;
numberIndex = 1;
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
//创建合计
Row rowhj = new Row(doc);
double numcount0 = table.Rows[0].Cells[0].CellFormat.Width;
double numcount1 = table.Rows[0].Cells[1].CellFormat.Width;
double numcount2 = table.Rows[0].Cells[2].CellFormat.Width;
double numcount3 = table.Rows[0].Cells[3].CellFormat.Width;
double numcount4 = table.Rows[0].Cells[4].CellFormat.Width;
double numcount5 = table.Rows[0].Cells[5].CellFormat.Width;
double numcount = numcount0 + numcount1 + numcount2 + numcount3 + numcount4 + numcount5;
rowhj.Cells.Add(CreateCell("暂无数据", doc, numcount));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
var reportItem = db.Report_CQMS_MonthReportItem.Where(x => x.ReportId == Id).OrderBy(x => x.ContentName).ToList();
#region 9.
var measuringInspection = reportItem.Where(x => x.ReType == "9").ToList();
if (measuringInspection.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 13;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0;
foreach (var item in measuringInspection)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[4].CellFormat.Width, "", "", "unit"));
table.Rows.Insert(numberIndex, row);
num1 += item.MonthsCount;
num2 += item.ProjectCount;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
else
{
isYm = true;
numberIndex = 1;
whileIndex = 13;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width));
row.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[1].CellFormat.Width));
row.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, row);
}
#endregion
#region 10.
#region 10-1
var TJInspection = reportItem.Where(x => x.ReType == "10-1").ToList();
if (TJInspection != null || TJInspection.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 14;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0, num3 = 0, num4 = 0;
string num5 = string.Empty;
string num6 = string.Empty;
foreach (var item in TJInspection)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.Rows[0].Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.Rows[0].Cells[1].CellFormat.Width));
// 合并第一行的前两个单元格
table.Rows[0].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
table.Rows[1].Cells[0].CellFormat.VerticalMerge = CellMerge.Previous;
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthsBackCount.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalNoBackCount.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
row.Cells.Add(CreateCell(item.RectificationRate.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex + 1, row);
num1 += item.MonthsCount;
num2 += item.MonthsBackCount;
num3 += item.ProjectCount;
num4 += item.TotalNoBackCount;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
if (num1 != 0)//被除数不能为零
{
num5 = Math.Round((double)num3 / (double)num1 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
num5 = "0%";
}
if (num2 != 0)//被除数不能为零
{
num6 = Math.Round((double)num4 / (double)num2 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
num6 = "0%";
}
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.Rows[0].Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.Rows[0].Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num3.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num4.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num5.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num6.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
else
{
isYm = true;
numberIndex = 1;
whileIndex = 14;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
//创建合计
Row rowhj = new Row(doc);
double numcount0 = table.Rows[0].Cells[0].CellFormat.Width;
double numcount1 = table.Rows[0].Cells[1].CellFormat.Width;
double numcount2 = table.Rows[1].Cells[2].CellFormat.Width;
double numcount3 = table.Rows[1].Cells[3].CellFormat.Width;
double numcount4 = table.Rows[1].Cells[4].CellFormat.Width;
double numcount5 = table.Rows[1].Cells[5].CellFormat.Width;
double numcount6 = table.Rows[1].Cells[6].CellFormat.Width;
double numcount7 = table.Rows[1].Cells[7].CellFormat.Width;
double numcount = numcount0 + numcount1 + numcount2 + numcount3 + numcount4 + numcount5 + numcount6 + numcount7;
rowhj.Cells.Add(CreateCell("暂无数据", doc, numcount));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 10-2
var SBInspection = reportItem.Where(x => x.ReType == "10-2").ToList();
if (SBInspection != null || SBInspection.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 15;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0, num3 = 0, num4 = 0;
string num5 = string.Empty;
string num6 = string.Empty;
foreach (var item in SBInspection)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.Rows[0].Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.Rows[0].Cells[1].CellFormat.Width));
// 合并第一行的前两个单元格
table.Rows[0].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
table.Rows[1].Cells[0].CellFormat.VerticalMerge = CellMerge.Previous;
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthsBackCount.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalNoBackCount.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
row.Cells.Add(CreateCell(item.RectificationRate.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex + 1, row);
num1 += item.MonthsCount;
num2 += item.MonthsBackCount;
num3 += item.ProjectCount;
num4 += item.TotalNoBackCount;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
if (num1 != 0)//被除数不能为零
{
num5 = Math.Round((double)num3 / (double)num1 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
num5 = "0%";
}
if (num2 != 0)//被除数不能为零
{
num6 = Math.Round((double)num4 / (double)num2 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
num6 = "0%";
}
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.Rows[0].Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.Rows[0].Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num3.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num4.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num5.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num6.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
else
{
isYm = true;
numberIndex = 1;
whileIndex = 15;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
//创建合计
Row rowhj = new Row(doc);
double numcount0 = table.Rows[0].Cells[0].CellFormat.Width;
double numcount1 = table.Rows[0].Cells[1].CellFormat.Width;
double numcount2 = table.Rows[1].Cells[2].CellFormat.Width;
double numcount3 = table.Rows[1].Cells[3].CellFormat.Width;
double numcount4 = table.Rows[1].Cells[4].CellFormat.Width;
double numcount5 = table.Rows[1].Cells[5].CellFormat.Width;
double numcount6 = table.Rows[1].Cells[6].CellFormat.Width;
double numcount7 = table.Rows[1].Cells[7].CellFormat.Width;
double numcount = numcount0 + numcount1 + numcount2 + numcount3 + numcount4 + numcount5 + numcount6 + numcount7;
rowhj.Cells.Add(CreateCell("暂无数据", doc, numcount));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 10-3
var GDInspection = reportItem.Where(x => x.ReType == "10-3").ToList();
if (GDInspection != null || GDInspection.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 16;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0, num3 = 0, num4 = 0;
string num5 = string.Empty;
string num6 = string.Empty;
foreach (var item in GDInspection)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.Rows[0].Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.Rows[0].Cells[1].CellFormat.Width));
// 合并第一行的前两个单元格
table.Rows[0].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
table.Rows[1].Cells[0].CellFormat.VerticalMerge = CellMerge.Previous;
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthsBackCount.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalNoBackCount.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
row.Cells.Add(CreateCell(item.RectificationRate.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex + 1, row);
num1 += item.MonthsCount;
num2 += item.MonthsBackCount;
num3 += item.ProjectCount;
num4 += item.TotalNoBackCount;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
if (num1 != 0)//被除数不能为零
{
num5 = Math.Round((double)num3 / (double)num1 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
num5 = "0%";
}
if (num2 != 0)//被除数不能为零
{
num6 = Math.Round((double)num4 / (double)num2 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
num6 = "0%";
}
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.Rows[0].Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.Rows[0].Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num3.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num4.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num5.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num6.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
else
{
isYm = true;
numberIndex = 1;
whileIndex = 16;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
//创建合计
Row rowhj = new Row(doc);
double numcount0 = table.Rows[0].Cells[0].CellFormat.Width;
double numcount1 = table.Rows[0].Cells[1].CellFormat.Width;
double numcount2 = table.Rows[1].Cells[2].CellFormat.Width;
double numcount3 = table.Rows[1].Cells[3].CellFormat.Width;
double numcount4 = table.Rows[1].Cells[4].CellFormat.Width;
double numcount5 = table.Rows[1].Cells[5].CellFormat.Width;
double numcount6 = table.Rows[1].Cells[6].CellFormat.Width;
double numcount7 = table.Rows[1].Cells[7].CellFormat.Width;
double numcount = numcount0 + numcount1 + numcount2 + numcount3 + numcount4 + numcount5 + numcount6 + numcount7;
rowhj.Cells.Add(CreateCell("暂无数据", doc, numcount));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 10-4
var DQInspection = reportItem.Where(x => x.ReType == "10-4").ToList();
if (DQInspection != null || DQInspection.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 17;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0, num3 = 0, num4 = 0;
string num5 = string.Empty;
string num6 = string.Empty;
foreach (var item in DQInspection)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.Rows[0].Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.Rows[0].Cells[1].CellFormat.Width));
// 合并第一行的前两个单元格
table.Rows[0].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
table.Rows[1].Cells[0].CellFormat.VerticalMerge = CellMerge.Previous;
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthsBackCount.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalNoBackCount.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
row.Cells.Add(CreateCell(item.RectificationRate.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex + 1, row);
num1 += item.MonthsCount;
num2 += item.MonthsBackCount;
num3 += item.ProjectCount;
num4 += item.TotalNoBackCount;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
if (num1 != 0)//被除数不能为零
{
num5 = Math.Round((double)num3 / (double)num1 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
num5 = "0%";
}
if (num2 != 0)//被除数不能为零
{
num6 = Math.Round((double)num4 / (double)num2 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
num6 = "0%";
}
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.Rows[0].Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.Rows[0].Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num3.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num4.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num5.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num6.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
else
{
isYm = true;
numberIndex = 1;
whileIndex = 17;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
//创建合计
Row rowhj = new Row(doc);
double numcount0 = table.Rows[0].Cells[0].CellFormat.Width;
double numcount1 = table.Rows[0].Cells[1].CellFormat.Width;
double numcount2 = table.Rows[1].Cells[2].CellFormat.Width;
double numcount3 = table.Rows[1].Cells[3].CellFormat.Width;
double numcount4 = table.Rows[1].Cells[4].CellFormat.Width;
double numcount5 = table.Rows[1].Cells[5].CellFormat.Width;
double numcount6 = table.Rows[1].Cells[6].CellFormat.Width;
double numcount7 = table.Rows[1].Cells[7].CellFormat.Width;
double numcount = numcount0 + numcount1 + numcount2 + numcount3 + numcount4 + numcount5 + numcount6 + numcount7;
rowhj.Cells.Add(CreateCell("暂无数据", doc, numcount));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 10-5.
var YBInspection = reportItem.Where(x => x.ReType == "10-5").ToList();
if (YBInspection != null || YBInspection.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 18;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0, num3 = 0, num4 = 0;
string num5 = string.Empty;
string num6 = string.Empty;
foreach (var item in YBInspection)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.Rows[0].Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.Rows[0].Cells[1].CellFormat.Width));
// 合并第一行的前两个单元格
table.Rows[0].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
table.Rows[1].Cells[0].CellFormat.VerticalMerge = CellMerge.Previous;
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthsBackCount.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalNoBackCount.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
row.Cells.Add(CreateCell(item.RectificationRate.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex + 1, row);
num1 += item.MonthsCount;
num2 += item.MonthsBackCount;
num3 += item.ProjectCount;
num4 += item.TotalNoBackCount;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
if (num1 != 0)//被除数不能为零
{
num5 = Math.Round((double)num3 / (double)num1 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
num5 = "0%";
}
if (num2 != 0)//被除数不能为零
{
num6 = Math.Round((double)num4 / (double)num2 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
num6 = "0%";
}
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.Rows[0].Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.Rows[0].Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num3.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num4.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num5.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num6.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
else
{
isYm = true;
numberIndex = 1;
whileIndex = 18;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
//创建合计
Row rowhj = new Row(doc);
double numcount0 = table.Rows[0].Cells[0].CellFormat.Width;
double numcount1 = table.Rows[0].Cells[1].CellFormat.Width;
double numcount2 = table.Rows[1].Cells[2].CellFormat.Width;
double numcount3 = table.Rows[1].Cells[3].CellFormat.Width;
double numcount4 = table.Rows[1].Cells[4].CellFormat.Width;
double numcount5 = table.Rows[1].Cells[5].CellFormat.Width;
double numcount6 = table.Rows[1].Cells[6].CellFormat.Width;
double numcount7 = table.Rows[1].Cells[7].CellFormat.Width;
double numcount = numcount0 + numcount1 + numcount2 + numcount3 + numcount4 + numcount5 + numcount6 + numcount7;
rowhj.Cells.Add(CreateCell("暂无数据", doc, numcount));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 10-6.
var FFInspection = reportItem.Where(x => x.ReType == "10-6").ToList();
if (FFInspection != null || FFInspection.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 19;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0, num3 = 0, num4 = 0;
string num5 = string.Empty;
string num6 = string.Empty;
foreach (var item in FFInspection)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.Rows[0].Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.Rows[0].Cells[1].CellFormat.Width));
// 合并第一行的前两个单元格
table.Rows[0].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
table.Rows[1].Cells[0].CellFormat.VerticalMerge = CellMerge.Previous;
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthsBackCount.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalNoBackCount.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
row.Cells.Add(CreateCell(item.RectificationRate.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex + 1, row);
num1 += item.MonthsCount;
num2 += item.MonthsBackCount;
num3 += item.ProjectCount;
num4 += item.TotalNoBackCount;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
if (num1 != 0)//被除数不能为零
{
num5 = Math.Round((double)num3 / (double)num1 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
num5 = "0%";
}
if (num2 != 0)//被除数不能为零
{
num6 = Math.Round((double)num4 / (double)num2 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
num6 = "0%";
}
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.Rows[0].Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.Rows[0].Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num3.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num4.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num5.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num6.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
else
{
isYm = true;
numberIndex = 1;
whileIndex = 19;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
//创建合计
Row rowhj = new Row(doc);
double numcount0 = table.Rows[0].Cells[0].CellFormat.Width;
double numcount1 = table.Rows[0].Cells[1].CellFormat.Width;
double numcount2 = table.Rows[1].Cells[2].CellFormat.Width;
double numcount3 = table.Rows[1].Cells[3].CellFormat.Width;
double numcount4 = table.Rows[1].Cells[4].CellFormat.Width;
double numcount5 = table.Rows[1].Cells[5].CellFormat.Width;
double numcount6 = table.Rows[1].Cells[6].CellFormat.Width;
double numcount7 = table.Rows[1].Cells[7].CellFormat.Width;
double numcount = numcount0 + numcount1 + numcount2 + numcount3 + numcount4 + numcount5 + numcount6 + numcount7;
rowhj.Cells.Add(CreateCell("暂无数据", doc, numcount));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 10-7.
var XFInspection = reportItem.Where(x => x.ReType == "10-7").ToList();
if (XFInspection != null || XFInspection.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 20;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0, num3 = 0, num4 = 0;
string num5 = string.Empty;
string num6 = string.Empty;
foreach (var item in XFInspection)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.Rows[0].Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.Rows[0].Cells[1].CellFormat.Width));
// 合并第一行的前两个单元格
table.Rows[0].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
table.Rows[1].Cells[0].CellFormat.VerticalMerge = CellMerge.Previous;
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthsBackCount.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalNoBackCount.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
row.Cells.Add(CreateCell(item.RectificationRate.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex + 1, row);
num1 += item.MonthsCount;
num2 += item.MonthsBackCount;
num3 += item.ProjectCount;
num4 += item.TotalNoBackCount;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
if (num1 != 0)//被除数不能为零
{
num5 = Math.Round((double)num3 / (double)num1 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
num5 = "0%";
}
if (num2 != 0)//被除数不能为零
{
num6 = Math.Round((double)num4 / (double)num2 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
num6 = "0%";
}
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.Rows[0].Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.Rows[0].Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num3.ToString(), doc, table.Rows[1].Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num4.ToString(), doc, table.Rows[1].Cells[5].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num5.ToString(), doc, table.Rows[1].Cells[6].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num6.ToString(), doc, table.Rows[1].Cells[7].CellFormat.Width));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
else
{
isYm = true;
numberIndex = 1;
whileIndex = 20;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
//创建合计
Row rowhj = new Row(doc);
double numcount0 = table.Rows[0].Cells[0].CellFormat.Width;
double numcount1 = table.Rows[0].Cells[1].CellFormat.Width;
double numcount2 = table.Rows[1].Cells[2].CellFormat.Width;
double numcount3 = table.Rows[1].Cells[3].CellFormat.Width;
double numcount4 = table.Rows[1].Cells[4].CellFormat.Width;
double numcount5 = table.Rows[1].Cells[5].CellFormat.Width;
double numcount6 = table.Rows[1].Cells[6].CellFormat.Width;
double numcount7 = table.Rows[1].Cells[7].CellFormat.Width;
double numcount = numcount0 + numcount1 + numcount2 + numcount3 + numcount4 + numcount5 + numcount6 + numcount7;
rowhj.Cells.Add(CreateCell("暂无数据", doc, numcount));
table.Rows.Insert(numberIndex + 1, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 10.
var InspectionDataInspection = reportItem.Where(x => x.ReType == "10").ToList();
if (InspectionDataInspection != null || InspectionDataInspection.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 21;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
//decimal? num1 = 0, num2 = 0;
//decimal MonthsCountstring = 0, ProjectCountstring = 0;
int CheckNum = 0, OKNum = 0, TotalCheckNum = 0, TotalOKNum = 0;
string QuantitySum1 = String.Empty;//本月检查合格点数/本月检查点数
string QuantitySum2 = String.Empty;//累计检查合格点数/累计检查点数
foreach (var item in InspectionDataInspection)
{
if (string.IsNullOrEmpty(item.RectificationRate))
{
item.RectificationRate = "0%";
}
if (string.IsNullOrEmpty(item.TotationRate))
{
item.TotationRate = "0%";
}
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(Convert.ToString(item.RectificationRate), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(Convert.ToString(item.TotationRate), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, row);
//num1 += MonthsCountstring;
//num2 += ProjectCountstring;
CheckNum += Convert.ToInt32(item.MonthsCount);
OKNum += Convert.ToInt32(item.ProjectCount);
TotalCheckNum += Convert.ToInt32(item.MonthsBackCount);
TotalOKNum += Convert.ToInt32(item.TotalNoBackCount);
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
if (CheckNum != 0)//被除数不能为零
{
QuantitySum1 = Math.Round((decimal)OKNum / (decimal)CheckNum * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
QuantitySum1 = "0%";
}
if (TotalCheckNum != 0)//被除数不能为零
{
QuantitySum2 = Math.Round((decimal)TotalOKNum / (decimal)TotalCheckNum * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
QuantitySum2 = "0%";
}
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(QuantitySum1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(QuantitySum2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#endregion
#region 11.
var PressureInspection = reportItem.Where(x => x.ReType == "11").ToList();
if (PressureInspection.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 22;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0, num3 = 0;
foreach (var item in PressureInspection)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalNoBackCount.ToString(), doc, table.FirstRow.Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[5].CellFormat.Width, "", "", "unit"));
table.Rows.Insert(numberIndex, row);
num1 += item.MonthsCount;
num2 += item.ProjectCount;
num3 += item.TotalNoBackCount;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num3.ToString(), doc, table.FirstRow.Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[5].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 12.
var PipingInspection = reportItem.Where(x => x.ReType == "12").ToList();
if (PipingInspection.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 23;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0, num3 = 0;
foreach (var item in PipingInspection)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.TotalNoBackCount.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.FirstRow.Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[5].CellFormat.Width, "", "", "unit"));
table.Rows.Insert(numberIndex, row);
num3 += item.TotalNoBackCount;
num1 += item.MonthsCount;
num2 += item.ProjectCount;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num3.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[5].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 13.
var SpecialInspection = reportItem.Where(x => x.ReType == "13").ToList();
if (SpecialInspection.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 24;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0, num3 = 0;
foreach (var item in SpecialInspection)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.TotalNoBackCount.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.FirstRow.Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[5].CellFormat.Width, "", "", "unit"));
table.Rows.Insert(numberIndex, row);
num1 += item.MonthsCount;
num2 += item.ProjectCount;
num3 += item.TotalNoBackCount;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num3.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[5].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 14.NCR管理情况
var NcrManagementInspection = reportItem.Where(x => x.ReType == "14").ToList();
if (NcrManagementInspection.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 25;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0, num3 = 0;
string num4 = string.Empty;
foreach (var item in NcrManagementInspection)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalNoBackCount.ToString(), doc, table.FirstRow.Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.RectificationRate.ToString(), doc, table.FirstRow.Cells[5].CellFormat.Width));
table.Rows.Insert(numberIndex, row);
num1 += item.MonthsCount;
num2 += item.ProjectCount;
num3 += item.TotalNoBackCount;
numberIndex += 1;
}
if (num2 != 0)//被除数不能为零
{
num4 = Math.Round((double)num2 / (double)num3 * 100, 2) + "%";//保留两位小数、后四舍五3
}
else
{
num4 = "0%";
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num3.ToString(), doc, table.FirstRow.Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num4.ToString(), doc, table.FirstRow.Cells[5].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 15.
var qualityInspections = reportItem.Where(x => x.ReType == "1").ToList();
if (qualityInspections.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 26;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0;
foreach (var item in qualityInspections)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.RectificationRate, doc, table.FirstRow.Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[5].CellFormat.Width, "", "", "unit"));
table.Rows.Insert(numberIndex, row);
num1 += item.MonthsCount;
num2 += item.ProjectCount;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[5].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 16.
var specialChecks = reportItem.Where(x => x.ReType == "2").ToList();
if (specialChecks.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 27;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0;
foreach (var item in specialChecks)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.FirstRow.Cells[1].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, row);
num1 += item.MonthsCount;
num2 += item.ProjectCount;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[4].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 17.
var fileReports = reportItem.Where(x => x.ReType == "3").ToList();
if (fileReports.Count > 0)
{
isYm = true;
//whileIndex += 1;
whileIndex = 28;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
//跳过页眉的表头
while (isYm)
{
if (table.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm = false;
}
}
numberIndex = 1;
int? num1 = 0, num2 = 0, num3 = 0, num4 = 0;
foreach (var item in fileReports)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ContentName, doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.MonthsCount.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProjectCount.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthsBackCount.ToString(), doc, table.FirstRow.Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalNoBackCount.ToString(), doc, table.FirstRow.Cells[5].CellFormat.Width));
table.Rows.Insert(numberIndex, row);
num1 += item.MonthsCount;
num2 += item.ProjectCount;
num3 += item.MonthsBackCount;
num4 += item.TotalNoBackCount;
numberIndex += 1;
}
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
//创建合计
Row rowhj = new Row(doc);
rowhj.Cells.Add(CreateCell("", doc, table.FirstRow.Cells[0].CellFormat.Width));
rowhj.Cells.Add(CreateCell("合计", doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
rowhj.Cells.Add(CreateCell(num1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num3.ToString(), doc, table.FirstRow.Cells[4].CellFormat.Width));
rowhj.Cells.Add(CreateCell(num4.ToString(), doc, table.FirstRow.Cells[5].CellFormat.Width));
table.Rows.Insert(numberIndex, rowhj);
//自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths);
}
#endregion
#region 18.
#region (1)
whileIndex = 29;
Aspose.Words.Tables.Table table18_1 = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
bool isYm18_1 = true;
//跳过页眉的表头
while (isYm18_1)
{
if (table18_1.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table18_1 = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm18_1 = false;
}
}
var rowMaterialProblems = db.Report_RowMaterialProblem.Where(x => x.ReportId == Id);
int numberIndex18_1 = 1;
foreach (var item in rowMaterialProblems)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex18_1.ToString(), doc, table18_1.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.UnitId, doc, table18_1.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.ProblemDesrioption, doc, table18_1.FirstRow.Cells[2].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.TreatmentMeasures, doc, table18_1.FirstRow.Cells[3].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.ProcessingResults, doc, table18_1.FirstRow.Cells[4].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.Remark, doc, table18_1.FirstRow.Cells[5].CellFormat.Width, "", "", "unit"));
table18_1.Rows.Insert(numberIndex18_1, row);
numberIndex18_1 += 1;
}
//自动设置表格样式
table18_1.AutoFit(AutoFitBehavior.FixedColumnWidths);
#endregion
#region (2)
whileIndex = 30;
Aspose.Words.Tables.Table table18_2 = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
bool isYm18_2 = true;
//跳过页眉的表头
while (isYm18_2)
{
if (table18_2.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table18_2 = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm18_2 = false;
}
}
var constructionProblems = db.Report_ConstructionProblems.Where(x => x.ReportId == Id);
int numberIndex18_2 = 1;
foreach (var item in constructionProblems)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex18_2.ToString(), doc, table18_2.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.UnitId, doc, table18_2.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.ProblemDesrioption, doc, table18_2.FirstRow.Cells[2].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.TreatmentMeasures, doc, table18_2.FirstRow.Cells[3].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.ProcessingResults, doc, table18_2.FirstRow.Cells[4].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.Remark, doc, table18_2.FirstRow.Cells[5].CellFormat.Width, "", "", "unit"));
table18_2.Rows.Insert(numberIndex18_2, row);
numberIndex18_2 += 1;
}
//自动设置表格样式
table18_2.AutoFit(AutoFitBehavior.FixedColumnWidths);
#endregion
#endregion
#region 19.
whileIndex = 31;
Aspose.Words.Tables.Table table19 = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
bool isYm19 = true;
//跳过页眉的表头
while (isYm19)
{
if (table19.Range.Text.Substring(0, 2) != "序号")
{
whileIndex += 1;
table19 = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
}
else
{
isYm19 = false;
}
}
var nextQualityControls = db.Report_NextQualityControl.Where(x => x.ReportId == Id);
int numberIndex19 = 1;
foreach (var item in nextQualityControls)
{
//创建行
Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex19.ToString(), doc, table19.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.NextQualityControlContent, doc, table19.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
table19.Rows.Insert(numberIndex19, row);
numberIndex19 += 1;
}
//自动设置表格样式
table19.AutoFit(AutoFitBehavior.FixedColumnWidths);
#endregion
#region 20.
bkmark = doc.Range.Bookmarks["Content20"];
if (bkmark != null)
{
bkmark.Text = txtReportList.FirstOrDefault(x => x.ContentType == "20").ContentText;
}
#endregion
#region 21.
bkmark = doc.Range.Bookmarks["Content21"];
if (bkmark != null)
{
bkmark.Text = txtReportList.FirstOrDefault(x => x.ContentType == "21").ContentText;
}
#endregion
#region 22.
bkmark = doc.Range.Bookmarks["Content22"];
if (bkmark != null)
{
bkmark.Text = txtReportList.FirstOrDefault(x => x.ContentType == "22").ContentText;
}
#endregion
#region 23.
string imageUrl = "res/images/R-C.png";
var imageUrl1 = txtReportList.FirstOrDefault(x => x.ContentType == "23-1").ImageUrl;
if (!string.IsNullOrWhiteSpace(imageUrl1) && imageUrl1 != imageUrl)
{
string rootPathUrl = rootPath.Replace("\\", "/");
string url = rootPathUrl + imageUrl1;
//DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToBookmark("ImageUrl1");
if (!string.IsNullOrEmpty(url))
{
System.Drawing.Size JpgSize;
float Wpx;
float Hpx;
UploadAttachmentService.getJpgSize(rootPathUrl + imageUrl1, out JpgSize, out Wpx, out Hpx);
//double w = 1;
//w = JpgSize.Width / 50.0;
if (File.Exists(url))
{
//builder.InsertImage(url, JpgSize.Width / w, JpgSize.Height / w);
builder.InsertImage(url, 200, 150);
}
}
}
var imageUrl2 = txtReportList.FirstOrDefault(x => x.ContentType == "23-2").ImageUrl;
if (!string.IsNullOrWhiteSpace(imageUrl2) && imageUrl2 != imageUrl)
{
string rootPathUrl = rootPath.Replace("\\", "/");
string url = rootPathUrl + imageUrl2;
//DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToBookmark("ImageUrl2");
if (!string.IsNullOrEmpty(url))
{
System.Drawing.Size JpgSize;
float Wpx;
float Hpx;
UploadAttachmentService.getJpgSize(rootPathUrl + imageUrl2, out JpgSize, out Wpx, out Hpx);
//double w = 1;
//w = JpgSize.Width / 50.0;
if (File.Exists(url))
{
//builder.InsertImage(url, JpgSize.Width / w, JpgSize.Height / w);
builder.InsertImage(url, 200, 150);
}
}
}
var imageUrl3 = txtReportList.FirstOrDefault(x => x.ContentType == "23-3").ImageUrl;
if (!string.IsNullOrWhiteSpace(imageUrl3) && imageUrl3 != imageUrl)
{
string rootPathUrl = rootPath.Replace("\\", "/");
string url = rootPathUrl + imageUrl3;
//DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToBookmark("ImageUrl3");
if (!string.IsNullOrEmpty(url))
{
System.Drawing.Size JpgSize;
float Wpx;
float Hpx;
UploadAttachmentService.getJpgSize(rootPathUrl + imageUrl3, out JpgSize, out Wpx, out Hpx);
//double w = 1;
//w = JpgSize.Width / 50.0;
if (File.Exists(url))
{
//builder.InsertImage(url, JpgSize.Width / w, JpgSize.Height / w);
builder.InsertImage(url, 200, 150);
}
}
}
var imageUrl4 = txtReportList.FirstOrDefault(x => x.ContentType == "23-4").ImageUrl;
if (!string.IsNullOrWhiteSpace(imageUrl4) && imageUrl4 != imageUrl)
{
string rootPathUrl = rootPath.Replace("\\", "/");
string url = rootPathUrl + imageUrl4;
//DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToBookmark("ImageUrl4");
if (!string.IsNullOrEmpty(url))
{
System.Drawing.Size JpgSize;
float Wpx;
float Hpx;
UploadAttachmentService.getJpgSize(rootPathUrl + imageUrl4, out JpgSize, out Wpx, out Hpx);
//double w = 1;
//w = JpgSize.Width / 50.0;
if (File.Exists(url))
{
//builder.InsertImage(url, JpgSize.Width / w, JpgSize.Height / w);
builder.InsertImage(url, 200, 150);
}
}
}
var imageUrl5 = txtReportList.FirstOrDefault(x => x.ContentType == "23-5").ImageUrl;
if (!string.IsNullOrWhiteSpace(imageUrl5) && imageUrl5 != imageUrl)
{
string rootPathUrl = rootPath.Replace("\\", "/");
string url = rootPathUrl + imageUrl5;
//DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToBookmark("ImageUrl5");
if (!string.IsNullOrEmpty(url))
{
System.Drawing.Size JpgSize;
float Wpx;
float Hpx;
UploadAttachmentService.getJpgSize(rootPathUrl + imageUrl5, out JpgSize, out Wpx, out Hpx);
//double w = 1;
//w = JpgSize.Width / 50.0;
if (File.Exists(url))
{
//builder.InsertImage(url, JpgSize.Width / w, JpgSize.Height / w);
builder.InsertImage(url, 200, 150);
}
}
}
var imageUrl6 = txtReportList.FirstOrDefault(x => x.ContentType == "23-6").ImageUrl;
if (!string.IsNullOrWhiteSpace(imageUrl6) && imageUrl6 != imageUrl)
{
string rootPathUrl = rootPath.Replace("\\", "/");
string url = rootPathUrl + imageUrl6;
//DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToBookmark("ImageUrl6");
if (!string.IsNullOrEmpty(url))
{
System.Drawing.Size JpgSize;
float Wpx;
float Hpx;
UploadAttachmentService.getJpgSize(rootPathUrl + imageUrl6, out JpgSize, out Wpx, out Hpx);
//double w = 1;
//w = JpgSize.Width / 50.0;
if (File.Exists(url))
{
//builder.InsertImage(url, JpgSize.Width / w, JpgSize.Height / w);
builder.InsertImage(url, 200, 150);
}
}
}
bkmark = doc.Range.Bookmarks["ImageContent1"];
if (bkmark != null)
{
bkmark.Text = txtReportList.FirstOrDefault(x => x.ContentType == "23-1").ContentText;
}
bkmark = doc.Range.Bookmarks["ImageContent2"];
if (bkmark != null)
{
bkmark.Text = txtReportList.FirstOrDefault(x => x.ContentType == "23-2").ContentText;
}
bkmark = doc.Range.Bookmarks["ImageContent3"];
if (bkmark != null)
{
bkmark.Text = txtReportList.FirstOrDefault(x => x.ContentType == "23-3").ContentText;
}
bkmark = doc.Range.Bookmarks["ImageContent4"];
if (bkmark != null)
{
bkmark.Text = txtReportList.FirstOrDefault(x => x.ContentType == "23-4").ContentText;
}
bkmark = doc.Range.Bookmarks["ImageContent5"];
if (bkmark != null)
{
bkmark.Text = txtReportList.FirstOrDefault(x => x.ContentType == "23-5").ContentText;
}
bkmark = doc.Range.Bookmarks["ImageContent6"];
if (bkmark != null)
{
bkmark.Text = txtReportList.FirstOrDefault(x => x.ContentType == "23-6").ContentText;
}
#endregion
#region
whileIndex = 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 1, true);
if (unitsYz != null)
{
//业主名称
table.Rows[0].Cells[2].FirstParagraph.Runs[0].Text = unitsYz.UnitName;
}
//项目号
table.Rows[0].Cells[4].FirstParagraph.Runs[0].Text = pModel.ProjectCode;
//项目名称
table.Rows[2].Cells[2].FirstParagraph.Runs[0].Text = pModel.ProjectName;
table.Rows[2].Cells[3].FirstParagraph.Runs[0].Text = pModel.ProjectCode + "-RM-PQM-" + weekModel.SortId;
//总页数
table.Rows[4].Cells[5].FirstParagraph.Runs[0].Text = doc.PageCount.ToString();
bkmark = doc.Range.Bookmarks["CountPage"];
if (bkmark != null)
{
bkmark.Text = doc.PageCount.ToString();
}
//页眉是第二个表
//tableIndex—要移动的表的索引。
//rowIndex - 表中行的索引。
//columnIndex—表中列的索引。
//字符在单元格中的索引。目前只能指定0移动到单元格的开头或指定 - 1移动到单元格的结尾。
//builder.MoveToCell(1,0,2,0);
//builder.Write(unitsYz.UnitName);
#endregion
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);
}
catch (Exception ex)
{
Alert.ShowInTop(ex.Message, MessageBoxIcon.Warning);
throw;
}
}
#endregion
}
}