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 Check : PageBase
{
#region 项目主键
///
/// 项目主键
///
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#endregion
#region 加载页面
///
/// 加载页面
///
///
///
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();
this.Panel1.Title = "安全监督检查数据(" + BLL.UnitService.GetUnitNameByUnitId(BLL.CommonService.GetThisUnitId()) + ")";
}
}
protected void changeTree(object sender, EventArgs e)
{
this.ProjectId = this.ucTree.ProjectId;
this.BindGrid();
}
private void BindGrid()
{
if (this.rbCom.SelectedValue == "1")
{
panelLeftRegion.Hidden = true;
var model = HSSEData_HSSEService.GetCompanyLeadShiftCheck();
if (!string.IsNullOrEmpty(this.txtStartTime.Text))
{
model = model.Where(x => x.CheckDate > this.txtStartTime.SelectedDate).ToList();
}
if (!string.IsNullOrEmpty(this.txtEndTime.Text))
{
model = model.Where(x => x.CheckDate < this.txtEndTime.SelectedDate).ToList();
}
Grid1.RecordCount = model.Count;
Grid1.DataSource = this.GetPagedDataTable(Grid1, Funs.LINQToDataTable(model));
Grid1.DataBind();
}
else if (this.rbCom.SelectedValue == "2")
{
panelLeftRegion.Hidden = true;
var model = HSSEData_HSSEService.GetCompanyComprehensiveCheck();
if (!string.IsNullOrEmpty(this.txtStartTime.Text))
{
model = model.Where(x => x.CheckDate > this.txtStartTime.SelectedDate).ToList();
}
if (!string.IsNullOrEmpty(this.txtEndTime.Text))
{
model = model.Where(x => x.CheckDate < this.txtEndTime.SelectedDate).ToList();
}
Grid1.RecordCount = model.Count;
Grid1.DataSource = this.GetPagedDataTable(Grid1, Funs.LINQToDataTable(model));
Grid1.DataBind();
}
else if (this.rbCom.SelectedValue == "3")
{
panelLeftRegion.Hidden = true;
var model = HSSEData_HSSEService.GetCompanySpecialCheck();
if (!string.IsNullOrEmpty(this.txtStartTime.Text))
{
model = model.Where(x => x.CheckDate > this.txtStartTime.SelectedDate).ToList();
}
if (!string.IsNullOrEmpty(this.txtEndTime.Text))
{
model = model.Where(x => x.CheckDate < this.txtEndTime.SelectedDate).ToList();
}
Grid1.RecordCount = model.Count;
Grid1.DataSource = this.GetPagedDataTable(Grid1, Funs.LINQToDataTable(model));
Grid1.DataBind();
}
///项目负责人带班检查
else if (this.rbCom.SelectedValue == "4")
{
panelLeftRegion.Hidden = false;
var model = HSSEData_HSSEService.GetProjectLeadShiftCheck();
if (!string.IsNullOrEmpty(this.txtEndTime.Text))
{
model = model.Where(x => x.CheckDate < this.txtEndTime.SelectedDate).ToList();
}
if (!string.IsNullOrEmpty(this.ucTree.SelectedNodeID))
{
if (!string.IsNullOrEmpty(this.ucTree.ProjectId))
{
model = model.Where(x => x.ProjectId == this.ucTree.ProjectId).ToList();
}
else
{
var BeUnderConstructionList = ProjectService.GetProjectWorkList().Where(x => (x.ProjectAttribute == "GONGCHENG" || x.ProjectAttribute == null) && x.UnitId == this.ucTree.UnitId).Select(x => x.ProjectId).ToList();
model = model.Where(x => BeUnderConstructionList.Contains(x.ProjectId)).ToList();
}
}
Grid1.RecordCount = model.Count;
Grid1.DataSource = this.GetPagedDataTable(Grid1, Funs.LINQToDataTable(model));
Grid1.DataBind();
}
///项目专业检查
else if (this.rbCom.SelectedValue == "5")
{
panelLeftRegion.Hidden = false;
var model = HSSEData_HSSEService.GetProjectSpecialCheck();
if (!string.IsNullOrEmpty(this.ucTree.SelectedNodeID))
{
if (!string.IsNullOrEmpty(this.ucTree.ProjectId))
{
model = model.Where(x => x.ProjectId == this.ucTree.ProjectId).ToList();
}
else
{
var BeUnderConstructionList = ProjectService.GetProjectWorkList().Where(x => (x.ProjectAttribute == "GONGCHENG" || x.ProjectAttribute == null) && x.UnitId == this.ucTree.UnitId).Select(x => x.ProjectId).ToList();
model = model.Where(x => BeUnderConstructionList.Contains(x.ProjectId)).ToList();
}
}
if (!string.IsNullOrEmpty(this.txtStartTime.Text))
{
model = model.Where(x => x.CheckDate > this.txtStartTime.SelectedDate).ToList();
}
if (!string.IsNullOrEmpty(this.txtEndTime.Text))
{
model = model.Where(x => x.CheckDate < this.txtEndTime.SelectedDate).ToList();
}
Grid1.RecordCount = model.Count;
Grid1.DataSource = this.GetPagedDataTable(Grid1, Funs.LINQToDataTable(model));
Grid1.DataBind();
this.Grid1.Columns[1].Hidden = false;
}
///项目专项目检查
else if (this.rbCom.SelectedValue == "6")
{
panelLeftRegion.Hidden = false;
var model = HSSEData_HSSEService.GetProjectMajorCheck();
if (!string.IsNullOrEmpty(this.ucTree.SelectedNodeID))
{
if (!string.IsNullOrEmpty(this.ucTree.ProjectId))
{
model = model.Where(x => x.ProjectId == this.ucTree.ProjectId).ToList();
}
else
{
var BeUnderConstructionList = ProjectService.GetProjectWorkList().Where(x => (x.ProjectAttribute == "GONGCHENG" || x.ProjectAttribute == null) && x.UnitId == this.ucTree.UnitId).Select(x => x.ProjectId).ToList();
model = model.Where(x => BeUnderConstructionList.Contains(x.ProjectId)).ToList();
}
}
if (!string.IsNullOrEmpty(this.txtStartTime.Text))
{
model = model.Where(x => x.CheckDate > this.txtStartTime.SelectedDate).ToList();
}
if (!string.IsNullOrEmpty(this.txtEndTime.Text))
{
model = model.Where(x => x.CheckDate < this.txtEndTime.SelectedDate).ToList();
}
Grid1.RecordCount = model.Count;
Grid1.DataSource = this.GetPagedDataTable(Grid1, Funs.LINQToDataTable(model));
Grid1.DataBind();
this.Grid1.Columns[1].Hidden = false;
}
}
#endregion
#region 查询
///
/// 查询
///
///
///
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
#region 表排序、分页、关闭窗口
///
/// 分页
///
///
///
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
///
/// 排序
///
///
///
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
BindGrid();
}
///
/// 分页显示条数下拉框
///
///
///
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
///
/// 关闭弹出窗
///
///
///
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
#region Grid双击事件 编辑
///
/// Grid行双击事件
///
///
///
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
EditData();
}
///
///
///
private void EditData()
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
if (this.rbCom.SelectedValue == "1"|| this.rbCom.SelectedValue == "2" || this.rbCom.SelectedValue == "3")
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../ZHGL/Supervise/SuperviseCheckReportEdit.aspx?SuperviseCheckReportId={0}&type=-1", Grid1.SelectedRowID, "查看 - ")));
}
else if (this.rbCom.SelectedValue == "4")
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../HSSE/Check/ProjectLeaderCheckView.aspx?ProjectLeaderCheckId={0}", Grid1.SelectedRowID, "查看 - ")));
}
else if (this.rbCom.SelectedValue == "5")
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../HSSE/HiddenInspection/HiddenRectificationView.aspx?HazardRegisterId={0}", Grid1.SelectedRowID, "查看 - ")));
}
else if (this.rbCom.SelectedValue == "6")
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../HSSE/Check/CheckSpecialView.aspx?CheckSpecialId={0}", Grid1.SelectedRowID, "查看 - ")));
}
}
#endregion
///
///
///
///
///
protected void btnView_Click(object sender, EventArgs e)
{
EditData();
}
}
}