358 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			358 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			C#
		
	
	
	
| using BLL;
 | ||
| using System;
 | ||
| using System.Collections.Generic;
 | ||
| using System.Data;
 | ||
| using System.Data.SqlClient;
 | ||
| using System.Linq;
 | ||
| 
 | ||
| namespace FineUIPro.Web.DataShow
 | ||
| {
 | ||
|     public partial class Emergency : 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);           
 | ||
|                 BLL.ProjectService.InitProjectDropDownList(this.drpProject, true);
 | ||
| 
 | ||
|                 ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
 | ||
|                 ddlPageSize2.SelectedValue = Grid2.PageSize.ToString();
 | ||
|                 // 绑定表格t
 | ||
|                 BindGrid();
 | ||
|                 BindGrid2();
 | ||
|                 this.Panel1.Title = "应急管理数据(" + BLL.UnitService.GetUnitNameByUnitId(BLL.Const.UnitId_CWCEC) + ")";
 | ||
|             }
 | ||
|         }
 | ||
|         #endregion
 | ||
| 
 | ||
|         #region 查询
 | ||
|         /// <summary>
 | ||
|         /// 查询
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void TextBox_TextChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if (this.rbCom.SelectedValue == "1")
 | ||
|             {
 | ||
|                 this.drpProject.Hidden = false;
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 this.drpProject.Hidden = true;
 | ||
|             }
 | ||
|             this.BindGrid();
 | ||
|             this.BindGrid2();
 | ||
|         }
 | ||
|         #endregion
 | ||
| 
 | ||
|         #region 数据绑定1
 | ||
|         /// <summary>
 | ||
|         /// 绑定数据
 | ||
|         /// </summary>
 | ||
|         private void BindGrid()
 | ||
|         {
 | ||
|             if (this.rbCom.SelectedValue == "0")
 | ||
|             {
 | ||
|                 string strSql = @"SELECT Em.EmergencyListId,Em.UnitId,Unit.UnitName,EmergencyType.EmergencyTypeName
 | ||
|                     ,Em.EmergencyName,Em.CompileDate,Em.CompileMan,Users.UserName AS CompileManName
 | ||
|                     ,Em.VersionCode,Em.States
 | ||
|                     FROM Emergency_EmergencyList_Unit AS Em 
 | ||
|                     LEFT JOIN Base_Unit AS Unit ON Em.UnitId=Unit.UnitId 
 | ||
|                     LEFT JOIN Base_EmergencyType AS EmergencyType ON Em.EmergencyTypeId=EmergencyType.EmergencyTypeId
 | ||
|                     LEFT JOIN Sys_User AS Users ON Em.CompileMan=Users.UserId WHERE 1=1 ";
 | ||
|                 List<SqlParameter> listStr = new List<SqlParameter>();
 | ||
|                 if (!string.IsNullOrEmpty(this.txtStartTime.Text))
 | ||
|                 {
 | ||
|                     strSql += " AND Em.CompileDate >=@StartTime";
 | ||
|                     listStr.Add(new SqlParameter("@StartTime", this.txtStartTime.Text));
 | ||
|                 }
 | ||
|                 if (!string.IsNullOrEmpty(this.txtEndTime.Text))
 | ||
|                 {
 | ||
|                     strSql += " AND Em.CompileDate <=@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 Em.EmergencyListId,Project.ProjectId,Project.ProjectCode,Project.ProjectName
 | ||
|                     ,Em.UnitId,Unit.UnitName,EmergencyType.EmergencyTypeName
 | ||
|                     ,Em.EmergencyName,Em.CompileDate,Em.CompileMan,Users.UserName AS CompileManName
 | ||
|                     ,Em.VersionCode,Em.States
 | ||
|                     FROM Emergency_EmergencyList AS Em 
 | ||
|                     LEFT JOIN Base_Unit AS Unit ON Em.UnitId=Unit.UnitId 
 | ||
|                     LEFT JOIN Base_Project AS Project ON Em.ProjectId=Project.ProjectId 
 | ||
|                     LEFT JOIN Base_EmergencyType AS EmergencyType ON Em.EmergencyTypeId=EmergencyType.EmergencyTypeId
 | ||
|                     LEFT JOIN Sys_User AS Users ON Em.CompileMan=Users.UserId 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 Em.CompileDate >=@StartTime";
 | ||
|                     listStr.Add(new SqlParameter("@StartTime", this.txtStartTime.Text));
 | ||
|                 }
 | ||
|                 if (!string.IsNullOrEmpty(this.txtEndTime.Text))
 | ||
|                 {
 | ||
|                     strSql += " AND Em.CompileDate <=@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;
 | ||
|             }
 | ||
|         }
 | ||
|     
 | ||
|         #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();
 | ||
|         }
 | ||
