2025-02-19 15:58:42 +08:00
using BLL ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Data.SqlClient ;
using System.Text ;
using AspNet = System . Web . UI . WebControls ;
namespace FineUIPro.Web.HSSE.Check
{
public partial class IncentiveNoticeStatistics : PageBase
{
#region 定 义 项
/// <summary>
/// 主键
/// </summary>
public string ProjectId
{
get
{
return ( string ) ViewState [ "ProjectId" ] ;
}
set
{
ViewState [ "ProjectId" ] = value ;
}
}
#endregion
2025-05-08 14:26:36 +08:00
#region 单 位 主 键
public string UnitId
{
get
{
return ( string ) ViewState [ "UnitId" ] ;
}
set
{
ViewState [ "UnitId" ] = value ;
}
}
#endregion
2025-02-19 15:58:42 +08:00
#region 加 载
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
Funs . DropDownPageSize ( this . ddlPageSize ) ;
this . ProjectId = this . CurrUser . LoginProjectId ;
if ( ! string . IsNullOrEmpty ( Request . Params [ "projectId" ] ) & & Request . Params [ "projectId" ] ! = this . CurrUser . LoginProjectId )
{
this . ProjectId = Request . Params [ "projectId" ] ;
}
2025-05-08 14:26:36 +08:00
this . ucTree . UnitId = this . CurrUser . UnitId ;
this . ucTree . ProjectId = this . ProjectId ;
if ( ! string . IsNullOrEmpty ( this . CurrUser . LoginProjectId ) )
{
this . panelLeftRegion . Hidden = true ;
// this.Grid1.Columns[0].Hidden = true;
}
2025-02-19 15:58:42 +08:00
if ( this . CurrUser ! = null & & this . CurrUser . PageSize . HasValue )
{
Grid1 . PageSize = this . CurrUser . PageSize . Value ;
}
this . ddlPageSize . SelectedValue = Grid1 . PageSize . ToString ( ) ;
// 绑定表格
this . BindGrid ( ) ;
}
}
2025-05-08 14:26:36 +08:00
protected void changeTree ( object sender , EventArgs e )
{
this . ProjectId = this . ucTree . ProjectId ;
//新增UnitId
//this.UnitId = this.ucTree.UnitId;
////判断 当有projectId的时候单位id为空
//if (!string.IsNullOrEmpty(this.ProjectId))
//{
// this.UnitId = "";
//}
this . BindGrid ( ) ;
}
2025-02-19 15:58:42 +08:00
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid ( )
{
2025-05-08 14:26:36 +08:00
if ( ! string . IsNullOrEmpty ( this . ProjectId ) )
{
string strSql = @"SELECT IncentiveNotice.ProjectId,IncentiveNotice.UnitId,Unit.UnitName,Unit.UnitCode,SUM(IncentiveNotice.IncentiveMoney) AS IncentiveMoneySum,COUNT(IncentiveNotice.IncentiveNoticeId) AS IncentiveCount"
2025-02-19 15:58:42 +08:00
+ @" FROM dbo.Check_IncentiveNotice AS IncentiveNotice "
+ @" LEFT JOIN Base_Unit AS Unit ON IncentiveNotice.UnitId = Unit.UnitId"
+ @" WHERE IncentiveNotice.States =" + BLL . Const . State_2 ;
2025-05-08 14:26:36 +08:00
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
2025-02-19 15:58:42 +08:00
2025-05-08 14:26:36 +08:00
if ( ! string . IsNullOrEmpty ( this . ProjectId ) )
{
strSql + = " AND IncentiveNotice.ProjectId = @ProjectId" ;
listStr . Add ( new SqlParameter ( "@ProjectId" , this . ProjectId ) ) ;
}
//if (!string.IsNullOrEmpty(UnitId))
//{
// strSql += " AND IncentiveNotice.UnitId = @UnitId1";
// listStr.Add(new SqlParameter("@UnitId1", UnitId));
//}
/// 施工分包 只看到自己已完成的奖励单
if ( BLL . ProjectUnitService . GetProjectUnitTypeByProjectIdUnitId ( this . ProjectId , this . CurrUser . UnitId ) )
{
strSql + = " AND IncentiveNotice.UnitId = @UnitId" ; ///奖励单位
listStr . Add ( new SqlParameter ( "@UnitId" , this . CurrUser . UnitId ) ) ;
}
if ( ! string . IsNullOrEmpty ( this . txtStartDate . Text . Trim ( ) ) )
{
strSql + = " AND IncentiveNotice.IncentiveDate >= @StartDate" ;
listStr . Add ( new SqlParameter ( "@StartDate" , this . txtStartDate . Text . Trim ( ) ) ) ;
}
if ( ! string . IsNullOrEmpty ( this . txtEndDate . Text . Trim ( ) ) )
{
strSql + = " AND IncentiveNotice.IncentiveDate <= @EndDate" ;
listStr . Add ( new SqlParameter ( "@EndDate" , this . txtEndDate . Text . Trim ( ) ) ) ;
}
strSql + = " GROUP BY IncentiveNotice.ProjectId,IncentiveNotice.UnitId,Unit.UnitName,Unit.UnitCode" ;
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 ( ) ;
2025-02-19 15:58:42 +08:00
}
}
#region 分 页 排 序
/// <summary>
/// 改变索引事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange ( object sender , GridPageEventArgs e )
{
BindGrid ( ) ;
}
/// <summary>
/// 分页下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged ( object sender , EventArgs e )
{
this . Grid1 . PageSize = Convert . ToInt32 ( this . ddlPageSize . SelectedValue ) ;
BindGrid ( ) ;
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort ( object sender , FineUIPro . GridSortEventArgs e )
{
this . BindGrid ( ) ;
}
#endregion
#endregion
#region 查 询
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged ( object sender , EventArgs e )
{
if ( ! string . IsNullOrEmpty ( this . txtStartDate . Text . Trim ( ) ) & & ! string . IsNullOrEmpty ( this . txtEndDate . Text . Trim ( ) ) )
{
if ( Convert . ToDateTime ( this . txtStartDate . Text . Trim ( ) ) > Convert . ToDateTime ( this . txtEndDate . Text . Trim ( ) ) )
{
Alert . ShowInTop ( "开始时间不能大于结束时间" , MessageBoxIcon . Warning ) ;
return ;
}
}
this . BindGrid ( ) ;
}
#endregion
#region 导 出 按 钮
/// 导出按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOut_Click ( object sender , EventArgs e )
{
Response . ClearContent ( ) ;
string filename = Funs . GetNewFileName ( ) ;
Response . AddHeader ( "content-disposition" , "attachment; filename=" + System . Web . HttpUtility . UrlEncode ( "奖励通知单" + filename , System . Text . Encoding . UTF8 ) + ".xls" ) ;
Response . ContentType = "application/excel" ;
Response . ContentEncoding = System . Text . Encoding . UTF8 ;
this . Grid1 . PageSize = this . Grid1 . RecordCount ;
this . BindGrid ( ) ;
Response . Write ( GetGridTableHtml ( Grid1 ) ) ;
Response . End ( ) ;
}
#endregion
protected void rbState_SelectedIndexChanged ( object sender , EventArgs e )
{
this . BindGrid ( ) ;
}
}
}