2025-02-12 09:27:47 +08:00
using BLL ;
using Model ;
using NPOI.SS.Formula.Functions ;
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 ( 29 ) . 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,
curr_trust_point.curr_trust_count_total, curr.curr_pass_point,curr.curr_check_count_total curr_check_count_point, total_trust_point.trust_count_total,totalpoint.total_pass_point, totalpoint.total_check_count_point
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
, SUM(case when CHT_CheckResult='合格' then 1 else 0 end) AS curr_pass_point
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
left join
( SELECT WorkAreaId,IsoInfo.UnitId,COUNT(*) AS total_check_count_point
, SUM(case when CHT_CheckResult='合格' then 1 else 0 end) AS total_pass_point
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 totalpoint on unit.UnitId= totalpoint.UnitId and workArea.WorkAreaId=totalpoint.WorkAreaId
left join (
SELECT WorkAreaId,IsoInfo.UnitId,COUNT(*) AS curr_trust_count_total
FROM CH_Trust trust
LEFT JOIN CH_TrustItem trustitem ON trustitem .CH_TrustID = trust.CH_TrustID
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = trustitem.JOT_ID
LEFT JOIN PW_IsoInfo as IsoInfo ON IsoInfo.ISO_ID = JointInfo.ISO_ID
where JointInfo.ProjectId=@ProjectId and (trust.CH_TrustDate >= @date1 OR @date1 IS NULL) and(trust.CH_TrustDate <= @date2 OR @date2 IS NULL)
group by WorkAreaId,IsoInfo.UnitId)as curr_trust_point on unit.UnitId= curr_trust_point.UnitId and workArea.WorkAreaId=curr_trust_point.WorkAreaId
left join (
SELECT WorkAreaId,IsoInfo.UnitId,COUNT(*) AS trust_count_total
FROM CH_Trust trust
LEFT JOIN CH_TrustItem trustitem ON trustitem .CH_TrustID = trust.CH_TrustID
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = trustitem.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_trust_point on unit.UnitId= total_trust_point.UnitId and workArea.WorkAreaId=total_trust_point.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 curr_trust_count_total = 0 ;
int curr_check_count_point = 0 ;
int curr_pass_point = 0 ;
int trust_count_total = 0 ;
int total_pass_point = 0 ;
int total_check_count_point = 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_total_film" ] . ToString ( ) ) ;
recordSheet . GetRow ( 5 + i ) . GetCell ( 5 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 5 + i ) . CreateCell ( 6 ) . SetCellValue ( row [ "curr_pass_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" ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
recordSheet . GetRow ( 5 + i ) . CreateCell ( 14 ) . SetCellValue ( row [ "pro_total_film" ] . ToString ( ) ) ;
recordSheet . GetRow ( 5 + i ) . GetCell ( 14 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 5 + i ) . CreateCell ( 15 ) . SetCellValue ( row [ "pro_pass_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" ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
recordSheet . GetRow ( 5 + i ) . CreateCell ( 17 ) . SetCellValue ( row [ "total_film" ] . ToString ( ) ) ;
recordSheet . GetRow ( 5 + i ) . GetCell ( 17 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 5 + i ) . CreateCell ( 18 ) . SetCellValue ( row [ "pass_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" ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
recordSheet . GetRow ( 5 + i ) . CreateCell ( 20 ) . SetCellValue ( row [ "recurr_total_film" ] . ToString ( ) ) ;
recordSheet . GetRow ( 5 + i ) . GetCell ( 20 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 5 + i ) . CreateCell ( 21 ) . SetCellValue ( row [ "recurr_pass_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" ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
recordSheet . GetRow ( 5 + i ) . CreateCell ( 23 ) . SetCellValue ( row [ "retotal_total_film" ] . ToString ( ) ) ;
recordSheet . GetRow ( 5 + i ) . GetCell ( 23 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 5 + i ) . CreateCell ( 24 ) . SetCellValue ( row [ "retotal_pass_film" ] . ToString ( ) ) ;
recordSheet . GetRow ( 5 + i ) . GetCell ( 24 ) . CellStyle = styleCenter ;
try
{
retotal_pass_film + = Funs . GetNewIntOrZero ( row [ "retotal_total_film" ] . ToString ( ) ) ;
retotal_total_film + = Funs . GetNewIntOrZero ( row [ "retotal_pass_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" ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
recordSheet . GetRow ( 5 + i ) . CreateCell ( 26 ) . SetCellValue ( row [ "curr_trust_count_total" ] . ToString ( ) ) ;
recordSheet . GetRow ( 5 + i ) . GetCell ( 26 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 5 + i ) . CreateCell ( 27 ) . SetCellValue ( row [ "curr_check_count_point" ] . ToString ( ) ) ;
recordSheet . GetRow ( 5 + i ) . GetCell ( 27 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 5 + i ) . CreateCell ( 28 ) . SetCellValue ( row [ "curr_pass_point" ] . ToString ( ) ) ;
recordSheet . GetRow ( 5 + i ) . GetCell ( 28 ) . CellStyle = styleCenter ;
try
{
curr_trust_count_total + = Funs . GetNewIntOrZero ( row [ "curr_trust_count_total" ] . ToString ( ) ) ;
curr_check_count_point + = Funs . GetNewIntOrZero ( row [ "curr_check_count_point" ] . ToString ( ) ) ;
curr_pass_point + = Funs . GetNewIntOrZero ( row [ "curr_pass_point" ] . ToString ( ) ) ;
var celCellValue5 = recordSheet . GetRow ( 5 + i ) . CreateCell ( 29 ) ;
celCellValue5 . CellStyle = styleCenter ;
celCellValue5 . SetCellValue ( ( 100.0 * int . Parse ( row [ "curr_pass_point" ] . ToString ( ) ) / int . Parse ( row [ "curr_check_count_point" ] . ToString ( ) ) ) . ToString ( "0.00" ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
recordSheet . GetRow ( 5 + i ) . CreateCell ( 30 ) . SetCellValue ( row [ "trust_count_total" ] . ToString ( ) ) ;
recordSheet . GetRow ( 5 + i ) . GetCell ( 30 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 5 + i ) . CreateCell ( 31 ) . SetCellValue ( row [ "total_check_count_point" ] . ToString ( ) ) ;
recordSheet . GetRow ( 5 + i ) . GetCell ( 31 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 5 + i ) . CreateCell ( 32 ) . SetCellValue ( row [ "total_pass_point" ] . ToString ( ) ) ;
recordSheet . GetRow ( 5 + i ) . GetCell ( 32 ) . CellStyle = styleCenter ;
try
{
trust_count_total + = Funs . GetNewIntOrZero ( row [ "trust_count_total" ] . ToString ( ) ) ;
total_pass_point + = Funs . GetNewIntOrZero ( row [ "total_pass_point" ] . ToString ( ) ) ;
total_check_count_point + = Funs . GetNewIntOrZero ( row [ "total_check_count_point" ] . ToString ( ) ) ;
var celCellValue5 = recordSheet . GetRow ( 5 + i ) . CreateCell ( 33 ) ;
celCellValue5 . CellStyle = styleCenter ;
celCellValue5 . SetCellValue ( ( 100.0 * int . Parse ( row [ "total_pass_point" ] . ToString ( ) ) / int . Parse ( row [ "total_check_count_point" ] . ToString ( ) ) ) . ToString ( "0.00" ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
i + + ;
}
if ( dt . Rows . Count > 10 )
{
recordSheet . GetRow ( dt . Rows . Count + 6 ) . CreateCell ( 6 ) . SetCellValue ( curr_pass_film + "" ) ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . GetCell ( 6 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . CreateCell ( 5 ) . SetCellValue ( curr_total_film + "" ) ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . GetCell ( 5 ) . 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" ) ) ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
recordSheet . GetRow ( dt . Rows . Count + 6 ) . CreateCell ( 15 ) . SetCellValue ( pro_pass_film + "" ) ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . GetCell ( 15 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . CreateCell ( 14 ) . SetCellValue ( pro_total_film + "" ) ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . GetCell ( 14 ) . 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" ) ) ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
recordSheet . GetRow ( dt . Rows . Count + 6 ) . CreateCell ( 17 ) . SetCellValue ( total_film + "" ) ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . GetCell ( 17 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . CreateCell ( 18 ) . SetCellValue ( pass_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" ) ) ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
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" ) ) ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
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" ) ) ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
recordSheet . GetRow ( dt . Rows . Count + 6 ) . CreateCell ( 26 ) . SetCellValue ( curr_trust_count_total + "" ) ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . GetCell ( 26 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . CreateCell ( 27 ) . SetCellValue ( curr_check_count_point + "" ) ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . GetCell ( 27 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . CreateCell ( 28 ) . SetCellValue ( curr_pass_point + "" ) ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . GetCell ( 28 ) . CellStyle = styleCenter ;
try
{
if ( curr_check_count_point > 0 )
{
var celCellValue5 = recordSheet . GetRow ( dt . Rows . Count + 6 ) . CreateCell ( 29 ) ;
celCellValue5 . CellStyle = styleCenter ;
celCellValue5 . SetCellValue ( ( 100.0 * curr_pass_point / curr_check_count_point ) . ToString ( "0.00" ) ) ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
recordSheet . GetRow ( dt . Rows . Count + 6 ) . CreateCell ( 30 ) . SetCellValue ( trust_count_total + "" ) ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . GetCell ( 30 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . CreateCell ( 31 ) . SetCellValue ( total_check_count_point + "" ) ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . GetCell ( 31 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . CreateCell ( 32 ) . SetCellValue ( total_pass_point + "" ) ;
recordSheet . GetRow ( dt . Rows . Count + 6 ) . GetCell ( 32 ) . CellStyle = styleCenter ;
try
{
if ( total_check_count_point > 0 )
{
var celCellValue5 = recordSheet . GetRow ( dt . Rows . Count + 6 ) . CreateCell ( 33 ) ;
celCellValue5 . CellStyle = styleCenter ;
celCellValue5 . SetCellValue ( ( 100.0 * total_pass_point / total_check_count_point ) . ToString ( "0.00" ) ) ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
}
else
{
recordSheet . GetRow ( 16 ) . CreateCell ( 6 ) . SetCellValue ( curr_pass_film + "" ) ;
recordSheet . GetRow ( 16 ) . GetCell ( 6 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 16 ) . CreateCell ( 5 ) . SetCellValue ( curr_total_film + "" ) ;
recordSheet . GetRow ( 16 ) . GetCell ( 5 ) . 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" ) ) ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
recordSheet . GetRow ( 16 ) . CreateCell ( 15 ) . SetCellValue ( pro_pass_film + "" ) ;
recordSheet . GetRow ( 16 ) . GetCell ( 15 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 16 ) . CreateCell ( 14 ) . SetCellValue ( pro_total_film + "" ) ;
recordSheet . GetRow ( 16 ) . GetCell ( 14 ) . 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" ) ) ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
recordSheet . GetRow ( 16 ) . CreateCell ( 17 ) . SetCellValue ( total_film + "" ) ;
recordSheet . GetRow ( 16 ) . GetCell ( 17 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 16 ) . CreateCell ( 18 ) . SetCellValue ( pass_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" ) ) ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
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" ) ) ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
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" ) ) ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
recordSheet . GetRow ( 16 ) . CreateCell ( 26 ) . SetCellValue ( curr_trust_count_total + "" ) ;
recordSheet . GetRow ( 16 ) . GetCell ( 26 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 16 ) . CreateCell ( 27 ) . SetCellValue ( curr_check_count_point + "" ) ;
recordSheet . GetRow ( 16 ) . GetCell ( 27 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 16 ) . CreateCell ( 28 ) . SetCellValue ( curr_pass_point + "" ) ;
recordSheet . GetRow ( 16 ) . GetCell ( 28 ) . CellStyle = styleCenter ;
try
{
if ( curr_check_count_point > 0 )
{
var celCellValue5 = recordSheet . GetRow ( 16 ) . CreateCell ( 29 ) ;
celCellValue5 . CellStyle = styleCenter ;
celCellValue5 . SetCellValue ( ( 100.0 * curr_pass_point / curr_check_count_point ) . ToString ( "0.00" ) ) ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
recordSheet . GetRow ( 16 ) . CreateCell ( 30 ) . SetCellValue ( trust_count_total + "" ) ;
recordSheet . GetRow ( 16 ) . GetCell ( 30 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 16 ) . CreateCell ( 31 ) . SetCellValue ( total_check_count_point + "" ) ;
recordSheet . GetRow ( 16 ) . GetCell ( 31 ) . CellStyle = styleCenter ;
recordSheet . GetRow ( 16 ) . CreateCell ( 32 ) . SetCellValue ( total_pass_point + "" ) ;
recordSheet . GetRow ( 16 ) . GetCell ( 32 ) . CellStyle = styleCenter ;
try
{
if ( total_check_count_point > 0 )
{
var celCellValue5 = recordSheet . GetRow ( 16 ) . CreateCell ( 33 ) ;
celCellValue5 . CellStyle = styleCenter ;
celCellValue5 . SetCellValue ( ( 100.0 * total_pass_point / total_check_count_point ) . ToString ( "0.00" ) ) ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception )
2025-02-12 09:27:47 +08:00
{ }
}
}
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 . IsNullOrEmpty ( this . txtEndDate . Text ) )
{
string staDate = this . txtStartDate . SelectedDate . Value . ToString ( "yyyy-MM-dd" ) + "至" + this . txtEndDate . SelectedDate . Value . 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
}
}