2024-05-08 10:17:02 +08:00
using BLL ;
using NPOI.SS.UserModel ;
2024-09-25 15:18:42 +08:00
using NPOI.XSSF.UserModel ;
2024-05-08 10:17:02 +08:00
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Data.SqlClient ;
using System.IO ;
using System.Linq ;
namespace FineUIPro.Web.SES
{
public partial class CQualityPunish : PageBase
{
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
GetButtonPower ( ) ; //权限设置
btnNew . OnClientClick = Window1 . GetShowReference ( "CQualityPunishEdit.aspx" ) + "return false;" ;
btnDelete . OnClientClick = Grid1 . GetNoSelectionAlertReference ( "Please select at least one item!" ) ;
btnDelete . ConfirmText = String . Format ( "Are you sure you want to delete the selected <b><script>{0}</script></b> rows?" , Grid1 . GetSelectedCountReference ( ) ) ;
var pun = from x in Funs . DB . View_EMC_Punishment
where x . Flag = = "2" & & x . Contract_AdminId ! = null
orderby x . Contract_Admin
select new { x . Contract_AdminId , x . Contract_Admin } ;
drpContractAdmin . DataValueField = "Contract_AdminId" ;
drpContractAdmin . DataTextField = "Contract_Admin" ;
drpContractAdmin . DataSource = pun . Distinct ( ) ;
drpContractAdmin . DataBind ( ) ;
Funs . FineUIPleaseSelect ( drpContractAdmin ) ;
ddlPageSize . SelectedValue = Grid1 . PageSize . ToString ( ) ;
// 绑定表格
BindGrid ( ) ;
}
}
private void BindGrid ( )
{
2024-09-18 10:36:26 +08:00
string strSql = @"SELECT * FROM dbo.View_EMC_Que_Punishment WHERE Flag='2' " ;
2024-05-08 10:17:02 +08:00
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
if ( ! string . IsNullOrEmpty ( this . txtFO_NO . Text . Trim ( ) ) )
{
strSql + = " AND FO_NO LIKE @FO_NO" ;
listStr . Add ( new SqlParameter ( "@FO_NO" , "%" + this . txtFO_NO . Text . Trim ( ) + "%" ) ) ;
}
2024-09-18 10:36:26 +08:00
if ( drpContractAdmin . SelectedValue ! = Const . _Null & & drpContractAdmin . SelectedValue ! = null )
2024-05-08 10:17:02 +08:00
{
strSql + = " AND Contract_AdminId = @Contract_AdminId" ;
listStr . Add ( new SqlParameter ( "@Contract_AdminId" , drpContractAdmin . SelectedValue ) ) ;
}
if ( ! string . IsNullOrEmpty ( txtPunishDate . Text ) )
{
DateTime startDate = Convert . ToDateTime ( txtPunishDate . Text + "-01" ) ;
DateTime endDate = startDate . AddMonths ( 1 ) ;
strSql + = " AND PunishDate >= @StartDate" ;
listStr . Add ( new SqlParameter ( "@StartDate" , startDate ) ) ;
strSql + = " AND PunishDate < @EndDate" ;
listStr . Add ( new SqlParameter ( "@EndDate" , endDate ) ) ;
}
SqlParameter [ ] parameter = listStr . ToArray ( ) ;
DataTable tb = SQLHelper . GetDataTableRunText ( strSql , parameter ) ;
Grid1 . RecordCount = tb . Rows . Count ;
var table = this . GetPagedDataTable ( Grid1 , tb ) ;
Grid1 . DataSource = table ;
Grid1 . DataBind ( ) ;
2024-09-18 10:36:26 +08:00
for ( int i = 0 ; i < Grid1 . Rows . Count ; i + + )
{
System . Web . UI . WebControls . LinkButton lbtnUrl = ( ( System . Web . UI . WebControls . LinkButton ) ( Grid1 . Rows [ i ] . FindControl ( "lbtnUrl" ) ) ) ;
string url = lbtnUrl . CommandArgument . ToString ( ) ;
if ( ! string . IsNullOrEmpty ( url ) )
{
url = url . Replace ( '\\' , '/' ) ;
lbtnUrl . Text = BLL . UploadAttachmentService . ShowAttachment ( "../" , url ) ;
}
}
2024-05-08 10:17:02 +08:00
}
#region 编 辑
/// <summary>
/// 编辑
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnEdit_Click ( object sender , EventArgs e )
{
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInParent ( "Please select at least one record!" ) ;
return ;
}
2024-09-18 10:36:26 +08:00
string rowID = Grid1 . SelectedRowID ;
var pun = BLL . PunishmentService . GetPunishmentById ( rowID ) ;
if ( pun ! = null )
{
if ( pun . IsAudit = = true )
{
if ( CurrUser . UserId = = pun . AuditMan )
{
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "CQualityPunishEdit.aspx?punishmentId={0}" , rowID , "编辑 - " ) ) ) ;
}
else
{
ShowNotify ( "已批准!只有批准人有修改权限!" , MessageBoxIcon . Warning ) ;
}
}
else
{
if ( pun . IsFrame = = true )
{
var datas = BLL . SESRelatedDataService . GetSESRelatedDataByFoNo ( pun . FO_NO ) ;
if ( CurrUser . UserId = = datas . Main_Coordinator | | CurrUser . UserId = = pun . Violation_Inspector | | CurrUser . UserId = = Const . GlyId )
{
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "CQualityPunishEdit.aspx?punishmentId={0}" , rowID , "编辑 - " ) ) ) ;
}
else
{
ShowNotify ( "只有主协调员,发起人(违章检查人)有修改权限!" , MessageBoxIcon . Warning ) ;
}
}
else
{
if ( CurrUser . UserId = = pun . Requisitioner | | CurrUser . UserId = = pun . Violation_Inspector | | CurrUser . UserId = = Const . GlyId )
{
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "CQualityPunishEdit.aspx?punishmentId={0}" , rowID , "编辑 - " ) ) ) ;
}
else
{
ShowNotify ( "只有合同请购人,发起人(违章检查人)有修改权限!" , MessageBoxIcon . Warning ) ;
}
}
}
}
}
protected void btnAudit_Click ( object sender , EventArgs e )
{
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInParent ( "Please select at least one record!" ) ;
return ;
}
string rowID = Grid1 . SelectedRowID ;
var pun = BLL . PunishmentService . GetPunishmentById ( rowID ) ;
string auditMan = string . Empty ;
if ( pun ! = null )
{
if ( pun . IsFrame = = true )
{
var fc = BLL . SESRelatedDataService . GetSESRelatedDataByFoNo ( pun . FO_NO ) ;
string curUser = this . CurrUser . UserId ; // 当前用户
string violationInspector = pun . Violation_Inspector ; // 发起人
string leader = string . Empty ; // 主协调员部门领导
string mainCoordinator = fc . Main_Coordinator ;
var userInfo = BLL . Sys_UserService . GetUsersByUserId ( fc . Main_Coordinator ) ;
if ( userInfo ! = null )
{
var dep = BLL . DepartService . GetDepartById ( userInfo . DepartId ) ;
if ( dep ! = null )
{
leader = dep . DepartLeader ;
}
}
// 当前用户不是主调协员
if ( curUser ! = mainCoordinator )
{
// 当前用户是主调协员部门领导 不发邮件
if ( curUser = = leader )
{
auditMan = leader ;
}
else if ( curUser = = Const . GlyId )
{
auditMan = Const . GlyId ;
}
else
{
ShowNotify ( "您没有审核权限,请与管理员联系!" , MessageBoxIcon . Warning ) ;
return ;
}
}
else // 当前用户是主调协员
{
auditMan = mainCoordinator ;
// 发邮件给主调协员部门领导
}
}
// 非框架合同
else
{
string curUser = this . CurrUser . UserId ; // 当前用户
string violationInspector = pun . Violation_Inspector ; // 发起人
string leader = string . Empty ; // 请购人部门领导
string requisitioner = pun . Requisitioner ; // 请购人
var userInfo = BLL . Sys_UserService . GetUsersByUserId ( pun . Requisitioner ) ;
if ( userInfo ! = null )
{
var dep = BLL . DepartService . GetDepartById ( userInfo . DepartId ) ;
if ( dep ! = null )
{
leader = dep . DepartLeader ;
}
}
// 当前用户不是请购人
if ( curUser ! = requisitioner )
{
// 当前用户是请购人部门领导 不发邮件
if ( curUser = = leader )
{
auditMan = leader ;
}
else if ( curUser = = Const . GlyId )
{
auditMan = Const . GlyId ;
}
else
{
ShowNotify ( "您没有审核权限,请与管理员联系!" , MessageBoxIcon . Warning ) ;
return ;
}
}
else // 当前用户是请购人
{
auditMan = requisitioner ;
// 发邮件给请购人部门领导
}
}
if ( auditMan ! = string . Empty )
{
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "CQualityPunishEdit.aspx?punishmentId={0}&auditMan={1}&audit=audit" , rowID , auditMan , "编辑 - " ) ) ) ;
}
else
{
ShowNotify ( "您没有审核权限,请与管理员联系!" , MessageBoxIcon . Warning ) ;
}
}
2024-05-08 10:17:02 +08:00
}
/// <summary>
/// 右键编辑事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click ( object sender , EventArgs e )
{
btnEdit_Click ( null , null ) ;
}
/// <summary>
/// Grid行双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick ( object sender , GridRowClickEventArgs e )
{
btnEdit_Click ( null , null ) ;
}
#endregion
#region 删 除 数 据
/// <summary>
/// 批量删除数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDelete_Click ( object sender , EventArgs e )
{
this . DeleteData ( ) ;
}
/// <summary>
/// 右键删除事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click ( object sender , EventArgs e )
{
this . DeleteData ( ) ;
}
/// <summary>
/// 删除方法
/// </summary>
private void DeleteData ( )
{
2024-09-18 10:36:26 +08:00
if ( ! string . IsNullOrEmpty ( Grid1 . SelectedRowID ) )
2024-05-08 10:17:02 +08:00
{
2024-09-18 10:36:26 +08:00
string rowID = Grid1 . SelectedRowID ;
var pun = BLL . PunishmentService . GetPunishmentById ( rowID ) ;
if ( pun ! = null )
2024-05-08 10:17:02 +08:00
{
2024-09-18 10:36:26 +08:00
if ( pun . IsFrame = = true )
2024-05-08 10:17:02 +08:00
{
2024-09-18 10:36:26 +08:00
var datas = BLL . SESRelatedDataService . GetSESRelatedDataByFoNo ( pun . FO_NO ) ;
if ( pun . IsAudit = = true ) // 审核后只有批准人可删除
2024-05-08 10:17:02 +08:00
{
2024-09-18 10:36:26 +08:00
if ( CurrUser . UserId = = pun . AuditMan )
{
if ( judgementDelete ( rowID , false ) )
{
BLL . PunishmentService . DeletePunishmentById ( rowID ) ;
}
}
else
{
ShowNotify ( "已批准!只有批准人有删除权限!" , MessageBoxIcon . Warning ) ;
return ;
}
2024-05-08 10:17:02 +08:00
}
2024-09-18 10:36:26 +08:00
else
{
if ( CurrUser . UserId = = datas . Main_Coordinator | | CurrUser . UserId = = pun . Violation_Inspector | | CurrUser . UserId = = Const . GlyId )
{
if ( judgementDelete ( rowID , false ) )
{
BLL . PunishmentService . DeletePunishmentById ( rowID ) ;
}
}
else
{
ShowNotify ( "只有主协调员,发起人(违章检查人)有删除权限!" , MessageBoxIcon . Warning ) ;
return ;
}
}
}
else
{
if ( pun . IsAudit = = true )
{
if ( CurrUser . UserId = = pun . AuditMan )
{
if ( judgementDelete ( rowID , false ) )
{
BLL . PunishmentService . DeletePunishmentById ( rowID ) ;
}
}
else
{
ShowNotify ( "已批准!只有批准人有删除权限!" , MessageBoxIcon . Warning ) ;
return ;
}
}
else
{
if ( CurrUser . UserId = = pun . Requisitioner | | CurrUser . UserId = = pun . Violation_Inspector | | CurrUser . UserId = = Const . GlyId )
{
if ( judgementDelete ( rowID , false ) )
{
BLL . PunishmentService . DeletePunishmentById ( rowID ) ;
}
}
else
{
ShowNotify ( "只有合同请购人,发起人(违章检查人)有删除权限!" , MessageBoxIcon . Warning ) ;
return ;
}
}
2024-05-08 10:17:02 +08:00
}
}
2024-09-18 10:36:26 +08:00
2024-05-08 10:17:02 +08:00
BindGrid ( ) ;
BLL . Sys_LogService . AddLog ( this . CurrUser . UserId , "Delete Contractor Safety Punishment" ) ;
ShowNotify ( "Deleted successfully!" ) ;
}
}
#endregion
#region 查 询
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSearch_Click ( object sender , EventArgs e )
{
BindGrid ( ) ;
}
#endregion
#region 查 看
protected void btnMenuView_Click ( object sender , EventArgs e )
{
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInParent ( "Please select at least one record!" ) ;
return ;
}
string Id = Grid1 . SelectedRowID ;
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "CQualityPunishEdit.aspx?punishmentId={0}&view=1" , Id , "查看 - " ) ) ) ;
}
#endregion
#region 判 断 是 否 可 删 除
/// <summary>
/// 判断是否可以删除
/// </summary>
/// <returns></returns>
private bool judgementDelete ( string id , bool isShow )
{
string content = string . Empty ;
2024-09-18 10:36:26 +08:00
2024-05-08 10:17:02 +08:00
if ( string . IsNullOrEmpty ( content ) )
{
return true ;
}
else
{
if ( isShow )
{
Alert . ShowInTop ( content ) ;
}
return false ;
}
}
#endregion
#region 关 闭 弹 出 窗 口
/// <summary>
/// 关闭窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close ( object sender , EventArgs e )
{
BindGrid ( ) ;
drpContractAdmin . Items . Clear ( ) ;
var pun = from x in Funs . DB . View_EMC_Punishment
where x . Flag = = "2" & & x . Contract_AdminId ! = null
orderby x . Contract_Admin
select new { x . Contract_AdminId , x . Contract_Admin } ;
drpContractAdmin . DataValueField = "Contract_AdminId" ;
drpContractAdmin . DataTextField = "Contract_Admin" ;
drpContractAdmin . DataSource = pun . Distinct ( ) ;
drpContractAdmin . DataBind ( ) ;
Funs . FineUIPleaseSelect ( drpContractAdmin ) ;
}
#endregion
#region 分 页 、 排 序
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange ( object sender , GridPageEventArgs e )
{
Grid1 . PageIndex = e . NewPageIndex ;
BindGrid ( ) ;
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged ( object sender , EventArgs e )
{
Grid1 . PageSize = Convert . ToInt32 ( ddlPageSize . SelectedValue ) ;
BindGrid ( ) ;
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort ( object sender , FineUIPro . GridSortEventArgs e )
{
Grid1 . SortDirection = e . SortDirection ;
Grid1 . SortField = e . SortField ;
BindGrid ( ) ;
}
#endregion
#region 导 出
/// <summary>
/// 导出按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnExport_Click ( object sender , EventArgs e )
{
string rootPath = Server . MapPath ( "~/" ) + Const . ExcelUrl ;
//模板文件
string TempletFileName = rootPath + "Punishment.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 ) ;
#region FC_List
XSSFSheet reportModel = ( XSSFSheet ) hssfworkbook . GetSheet ( "Sheet1" ) ;
IDataFormat dataformat = hssfworkbook . CreateDataFormat ( ) ;
ICellStyle styleQfw = hssfworkbook . CreateCellStyle ( ) ;
styleQfw . DataFormat = dataformat . GetFormat ( "#,##0.00" ) ;
ICellStyle styleDate = hssfworkbook . CreateCellStyle ( ) ;
styleDate . DataFormat = dataformat . GetFormat ( "yyyy/m/d" ) ;
ICellStyle styleTime = hssfworkbook . CreateCellStyle ( ) ;
styleTime . DataFormat = dataformat . GetFormat ( "yyyy/m/d HH:mm:ss" ) ;
XSSFFont cs_content_Font = ( XSSFFont ) hssfworkbook . CreateFont ( ) ; //创建字体
cs_content_Font . FontName = "等线" ; //字体
cs_content_Font . FontHeightInPoints = 10 ; //字体大小
Grid1 . PageSize = 1000000 ;
BindGrid ( ) ;
if ( Grid1 . Rows . Count ( ) > 0 )
{
for ( int i = 1 ; i < = Grid1 . Rows . Count ( ) ; i + + )
{
if ( reportModel . GetRow ( i ) = = null ) reportModel . CreateRow ( i ) ;
#region 列 赋 值
//Date
if ( reportModel . GetRow ( i ) . GetCell ( 0 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 0 ) ;
if ( Grid1 . Rows [ i - 1 ] . Values [ 1 ] ! = null & & Grid1 . Rows [ i - 1 ] . Values [ 1 ] . ToString ( ) ! = "" )
{
DateTime date = Convert . ToDateTime ( Grid1 . Rows [ i - 1 ] . Values [ 1 ] ) ;
reportModel . GetRow ( i ) . GetCell ( 0 ) . SetCellValue ( date . ToString ( "yyyy/MM/dd" ) ) ;
// reportModel.GetRow(i).GetCell(0).CellStyle.SetFont(cs_content_Font);//将字体绑定到样式
}
//Time
if ( reportModel . GetRow ( i ) . GetCell ( 1 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 1 ) ;
reportModel . GetRow ( i ) . GetCell ( 1 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 2 ] . ToString ( ) ) ;
// Contract No.
if ( reportModel . GetRow ( i ) . GetCell ( 2 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 2 ) ;
reportModel . GetRow ( i ) . GetCell ( 2 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 3 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
//是否框架合格
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 3 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 3 ) ;
2024-09-25 15:18:42 +08:00
reportModel . GetRow ( i ) . GetCell ( 3 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 4 ] . ToString ( ) = = "True" ? "是" : "否" ) ;
// Discipline
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 4 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 4 ) ;
reportModel . GetRow ( i ) . GetCell ( 4 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 5 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
// Contractor
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 5 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 5 ) ;
reportModel . GetRow ( i ) . GetCell ( 5 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 6 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
// Location
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 6 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 6 ) ;
reportModel . GetRow ( i ) . GetCell ( 6 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 7 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
//Violation Person
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 7 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 7 ) ;
reportModel . GetRow ( i ) . GetCell ( 7 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 8 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
// Violation Description
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 8 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 8 ) ;
reportModel . GetRow ( i ) . GetCell ( 8 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 9 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
//Violation Clause
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 9 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 9 ) ;
reportModel . GetRow ( i ) . GetCell ( 9 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 10 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
// Company(RMB)
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 10 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 10 ) ;
reportModel . GetRow ( i ) . GetCell ( 10 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 11 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
// Individual(RMB)
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 11 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 11 ) ;
reportModel . GetRow ( i ) . GetCell ( 11 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 12 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
// Backcharge(RMB)
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 12 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 12 ) ;
reportModel . GetRow ( i ) . GetCell ( 12 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 13 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
// Violation Degree
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 13 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 13 ) ;
reportModel . GetRow ( i ) . GetCell ( 13 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 14 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
// Contract Admin
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 14 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 14 ) ;
reportModel . GetRow ( i ) . GetCell ( 14 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 15 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
// Main Coordinator
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 15 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 15 ) ;
reportModel . GetRow ( i ) . GetCell ( 15 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 16 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
// M.C.Dept
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 16 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 16 ) ;
reportModel . GetRow ( i ) . GetCell ( 16 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 17 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
// User Representative
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 17 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 17 ) ;
reportModel . GetRow ( i ) . GetCell ( 17 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 18 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
// BYC RU
2024-05-08 10:17:02 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 18 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 18 ) ;
reportModel . GetRow ( i ) . GetCell ( 18 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 19 ] . ToString ( ) ) ;
2024-09-25 15:18:42 +08:00
// Violation Inspector
if ( reportModel . GetRow ( i ) . GetCell ( 19 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 19 ) ;
reportModel . GetRow ( i ) . GetCell ( 19 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 20 ] . ToString ( ) ) ;
// Inspection Department
if ( reportModel . GetRow ( i ) . GetCell ( 20 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 20 ) ;
reportModel . GetRow ( i ) . GetCell ( 20 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 21 ] . ToString ( ) ) ;
//Requistioner
if ( reportModel . GetRow ( i ) . GetCell ( 21 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 21 ) ;
reportModel . GetRow ( i ) . GetCell ( 21 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 22 ] . ToString ( ) ) ;
// Backcharge SES No.
if ( reportModel . GetRow ( i ) . GetCell ( 22 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 22 ) ;
reportModel . GetRow ( i ) . GetCell ( 22 ) . SetCellValue ( Grid1 . Rows [ i - 1 ] . Values [ 23 ] . ToString ( ) ) ;
2024-05-08 10:17:02 +08:00
// Backcharge Completion Date
2024-09-25 15:18:42 +08:00
if ( reportModel . GetRow ( i ) . GetCell ( 23 ) = = null ) reportModel . GetRow ( i ) . CreateCell ( 23 ) ;
if ( Grid1 . Rows [ i - 1 ] . Values [ 24 ] ! = null & & Grid1 . Rows [ i - 1 ] . Values [ 24 ] . ToString ( ) ! = "" )
2024-05-08 10:17:02 +08:00
{
2024-09-25 15:18:42 +08:00
DateTime date = Convert . ToDateTime ( Grid1 . Rows [ i - 1 ] . Values [ 24 ] ) ;
reportModel . GetRow ( i ) . GetCell ( 23 ) . SetCellValue ( date . ToString ( "yyyy/MM/dd" ) ) ;
// reportModel.GetRow(i).GetCell(0).CellStyle.SetFont(cs_content_Font);//将字体绑定到样式
2024-05-08 10:17:02 +08:00
}
#endregion
}
}
#endregion
reportModel . ForceFormulaRecalculation = true ;
using ( FileStream filess = File . OpenWrite ( ReportFileName ) )
{
hssfworkbook . Write ( filess ) ;
}
FileInfo filet = new FileInfo ( ReportFileName ) ;
Response . Clear ( ) ;
Response . Charset = "GB2312" ;
Response . ContentEncoding = System . Text . Encoding . UTF8 ;
// 添加头信息,为"文件下载/另存为"对话框指定默认文件名
Response . AddHeader ( "Content-Disposition" , "attachment; filename=CQuality_Punishment_" + 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 ( ) ;
}
#endregion
#region 权 限 设 置
/// <summary>
/// 菜单按钮权限
/// </summary>
private void GetButtonPower ( )
{
var buttonList = BLL . CommonService . GetAllButtonList ( this . CurrUser . UserId , BLL . Const . CQualityPunishMenuId ) ;
if ( buttonList . Count ( ) > 0 )
{
if ( buttonList . Contains ( BLL . Const . BtnAdd ) )
{
this . btnNew . Hidden = false ;
}
if ( buttonList . Contains ( BLL . Const . BtnModify ) )
{
this . btnEdit . Hidden = false ;
this . btnMenuEdit . Hidden = false ;
}
if ( buttonList . Contains ( BLL . Const . BtnDelete ) )
{
this . btnDelete . Hidden = false ;
this . btnMenuDelete . Hidden = false ;
}
if ( buttonList . Contains ( BLL . Const . BtnOut ) )
{
this . btnExport . Hidden = false ;
}
if ( buttonList . Contains ( BLL . Const . BtnSave ) )
{
this . Grid1 . EnableRowDoubleClickEvent = true ;
}
else
{
this . Grid1 . EnableRowDoubleClickEvent = false ;
}
}
}
#endregion
}
}