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

1230 lines
62 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
from Report_WeekAndMonthReport_New C
where 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.CQWeekReportNewMenuId);
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)
{
Cell cell = new Cell(doc);
Paragraph p = new Paragraph(doc);
p.AppendChild(new Run(doc, value));
cell.CellFormat.Width = cellWidth;
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");
if (File.Exists(newUrl))
{
File.Delete(newUrl);
}
File.Copy(uploadfilepath, newUrl);
//更新书签内容
Document doc = new Aspose.Words.Document(newUrl);
DocumentBuilder builder = new DocumentBuilder(doc);
//根据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);
#region
Bookmark bkmark = doc.Range.Bookmarks["username"];
if (bkmark != null) {
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+"("+ pModel.ProjectCode + ")";
}
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+",";
}
bkmark.Text = zlName;
}
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));
row.Cells.Add(CreateCell(item.ProStage, doc, table.FirstRow.Cells[1].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProDescribe, doc, table.FirstRow.Cells[2].CellFormat.Width));
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));
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;
}
#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));
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 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));
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.Quantity3.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;
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));
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));
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));
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));
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 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.Status == "3").ToString(); //当期完成数
checkStatisc.TotalOneOKRate = totalManagementList.Count(x => x.Status == "3").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));
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));
row.Cells.Add(CreateCell(item.UnitName, doc, table.Rows[0].Cells[1].CellFormat.Width));
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));
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));
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
var reportItem = db.Report_CQMS_MonthReportItem.Where(x => x.ReportId == Id).OrderBy(x => x.ContentName).ToList();
#region 9.
#endregion
#region 10.
#endregion
#region 11.
#endregion
#region 12.
#endregion
#region 13.
#endregion
#region 14.NCR管理情况
#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));
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.RectificationRate, 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.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));
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));
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));
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.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));
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));
row.Cells.Add(CreateCell(item.UnitId, doc, table18_1.FirstRow.Cells[1].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProblemDesrioption, doc, table18_1.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.TreatmentMeasures, doc, table18_1.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProcessingResults, doc, table18_1.FirstRow.Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remark, doc, table18_1.FirstRow.Cells[5].CellFormat.Width));
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));
row.Cells.Add(CreateCell(item.UnitId, doc, table18_2.FirstRow.Cells[1].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProblemDesrioption, doc, table18_2.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.TreatmentMeasures, doc, table18_2.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.ProcessingResults, doc, table18_2.FirstRow.Cells[4].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remark, doc, table18_2.FirstRow.Cells[5].CellFormat.Width));
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));
row.Cells.Add(CreateCell(item.NextQualityControlContent, doc, table19.FirstRow.Cells[1].CellFormat.Width));
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
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
}
}