|         #endregion
 | ||
| 
 | ||
|         #region Grid双击事件 编辑
 | ||
|         /// <summary>
 | ||
|         /// Grid行双击事件
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
 | ||
|         {
 | ||
|             EditData1();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 
 | ||
|         /// </summary>
 | ||
|         private void EditData1()
 | ||
|         {
 | ||
|             if (Grid1.SelectedRowIndexArray.Length == 0)
 | ||
|             {
 | ||
|                 Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
 | ||
|                 return;
 | ||
|             }
 | ||
|             if (this.rbCom.SelectedValue == "0")
 | ||
|             {
 | ||
|                 PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../ZHGL/Emergency/EmergencyListView.aspx?EmergencyListId={0}", Grid1.SelectedRowID, "查看 - ")));
 | ||
|             }
 | ||
|             else if (this.rbCom.SelectedValue == "1")
 | ||
|             {
 | ||
|                 PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../HSSE/Emergency/EmergencyListView.aspx?EmergencyListId={0}", Grid1.SelectedRowID, "查看 - ")));
 | ||
|             }
 | ||
|            
 | ||
|         }
 | ||
|         #endregion
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void btnView_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             EditData1();
 | ||
|         }
 | ||
| 
 | ||
|         protected void btnView2_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             EditData2();
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         #region 数据绑定2
 | ||
|         /// <summary>
 | ||
|         /// 绑定数据
 | ||
|         /// </summary>
 | ||
|         private void BindGrid2()
 | ||
