634 lines
35 KiB
C#
634 lines
35 KiB
C#
|
using BLL;
|
|||
|
using Model;
|
|||
|
using NPOI.SS.UserModel;
|
|||
|
using NPOI.SS.Util;
|
|||
|
using NPOI.XSSF.UserModel;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Data;
|
|||
|
using System.Data.SqlClient;
|
|||
|
using System.IO;
|
|||
|
|
|||
|
namespace FineUIPro.Web.HJGL.WeldingReport
|
|||
|
{
|
|||
|
public partial class NDTMonthReport : PageBase
|
|||
|
{
|
|||
|
#region 定义变量
|
|||
|
/// <summary>
|
|||
|
/// 主键
|
|||
|
/// </summary>
|
|||
|
public string NDTReportId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["NDTReportId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["NDTReportId"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 加载
|
|||
|
/// <summary>
|
|||
|
/// 加载页面
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void BindGrid()
|
|||
|
{
|
|||
|
List<SpRpNDTWeekReport> list = new List<SpRpNDTWeekReport>();
|
|||
|
List<Model.NDTReport> NDTReportLists = BLL.NDTReportService.GetNDTReportByProjectId(this.CurrUser.LoginProjectId, "2");
|
|||
|
foreach (var item in NDTReportLists)
|
|||
|
{
|
|||
|
SpRpNDTWeekReport t = new SpRpNDTWeekReport();
|
|||
|
t.NDTReportId = item.NDTReportId;
|
|||
|
t.ProjectId = item.ProjectId;
|
|||
|
t.ProjectName = BLL.ProjectService.GetProjectNameByProjectId(item.ProjectId);
|
|||
|
t.StaDate = string.Format("{0:yyyy-MM-dd}", item.StartDate) + "至" + string.Format("{0:yyyy-MM-dd}", item.EndDate);
|
|||
|
list.Add(t);
|
|||
|
}
|
|||
|
this.Grid1.DataSource = list;
|
|||
|
this.Grid1.DataBind();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|||
|
{
|
|||
|
object[] keys = Grid1.DataKeys[e.RowIndex];
|
|||
|
string fileId = string.Empty;
|
|||
|
if (keys == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
fileId = keys[0].ToString();
|
|||
|
}
|
|||
|
if (e.CommandName == "print")
|
|||
|
{
|
|||
|
string dateStr = Grid1.Rows[e.RowIndex].Values[2].ToString();
|
|||
|
var dates = dateStr.Split('至');
|
|||
|
DateTime begin = DateTime.Parse(dates[0]);
|
|||
|
DateTime end = DateTime.Parse(dates[1]);
|
|||
|
DateTime probegin = begin.AddMonths(-1);
|
|||
|
DateTime proend = begin.AddDays(-1);
|
|||
|
|
|||
|
var projectName = ProjectService.GetProjectNameByProjectId(CurrUser.LoginProjectId);
|
|||
|
|
|||
|
|
|||
|
string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
|
|||
|
//模板文件
|
|||
|
string TempletFileName = Server.MapPath("~/") + "File/Excel/HJGL_DataOut/无损检测月报.xlsx";
|
|||
|
//导出文件
|
|||
|
string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
|
|||
|
if (!Directory.Exists(filePath))
|
|||
|
{
|
|||
|
Directory.CreateDirectory(filePath);
|
|||
|
}
|
|||
|
string ReportFileName = filePath + "out.xlsx";
|
|||
|
|
|||
|
FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
|
|||
|
XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
|
|||
|
|
|||
|
ICellStyle styleCenter = hssfworkbook.CreateCellStyle();
|
|||
|
styleCenter.VerticalAlignment = VerticalAlignment.Center;
|
|||
|
styleCenter.Alignment = HorizontalAlignment.Center;
|
|||
|
styleCenter.BorderLeft = BorderStyle.Thin;
|
|||
|
styleCenter.BorderTop = BorderStyle.Thin;
|
|||
|
styleCenter.BorderRight = BorderStyle.Thin;
|
|||
|
styleCenter.BorderBottom = BorderStyle.Thin;
|
|||
|
styleCenter.WrapText = true;
|
|||
|
IFont font = styleCenter.GetFont(hssfworkbook);
|
|||
|
font.FontHeightInPoints = 10;//字体高度(与excel中的字号一致)
|
|||
|
styleCenter.SetFont(font);
|
|||
|
XSSFSheet recordSheet = (XSSFSheet)hssfworkbook.GetSheet("无损检测月报");
|
|||
|
|
|||
|
// recordSheet.AddMergedRegion(new CellRangeAddress(0, 0, 8, 9));
|
|||
|
|
|||
|
|
|||
|
recordSheet.GetRow(2).GetCell(2).SetCellValue(projectName.ToString());
|
|||
|
//recordSheet.GetRow(2).GetCell(2).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(2).GetCell(16).SetCellValue(dateStr);
|
|||
|
//recordSheet.GetRow(2).GetCell(16).CellStyle = styleCenter;
|
|||
|
List<Base_Unit> units = UnitService.GetUnitByProjectIdUnitTypeList(this.CurrUser.LoginProjectId, Const.ProjectUnitType_5);
|
|||
|
string unitName = "";
|
|||
|
foreach (Base_Unit unit in units)
|
|||
|
{
|
|||
|
unitName += unit.UnitName + ",";
|
|||
|
}
|
|||
|
recordSheet.GetRow(3).GetCell(2).SetCellValue(unitName.TrimEnd(','));
|
|||
|
//recordSheet.GetRow(3).GetCell(2).CellStyle = styleCenter;
|
|||
|
|
|||
|
|
|||
|
string strSql1 = @"select unit.UnitId,unit.UnitName,workArea.WorkAreaName,workArea.WorkAreaCode,curr.curr_pass_film,curr.curr_total_film,pro.pro_pass_film,pro.pro_total_film,total.pass_film,total.total_film,recurr.recurr_pass_film,recurr.recurr_total_film,retotal.retotal_pass_film,retotal.retotal_total_film
|
|||
|
from Base_Unit unit right join
|
|||
|
ProjectData_WorkArea workArea on workArea.UnitId=unit.UnitId
|
|||
|
left join
|
|||
|
( SELECT WorkAreaId,IsoInfo.UnitId,COUNT(*) AS check_count_total
|
|||
|
, SUM(cht_totalfilm) AS total_film
|
|||
|
, SUM(cht_passfilm) AS pass_film
|
|||
|
FROM CH_Check Checks
|
|||
|
LEFT JOIN CH_CheckItem ON ch_checkitem.CHT_CheckID = Checks.CHT_CheckID
|
|||
|
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = ch_checkitem.JOT_ID
|
|||
|
LEFT JOIN PW_IsoInfo as IsoInfo ON IsoInfo.ISO_ID = JointInfo.ISO_ID
|
|||
|
where JointInfo.ProjectId=@ProjectId
|
|||
|
group by WorkAreaId,IsoInfo.UnitId) as total on unit.UnitId= total.UnitId and workArea.WorkAreaId=total.WorkAreaId
|
|||
|
left join
|
|||
|
( SELECT WorkAreaId,IsoInfo.UnitId,COUNT(*) AS curr_check_count_total
|
|||
|
, SUM(cht_totalfilm) AS curr_total_film
|
|||
|
, SUM(cht_passfilm) AS curr_pass_film
|
|||
|
FROM CH_Check Checks
|
|||
|
LEFT JOIN CH_CheckItem ON ch_checkitem.CHT_CheckID = Checks.CHT_CheckID
|
|||
|
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = ch_checkitem.JOT_ID
|
|||
|
LEFT JOIN PW_IsoInfo as IsoInfo ON IsoInfo.ISO_ID = JointInfo.ISO_ID
|
|||
|
where JointInfo.ProjectId=@ProjectId and (cht_checkdate >= @date1 OR @date1 IS NULL) and(cht_checkdate <= @date2 OR @date2 IS NULL)
|
|||
|
group by WorkAreaId,IsoInfo.UnitId) as curr on unit.UnitId= curr.UnitId and workArea.WorkAreaId=curr.WorkAreaId
|
|||
|
left join
|
|||
|
( SELECT WorkAreaId,IsoInfo.UnitId,COUNT(*) AS pro_check_count_total
|
|||
|
, SUM(cht_totalfilm) AS pro_total_film
|
|||
|
, SUM(cht_passfilm) AS pro_pass_film
|
|||
|
FROM CH_Check Checks
|
|||
|
LEFT JOIN CH_CheckItem ON ch_checkitem.CHT_CheckID = Checks.CHT_CheckID
|
|||
|
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = ch_checkitem.JOT_ID
|
|||
|
LEFT JOIN PW_IsoInfo as IsoInfo ON IsoInfo.ISO_ID = JointInfo.ISO_ID
|
|||
|
where JointInfo.ProjectId=@ProjectId and (cht_checkdate >= @date3 OR @date3 IS NULL) and(cht_checkdate <= @date4 OR @date4 IS NULL)
|
|||
|
group by WorkAreaId,IsoInfo.UnitId) as pro on unit.UnitId= pro.UnitId and workArea.WorkAreaId=pro.WorkAreaId
|
|||
|
left join
|
|||
|
( SELECT WorkAreaId,IsoInfo.UnitId,COUNT(*) AS recurr_check_count_total
|
|||
|
, SUM(cht_totalfilm) AS recurr_total_film
|
|||
|
, SUM(cht_passfilm) AS recurr_pass_film
|
|||
|
FROM CH_Check Checks
|
|||
|
LEFT JOIN CH_CheckItem ON ch_checkitem.CHT_CheckID = Checks.CHT_CheckID
|
|||
|
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = ch_checkitem.JOT_ID
|
|||
|
LEFT JOIN PW_IsoInfo as IsoInfo ON IsoInfo.ISO_ID = JointInfo.ISO_ID
|
|||
|
LEFT JOIN CH_Trust trust on trust.CH_TrustID = Checks.CH_TrustID
|
|||
|
where JointInfo.ProjectId=@ProjectId and trust.CH_TrustType='2' and (cht_checkdate >= @date1 OR @date1 IS NULL) and(cht_checkdate <= @date2 OR @date2 IS NULL)
|
|||
|
group by WorkAreaId,IsoInfo.UnitId) as recurr on unit.UnitId= recurr.UnitId and workArea.WorkAreaId=recurr.WorkAreaId
|
|||
|
left join
|
|||
|
( SELECT WorkAreaId,IsoInfo.UnitId,COUNT(*) AS retotal_check_count_total
|
|||
|
, SUM(cht_totalfilm) AS retotal_total_film
|
|||
|
, SUM(cht_passfilm) AS retotal_pass_film
|
|||
|
FROM CH_Check Checks
|
|||
|
LEFT JOIN CH_CheckItem ON ch_checkitem.CHT_CheckID = Checks.CHT_CheckID
|
|||
|
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = ch_checkitem.JOT_ID
|
|||
|
LEFT JOIN PW_IsoInfo as IsoInfo ON IsoInfo.ISO_ID = JointInfo.ISO_ID
|
|||
|
LEFT JOIN CH_Trust trust on trust.CH_TrustID = Checks.CH_TrustID
|
|||
|
where JointInfo.ProjectId=@ProjectId and trust.CH_TrustType='2'
|
|||
|
group by WorkAreaId,IsoInfo.UnitId) as retotal on unit.UnitId= retotal.UnitId and workArea.WorkAreaId=retotal.WorkAreaId
|
|||
|
where workArea.ProjectId=@ProjectId ";
|
|||
|
|
|||
|
|
|||
|
List<SqlParameter> listpar = new List<SqlParameter>
|
|||
|
{
|
|||
|
new SqlParameter("@projectId", this.CurrUser.LoginProjectId)
|
|||
|
};
|
|||
|
|
|||
|
listpar.Add(new SqlParameter("@date1", begin.ToString("yyyy-MM-dd")));
|
|||
|
listpar.Add(new SqlParameter("@date2", end.ToString("yyyy-MM-dd")));
|
|||
|
|
|||
|
listpar.Add(new SqlParameter("@date3", probegin.ToString("yyyy-MM-dd")));
|
|||
|
listpar.Add(new SqlParameter("@date4", proend.ToString("yyyy-MM-dd")));
|
|||
|
|
|||
|
SqlParameter[] parameter5 = listpar.ToArray();
|
|||
|
DataTable dt = SQLHelper.GetDataTableRunText(strSql1, parameter5);
|
|||
|
|
|||
|
if (dt != null)
|
|||
|
{
|
|||
|
if (dt.Rows.Count > 10)
|
|||
|
{
|
|||
|
recordSheet.ShiftRows(8, 20, dt.Rows.Count - 10);
|
|||
|
for (int j = 0; j < dt.Rows.Count - 10; j++)
|
|||
|
{
|
|||
|
recordSheet.CopyRow(7 + j, 8 + j);
|
|||
|
}
|
|||
|
|
|||
|
for (int ii = 1; ii <= dt.Rows.Count; ii++)
|
|||
|
{
|
|||
|
CellRangeAddress region = new CellRangeAddress(5 + ii, 5 + ii, 1, 2);
|
|||
|
recordSheet.AddMergedRegion(region);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
for (int ii = 1; ii <= 10; ii++)
|
|||
|
{
|
|||
|
CellRangeAddress region = new CellRangeAddress(5 + ii, 5 + ii, 1, 2);
|
|||
|
recordSheet.AddMergedRegion(region);
|
|||
|
}
|
|||
|
}
|
|||
|
int curr_pass_film = 0;
|
|||
|
int curr_total_film = 0;
|
|||
|
int pro_pass_film = 0;
|
|||
|
int pro_total_film = 0;
|
|||
|
int pass_film = 0;
|
|||
|
int total_film = 0;
|
|||
|
int recurr_pass_film = 0;
|
|||
|
int recurr_total_film = 0;
|
|||
|
int retotal_pass_film = 0;
|
|||
|
int retotal_total_film = 0;
|
|||
|
int i = 1;
|
|||
|
foreach (DataRow row in dt.Rows)
|
|||
|
{
|
|||
|
|
|||
|
recordSheet.GetRow(5 + i).Height = 29 * 20;
|
|||
|
recordSheet.GetRow(5 + i).CreateCell(0).SetCellValue(i + "");
|
|||
|
recordSheet.GetRow(5 + i).GetCell(0).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(5 + i).CreateCell(1).SetCellValue(row["UnitName"].ToString());
|
|||
|
recordSheet.GetRow(5 + i).GetCell(1).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(5 + i).CreateCell(3).SetCellValue(row["WorkAreaCode"].ToString());
|
|||
|
recordSheet.GetRow(5 + i).GetCell(3).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(5 + i).CreateCell(4).SetCellValue(row["WorkAreaName"].ToString());
|
|||
|
recordSheet.GetRow(5 + i).GetCell(4).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(5 + i).CreateCell(5).SetCellValue(row["curr_pass_film"].ToString());
|
|||
|
recordSheet.GetRow(5 + i).GetCell(5).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(5 + i).CreateCell(6).SetCellValue(row["curr_total_film"].ToString());
|
|||
|
recordSheet.GetRow(5 + i).GetCell(6).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
curr_pass_film += Funs.GetNewIntOrZero(row["curr_pass_film"].ToString());
|
|||
|
curr_total_film += Funs.GetNewIntOrZero(row["curr_total_film"].ToString());
|
|||
|
var celCellValue1 = recordSheet.GetRow(5 + i).CreateCell(7);
|
|||
|
celCellValue1.CellStyle = styleCenter;
|
|||
|
celCellValue1.SetCellValue((100.0 * int.Parse(row["curr_pass_film"].ToString()) / int.Parse(row["curr_total_film"].ToString())).ToString("0.00"));
|
|||
|
}
|
|||
|
catch (Exception e1)
|
|||
|
{ }
|
|||
|
|
|||
|
recordSheet.GetRow(5 + i).CreateCell(14).SetCellValue(row["pro_pass_film"].ToString());
|
|||
|
recordSheet.GetRow(5 + i).GetCell(14).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(5 + i).CreateCell(15).SetCellValue(row["pro_total_film"].ToString());
|
|||
|
recordSheet.GetRow(5 + i).GetCell(15).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
pro_pass_film += Funs.GetNewIntOrZero(row["pro_pass_film"].ToString());
|
|||
|
pro_total_film += Funs.GetNewIntOrZero(row["pro_total_film"].ToString());
|
|||
|
|
|||
|
var celCellValue2 = recordSheet.GetRow(5 + i).CreateCell(16);
|
|||
|
celCellValue2.CellStyle = styleCenter;
|
|||
|
celCellValue2.SetCellValue((100.0 * int.Parse(row["pro_pass_film"].ToString()) / int.Parse(row["pro_total_film"].ToString())).ToString("0.00"));
|
|||
|
}
|
|||
|
catch (Exception e2)
|
|||
|
{ }
|
|||
|
recordSheet.GetRow(5 + i).CreateCell(17).SetCellValue(row["pass_film"].ToString());
|
|||
|
recordSheet.GetRow(5 + i).GetCell(17).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(5 + i).CreateCell(18).SetCellValue(row["total_film"].ToString());
|
|||
|
recordSheet.GetRow(5 + i).GetCell(18).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
pass_film += Funs.GetNewIntOrZero(row["pass_film"].ToString());
|
|||
|
total_film += Funs.GetNewIntOrZero(row["total_film"].ToString());
|
|||
|
|
|||
|
var celCellValue3 = recordSheet.GetRow(5 + i).CreateCell(19);
|
|||
|
celCellValue3.CellStyle = styleCenter;
|
|||
|
celCellValue3.SetCellValue((100.0 * int.Parse(row["pass_film"].ToString()) / int.Parse(row["total_film"].ToString())).ToString("0.00"));
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e3)
|
|||
|
{ }
|
|||
|
recordSheet.GetRow(5 + i).CreateCell(20).SetCellValue(row["recurr_pass_film"].ToString());
|
|||
|
recordSheet.GetRow(5 + i).GetCell(20).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(5 + i).CreateCell(21).SetCellValue(row["recurr_total_film"].ToString());
|
|||
|
recordSheet.GetRow(5 + i).GetCell(21).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
recurr_pass_film += Funs.GetNewIntOrZero(row["recurr_pass_film"].ToString());
|
|||
|
recurr_total_film += Funs.GetNewIntOrZero(row["recurr_total_film"].ToString());
|
|||
|
var celCellValue4 = recordSheet.GetRow(5 + i).CreateCell(22);
|
|||
|
celCellValue4.CellStyle = styleCenter;
|
|||
|
celCellValue4.SetCellValue((100.0 * int.Parse(row["recurr_pass_film"].ToString()) / int.Parse(row["recurr_total_film"].ToString())).ToString("0.00"));
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e4)
|
|||
|
{ }
|
|||
|
recordSheet.GetRow(5 + i).CreateCell(23).SetCellValue(row["retotal_pass_film"].ToString());
|
|||
|
recordSheet.GetRow(5 + i).GetCell(23).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(5 + i).CreateCell(24).SetCellValue(row["retotal_total_film"].ToString());
|
|||
|
recordSheet.GetRow(5 + i).GetCell(24).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
retotal_pass_film += Funs.GetNewIntOrZero(row["retotal_pass_film"].ToString());
|
|||
|
retotal_total_film += Funs.GetNewIntOrZero(row["retotal_total_film"].ToString());
|
|||
|
var celCellValue5 = recordSheet.GetRow(5 + i).CreateCell(25);
|
|||
|
celCellValue5.CellStyle = styleCenter;
|
|||
|
celCellValue5.SetCellValue((100.0 * int.Parse(row["retotal_pass_film"].ToString()) / int.Parse(row["retotal_total_film"].ToString())).ToString("0.00"));
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e5)
|
|||
|
{ }
|
|||
|
|
|||
|
i++;
|
|||
|
}
|
|||
|
|
|||
|
if (dt.Rows.Count > 10)
|
|||
|
{
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).CreateCell(5).SetCellValue(curr_pass_film + "");
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).GetCell(5).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).CreateCell(6).SetCellValue(curr_total_film + "");
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).GetCell(6).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
if (curr_total_film > 0)
|
|||
|
{
|
|||
|
var celCellValue1 = recordSheet.GetRow(dt.Rows.Count + 6).CreateCell(7);
|
|||
|
celCellValue1.CellStyle = styleCenter;
|
|||
|
celCellValue1.SetCellValue((100.0 * curr_pass_film / curr_total_film).ToString("0.00"));
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e1)
|
|||
|
{ }
|
|||
|
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).CreateCell(14).SetCellValue(pro_pass_film + "");
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).GetCell(14).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).CreateCell(15).SetCellValue(pro_total_film + "");
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).GetCell(15).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
if (pro_total_film > 0)
|
|||
|
{
|
|||
|
var celCellValue2 = recordSheet.GetRow(dt.Rows.Count + 6).CreateCell(16);
|
|||
|
celCellValue2.CellStyle = styleCenter;
|
|||
|
celCellValue2.SetCellValue((100.0 * pro_pass_film / pro_total_film).ToString("0.00"));
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e2)
|
|||
|
{ }
|
|||
|
recordSheet.GetRow(dt.Rows.Count + 6).CreateCell(17).SetCellValue(pass_film + "");
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).GetCell(17).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).CreateCell(18).SetCellValue(total_film + "");
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).GetCell(18).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
if (total_film > 0)
|
|||
|
{
|
|||
|
var celCellValue3 = recordSheet.GetRow(dt.Rows.Count + 6).CreateCell(19);
|
|||
|
celCellValue3.CellStyle = styleCenter;
|
|||
|
celCellValue3.SetCellValue((100.0 * pass_film / total_film).ToString("0.00"));
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e3)
|
|||
|
{ }
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).CreateCell(20).SetCellValue(recurr_pass_film + "");
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).GetCell(20).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).CreateCell(21).SetCellValue(recurr_total_film + "");
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).GetCell(21).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
if (recurr_total_film > 0)
|
|||
|
{
|
|||
|
|
|||
|
var celCellValue4 = recordSheet.GetRow(dt.Rows.Count + 6).CreateCell(22);
|
|||
|
celCellValue4.CellStyle = styleCenter;
|
|||
|
celCellValue4.SetCellValue((100.0 * recurr_pass_film / recurr_total_film).ToString("0.00"));
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e4)
|
|||
|
{ }
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).CreateCell(23).SetCellValue(retotal_pass_film + "");
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).GetCell(23).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).CreateCell(24).SetCellValue(retotal_total_film + "");
|
|||
|
recordSheet.GetRow(dt.Rows.Count+6).GetCell(24).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
if (retotal_total_film > 0)
|
|||
|
{
|
|||
|
var celCellValue5 = recordSheet.GetRow(dt.Rows.Count + 6).CreateCell(25);
|
|||
|
celCellValue5.CellStyle = styleCenter;
|
|||
|
celCellValue5.SetCellValue((100.0 * retotal_pass_film / retotal_total_film).ToString("0.00"));
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e5)
|
|||
|
{ }
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
recordSheet.GetRow(16).CreateCell(5).SetCellValue(curr_pass_film+"");
|
|||
|
recordSheet.GetRow(16).GetCell(5).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(16).CreateCell(6).SetCellValue(curr_total_film+"");
|
|||
|
recordSheet.GetRow(16).GetCell(6).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
if (curr_total_film > 0)
|
|||
|
{
|
|||
|
var celCellValue1 = recordSheet.GetRow(16).CreateCell(7);
|
|||
|
celCellValue1.CellStyle = styleCenter;
|
|||
|
celCellValue1.SetCellValue((100.0 * curr_pass_film / curr_total_film).ToString("0.00"));
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e1)
|
|||
|
{ }
|
|||
|
|
|||
|
recordSheet.GetRow(16).CreateCell(14).SetCellValue(pro_pass_film+"");
|
|||
|
recordSheet.GetRow(16).GetCell(14).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(16).CreateCell(15).SetCellValue(pro_total_film+"");
|
|||
|
recordSheet.GetRow(16).GetCell(15).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
if (pro_total_film > 0)
|
|||
|
{
|
|||
|
var celCellValue2 = recordSheet.GetRow(16).CreateCell(16);
|
|||
|
celCellValue2.CellStyle = styleCenter;
|
|||
|
celCellValue2.SetCellValue((100.0 * pro_pass_film / pro_total_film).ToString("0.00"));
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e2)
|
|||
|
{ }
|
|||
|
recordSheet.GetRow(16).CreateCell(17).SetCellValue(pass_film+"");
|
|||
|
recordSheet.GetRow(16).GetCell(17).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(16).CreateCell(18).SetCellValue(total_film+"");
|
|||
|
recordSheet.GetRow(16).GetCell(18).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
if (total_film > 0)
|
|||
|
{
|
|||
|
var celCellValue3 = recordSheet.GetRow(16).CreateCell(19);
|
|||
|
celCellValue3.CellStyle = styleCenter;
|
|||
|
celCellValue3.SetCellValue((100.0 * pass_film / total_film).ToString("0.00"));
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e3)
|
|||
|
{ }
|
|||
|
recordSheet.GetRow(16).CreateCell(20).SetCellValue(recurr_pass_film+"");
|
|||
|
recordSheet.GetRow(16).GetCell(20).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(16).CreateCell(21).SetCellValue(recurr_total_film+"");
|
|||
|
recordSheet.GetRow(16).GetCell(21).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
if (recurr_total_film > 0)
|
|||
|
{
|
|||
|
var celCellValue4 = recordSheet.GetRow(16).CreateCell(22);
|
|||
|
celCellValue4.CellStyle = styleCenter;
|
|||
|
celCellValue4.SetCellValue((100.0 * recurr_pass_film / recurr_total_film).ToString("0.00"));
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e4)
|
|||
|
{ }
|
|||
|
recordSheet.GetRow(16).CreateCell(23).SetCellValue(retotal_pass_film+"");
|
|||
|
recordSheet.GetRow(16).GetCell(23).CellStyle = styleCenter;
|
|||
|
recordSheet.GetRow(16).CreateCell(24).SetCellValue(retotal_total_film+"");
|
|||
|
recordSheet.GetRow(16).GetCell(24).CellStyle = styleCenter;
|
|||
|
try
|
|||
|
{
|
|||
|
if (retotal_total_film > 0)
|
|||
|
{
|
|||
|
var celCellValue5 = recordSheet.GetRow(16).CreateCell(25);
|
|||
|
celCellValue5.CellStyle = styleCenter;
|
|||
|
celCellValue5.SetCellValue((100.0 * retotal_pass_film / retotal_total_film).ToString("0.00"));
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e5)
|
|||
|
{ }
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
using (FileStream filess = File.OpenWrite(ReportFileName))
|
|||
|
{
|
|||
|
hssfworkbook.Write(filess);
|
|||
|
}
|
|||
|
//PageContext.RegisterStartupScript(Window5.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.HJGL_JointInfoReportId, isoId, varValue, this.CurrUser.LoginProjectId)));
|
|||
|
|
|||
|
FileInfo filet = new FileInfo(ReportFileName);
|
|||
|
Response.Clear();
|
|||
|
Response.Charset = "GB2312";
|
|||
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|||
|
// 添加头信息,为"文件下载/另存为"对话框指定默认文件名
|
|||
|
Response.AddHeader("Content-Disposition", "attachment; filename=无损检测月报_" + Server.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx"));
|
|||
|
// 添加头信息,指定文件大小,让浏览器能够显示下载进度
|
|||
|
Response.AddHeader("Content-Length", filet.Length.ToString());
|
|||
|
// 指定返回的是一个不能被客户端读取的流,必须被下载
|
|||
|
Response.ContentType = "application/ms-excel";
|
|||
|
// 把文件流发送到客户端
|
|||
|
Response.WriteFile(filet.FullName);
|
|||
|
// 停止页面的执行
|
|||
|
Response.End();
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#region 查询
|
|||
|
/// <summary>
|
|||
|
/// 查询
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnSearch_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
string projectName = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId).ProjectName;
|
|||
|
if (!string.IsNullOrEmpty(this.txtStartDate.Text))
|
|||
|
{
|
|||
|
string staDate = this.txtStartDate.SelectedDate.Value.ToString("yyyy-MM-dd") + "至" + this.txtStartDate.SelectedDate.Value.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
|
|||
|
|
|||
|
SpRpNDTWeekReport t = new SpRpNDTWeekReport();
|
|||
|
this.NDTReportId = SQLHelper.GetNewID(typeof(Model.NDTReport));
|
|||
|
t.NDTReportId = this.NDTReportId;
|
|||
|
t.ProjectId = this.CurrUser.LoginProjectId;
|
|||
|
t.ProjectName = projectName;
|
|||
|
t.StaDate = staDate;
|
|||
|
|
|||
|
List<SpRpNDTWeekReport> list = new List<SpRpNDTWeekReport>();
|
|||
|
list.Add(t);
|
|||
|
Grid1.DataSource = list;
|
|||
|
Grid1.DataBind();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Alert.ShowInTop("日期不能为空!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 保存
|
|||
|
/// <summary>
|
|||
|
/// 保存
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnSave_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(this.txtStartDate.Text))
|
|||
|
{
|
|||
|
Model.NDTReport ndtReport = new Model.NDTReport();
|
|||
|
ndtReport.NDTReportId = this.NDTReportId;
|
|||
|
ndtReport.ProjectId = this.CurrUser.LoginProjectId;
|
|||
|
ndtReport.StartDate = this.txtStartDate.SelectedDate.Value;
|
|||
|
ndtReport.EndDate =this.txtStartDate.SelectedDate.Value.AddMonths(1).AddDays(-1);
|
|||
|
ndtReport.RType = "2";
|
|||
|
BLL.NDTReportService.AddNDTReort(ndtReport);
|
|||
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|||
|
BindGrid();
|
|||
|
this.txtStartDate.Text = string.Empty;
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Alert.ShowInTop("日期不能为空!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 右键删除
|
|||
|
/// <summary>
|
|||
|
/// 右键删除
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|||
|
{
|
|||
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|||
|
{
|
|||
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|||
|
var rep = BLL.NDTReportService.GetNDTReportById(rowID);
|
|||
|
if (rep != null)
|
|||
|
{
|
|||
|
BLL.NDTReportService.DeleteNDTReportById(rowID);
|
|||
|
}
|
|||
|
}
|
|||
|
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 日期选择事件
|
|||
|
/// <summary>
|
|||
|
/// 开始日期选择事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void txtStartDate_TextChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 结束日期选择事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void txtEndDate_TextChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|