2023-03-25 14:46:00 +08:00
using Aspose.Words ;
using BLL ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Data.SqlClient ;
using System.IO ;
using System.Linq ;
using System.Text ;
namespace FineUIPro.Web.DataShow
{
public partial class Meeting : PageBase
{
#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 ) ;
ddlPageSize . SelectedValue = Grid1 . PageSize . ToString ( ) ;
BLL . ProjectService . InitProjectDropDownList ( this . drpProject , true ) ;
// 绑定表格t
BindGrid ( ) ;
2023-06-07 18:55:33 +08:00
this . Panel1 . Title = "安全会议(" + BLL . UnitService . GetUnitNameByUnitId ( BLL . Const . UnitId_CWCEC ) + ") " ;
2023-03-25 14:46:00 +08:00
}
}
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid ( )
{
if ( this . rbCom . SelectedValue = = "0" )
{
string strSql = @ "SELECT Meeting.CompanySafetyMeetingId AS ID,Meeting.CompanySafetyMeetingName AS MeetingName
, Meeting . CompanySafetyMeetingDate AS MeetingDate , Meeting . MeetingHours
, MeetingHostMan AS HostMan , Meeting . AttentPersonNum , Meeting . AttentPerson
FROM Meeting_CompanySafetyMeeting AS Meeting
LEFT JOIN Sys_User AS Users ON Meeting . MeetingHostMan = Users . UserId
where 1 = 1 ";
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
if ( ! string . IsNullOrEmpty ( this . txtStartTime . Text ) )
{
strSql + = " AND Meeting.CompanySafetyMeetingDate >=@StartTime" ;
listStr . Add ( new SqlParameter ( "@StartTime" , this . txtStartTime . Text ) ) ;
}
if ( ! string . IsNullOrEmpty ( this . txtEndTime . Text ) )
{
strSql + = " AND Meeting.CompanySafetyMeetingDate <=@EndTime" ;
listStr . Add ( new SqlParameter ( "@EndTime" , this . txtEndTime . Text ) ) ;
}
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 ( ) ;
this . Grid1 . Columns [ 1 ] . Hidden = true ;
}
else if ( this . rbCom . SelectedValue = = "1" )
{
string strSql = @ "SELECT Meeting.CompanySpecialMeetingId AS ID,Meeting.CompanySpecialMeetingName AS MeetingName
, Meeting . CompanySpecialMeetingDate AS MeetingDate , Meeting . MeetingHours
, MeetingHostMan AS HostMan , Meeting . AttentPersonNum , Meeting . AttentPerson
FROM Meeting_CompanySpecialMeeting AS Meeting
LEFT JOIN Sys_User AS Users ON Meeting . MeetingHostMan = Users . UserId
where 1 = 1 ";
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
if ( ! string . IsNullOrEmpty ( this . txtStartTime . Text ) )
{
strSql + = " AND Meeting.CompanySpecialMeetingDate >=@StartTime" ;
listStr . Add ( new SqlParameter ( "@StartTime" , this . txtStartTime . Text ) ) ;
}
if ( ! string . IsNullOrEmpty ( this . txtEndTime . Text ) )
{
strSql + = " AND Meeting.CompanySpecialMeetingDate <=@EndTime" ;
listStr . Add ( new SqlParameter ( "@EndTime" , this . txtEndTime . Text ) ) ;
}
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 ( ) ;
this . Grid1 . Columns [ 1 ] . Hidden = true ;
}
else if ( this . rbCom . SelectedValue = = "2" )
{
string strSql = @ "SELECT Project.ProjectName,Meeting.SafetyLeaderGroupMeetingId AS ID,Meeting.SafetyLeaderGroupMeetingName AS MeetingName,Meeting.SafetyLeaderGroupMeetingDate AS MeetingDate,Meeting.MeetingHours
, MeetingHostMan AS HostMan , Meeting . AttentPersonNum , Meeting . AttentPerson
FROM Meeting_SafetyLeaderGroupMeeting AS Meeting
LEFT JOIN Sys_User AS Users ON Meeting . MeetingHostMan = Users . UserId
LEFT JOIN Base_Project AS Project ON Meeting . ProjectId = Project . ProjectId
where 1 = 1 ";
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
if ( this . drpProject . SelectedValue ! = Const . _Null )
{
strSql + = " AND Project.ProjectId =@ProjectId" ;
listStr . Add ( new SqlParameter ( "@ProjectId" , this . drpProject . SelectedValue ) ) ;
}
if ( ! string . IsNullOrEmpty ( this . txtStartTime . Text ) )
{
strSql + = " AND Meeting.SafetyLeaderGroupMeetingDate >=@StartTime" ;
listStr . Add ( new SqlParameter ( "@StartTime" , this . txtStartTime . Text ) ) ;
}
if ( ! string . IsNullOrEmpty ( this . txtEndTime . Text ) )
{
strSql + = " AND Meeting.SafetyLeaderGroupMeetingDate <=@EndTime" ;
listStr . Add ( new SqlParameter ( "@EndTime" , this . txtEndTime . Text ) ) ;
}
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 ( ) ;
this . Grid1 . Columns [ 1 ] . Hidden = false ;
}
else if ( this . rbCom . SelectedValue = = "3" )
{
string strSql = @ "SELECT ProjectId,ProjectName, ID, MeetingName, MeetingDate,MeetingHours,HostMan,AttentPersonNum,AttentPerson
FROM ( SELECT Project . ProjectId , Project . ProjectName , Meeting . MonthMeetingId AS ID , Meeting . MonthMeetingName AS MeetingName , Meeting . MonthMeetingDate AS MeetingDate , Meeting . MeetingHours
, MeetingHostMan AS HostMan , Meeting . AttentPersonNum , Meeting . AttentPerson
FROM Meeting_MonthMeeting AS Meeting
LEFT JOIN Sys_User AS Users ON Meeting . MeetingHostMan = Users . UserId
LEFT JOIN Base_Project AS Project ON Meeting . ProjectId = Project . ProjectId
union all
SELECT Project . ProjectId , Project . ProjectName , Meeting . WeekMeetingId AS ID , Meeting . WeekMeetingName AS MeetingName , Meeting . WeekMeetingDate AS MeetingDate , Meeting . MeetingHours
, MeetingHostMan AS HostMan , Meeting . AttentPersonNum , Meeting . AttentPerson
FROM Meeting_WeekMeeting AS Meeting
LEFT JOIN Sys_User AS Users ON Meeting . MeetingHostMan = Users . UserId
LEFT JOIN Base_Project AS Project ON Meeting . ProjectId = Project . ProjectId ) V
where 1 = 1 ";
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
if ( this . drpProject . SelectedValue ! = Const . _Null )
{
strSql + = " AND V.ProjectId =@ProjectId" ;
listStr . Add ( new SqlParameter ( "@ProjectId" , this . drpProject . SelectedValue ) ) ;
}
if ( ! string . IsNullOrEmpty ( this . txtStartTime . Text ) )
{
strSql + = " AND V.MeetingDate >=@StartTime" ;
listStr . Add ( new SqlParameter ( "@StartTime" , this . txtStartTime . Text ) ) ;
}
if ( ! string . IsNullOrEmpty ( this . txtEndTime . Text ) )
{
strSql + = " AND V.MeetingDate <=@EndTime" ;
listStr . Add ( new SqlParameter ( "@EndTime" , this . txtEndTime . Text ) ) ;
}
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 ( ) ;
this . Grid1 . Columns [ 1 ] . Hidden = false ;
}
}
#endregion
#region 查 询
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged ( object sender , EventArgs e )
{
if ( this . rbCom . SelectedValue = = "2" | | this . rbCom . SelectedValue = = "3" )
{
this . drpProject . Hidden = false ;
}
else
{
this . drpProject . Hidden = true ;
}
this . BindGrid ( ) ;
}
#endregion
#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 Grid1_Sort ( object sender , GridSortEventArgs e )
{
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 Window1_Close ( object sender , WindowCloseEventArgs e )
{
BindGrid ( ) ;
}
#endregion
#region Grid双击事件 编 辑
/// <summary>
/// Grid行双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick ( object sender , GridRowClickEventArgs e )
{
EditData ( ) ;
}
/// <summary>
///
/// </summary>
private void EditData ( )
{
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请至少选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( this . rbCom . SelectedValue = = "0" )
{
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "../ZHGL/Meeting/CompanySafetyMeetingView.aspx?CompanySafetyMeetingId={0}" , Grid1 . SelectedRowID , "查看 - " ) ) ) ;
}
else if ( this . rbCom . SelectedValue = = "1" )
{
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "../ZHGL/Meeting/CompanySpecialMeetingView.aspx?CompanySpecialMeetingId={0}" , Grid1 . SelectedRowID , "查看 - " ) ) ) ;
}
else if ( this . rbCom . SelectedValue = = "2" )
{
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "../HSSE/Meeting/SafetyLeaderGroupMeetingView.aspx?SafetyLeaderGroupMeetingId={0}" , Grid1 . SelectedRowID , "查看 - " ) ) ) ;
}
else if ( this . rbCom . SelectedValue = = "3" )
{
var getMeet = BLL . WeekMeetingService . GetWeekMeetingById ( Grid1 . SelectedRowID ) ;
if ( getMeet ! = null )
{
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "../HSSE/Meeting/WeekMeetingView.aspx?WeekMeetingId={0}" , Grid1 . SelectedRowID , "查看 - " ) ) ) ;
}
else
{
PageContext . RegisterStartupScript ( Window1 . GetShowReference ( String . Format ( "../HSSE/Meeting/MonthMeetingView.aspx?MonthMeetingId={0}" , Grid1 . SelectedRowID , "查看 - " ) ) ) ;
}
}
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnView_Click ( object sender , EventArgs e )
{
EditData ( ) ;
}
}
}