|         {
 | ||
|             if (this.rbCom.SelectedValue == "0")
 | ||
|             {
 | ||
|                 string strSql = @"SELECT List.DrillRecordListId
 | ||
|                             ,DrillRecordType.ConstText AS DrillRecordTypeName,List.JointPersonNum,List.DrillCost
 | ||
|                             ,List.DrillRecordName,List.DrillRecordDate
 | ||
|                             ,List.UnitIds,List.UnitNames
 | ||
|                             ,List.States 
 | ||
|                             FROM Emergency_DrillRecordList_Unit AS List  
 | ||
|                             LEFT JOIN Sys_Const AS DrillRecordType ON DrillRecordType.ConstValue = List.DrillRecordType 
 | ||
|                             and DrillRecordType.GroupId='DrillRecordType'
 | ||
|                             WHERE 1=1  ";
 | ||
|                 List<SqlParameter> listStr = new List<SqlParameter>();
 | ||
|                 if (!string.IsNullOrEmpty(this.txtStartTime.Text))
 | ||
|                 {
 | ||
|                     strSql += " AND Em.CompileDate >=@StartTime";
 | ||
|                     listStr.Add(new SqlParameter("@StartTime", this.txtStartTime.Text));
 | ||
|                 }
 | ||
|                 if (!string.IsNullOrEmpty(this.txtEndTime.Text))
 | ||
|                 {
 | ||
|                     strSql += " AND Em.CompileDate <=@EndTime";
 | ||
|                     listStr.Add(new SqlParameter("@EndTime", this.txtEndTime.Text));
 | ||
|                 }
 | ||
| 
 | ||
|                 SqlParameter[] parameter = listStr.ToArray();
 | ||
|                 DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
 | ||
|                 Grid2.RecordCount = tb.Rows.Count;
 | ||
|                 var table = this.GetPagedDataTable(Grid2, tb);
 | ||
|                 Grid2.DataSource = table;
 | ||
|                 Grid2.DataBind();
 | ||
|                 this.Grid2.Columns[1].Hidden = true;
 | ||
|             }
 | ||
|             else if (this.rbCom.SelectedValue == "1")
 | ||
|             {
 | ||
|                 string strSql = @"SELECT List.DrillRecordListId,List.ProjectId,Project.PostCode,Project.ProjectName
 | ||
|                         ,DrillRecordType.ConstText AS DrillRecordTypeName,List.JointPersonNum,List.DrillCost
 | ||
|                         ,List.DrillRecordName,List.DrillRecordDate
 | ||
|                         ,List.UnitIds,List.UnitNames
 | ||
|                         ,List.States 
 | ||
|                         FROM Emergency_DrillRecordList AS List  
 | ||
|                         LEFT JOIN Base_Project AS Project ON List.Projectid = Project.ProjectId
 | ||
|                         LEFT JOIN Sys_Const AS DrillRecordType ON DrillRecordType.ConstValue = List.DrillRecordType 
 | ||
|                         and DrillRecordType.GroupId='DrillRecordType'
 | ||
|                         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 Em.CompileDate >=@StartTime";
 | ||
|                     listStr.Add(new SqlParameter("@StartTime", this.txtStartTime.Text));
 | ||
|                 }
 | ||
|                 if (!string.IsNullOrEmpty(this.txtEndTime.Text))
 | ||
|                 {
 | ||
|                     strSql += " AND Em.CompileDate <=@EndTime";
 | ||
|                     listStr.Add(new SqlParameter("@EndTime", this.txtEndTime.Text));
 | ||
|                 }
 | ||
| 
 | ||
|                 SqlParameter[] parameter = listStr.ToArray();
 | ||
|                 DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
 | ||
|                 Grid2.RecordCount = tb.Rows.Count;
 | ||
|                 var table = this.GetPagedDataTable(Grid2, tb);
 | ||
|                 Grid2.DataSource = table;
 | ||
|                 Grid2.DataBind();
 | ||
|                 this.Grid2.Columns[1].Hidden = true;
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         #endregion
 | ||
| 
 | ||
|         #region 表排序、分页、关闭窗口
 | ||
|         /// <summary>
 | ||
|         /// 分页
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void Grid2_PageIndexChange(object sender, GridPageEventArgs e)
 | ||
|         {
 | ||
|             BindGrid2();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 排序
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void Grid2_Sort(object sender, GridSortEventArgs e)
 | ||
|         {
 | ||
|             BindGrid2();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 分页显示条数下拉框
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void ddlPageSize2_SelectedIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             Grid2.PageSize = Convert.ToInt32(ddlPageSize2.SelectedValue);
 | ||
|             BindGrid2();
 | ||
|         }
 | ||
| 
 | ||
|         #endregion
 | ||
| 
 | ||
|         #region Grid双击事件 编辑
 | ||
|         /// <summary>
 | ||
|         /// Grid行双击事件
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         protected void Grid2_RowDoubleClick(object sender, GridRowClickEventArgs e)
 | ||
|         {
 | ||
|             EditData2();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 
 | ||
|         /// </summary>
 | ||
|         private void EditData2()
 | ||
|         {
 | ||
|             if (Grid2.SelectedRowIndexArray.Length == 0)
 | ||
|             {
 | ||
|                 Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
 | ||
|                 return;
 | ||
|             }
 | ||
|             if (this.rbCom.SelectedValue == "0")
 | ||
|             {
 | ||
|                 PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../ZHGL/Emergency/DrillRecordListView.aspx?DrillRecordListId={0}", Grid2.SelectedRowID, "查看 - ")));
 | ||
|             }
 | ||
|             else if (this.rbCom.SelectedValue == "1")
 | ||
|             {
 | ||
|                 PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../HSSE/Emergency/DrillRecordListView.aspx?DrillRecordListId={0}", Grid2.SelectedRowID, "查看 - ")));
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|         #endregion
 | ||
|     }
 | ||
| } |