297 lines
10 KiB
C#
297 lines
10 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using BLL;
|
|
using System.Text;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.HSSE.HiddenInspection
|
|
{
|
|
public partial class ServerHiddenRectificationList : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string UnitId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["UnitId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["UnitId"] = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 项目主键
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 菜单主键
|
|
/// </summary>
|
|
public string MenuId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["MenuId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["MenuId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#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);
|
|
HSSE_Hazard_HazardRegisterService.InitStatesDropDownList(this.drpStates, false);
|
|
Funs.FineUIPleaseSelect(this.drpStates, "按状态查询");
|
|
// ConstValue.InitConstValueRadioButtonList(this.ckType, ConstValue.Group_CheckCycle, "D");
|
|
|
|
this.UnitId = this.CurrUser.UnitId ?? CommonService.GetThisUnitId();
|
|
UnitService.InitBranchUnitDropDownList(this.drpCompany,false);
|
|
Funs.FineUIPleaseSelect(this.drpCompany, "按企业查询");
|
|
if (this.UnitId != CommonService.GetThisUnitId())
|
|
{
|
|
this.drpCompany.Readonly = true;
|
|
this.drpCompany.SelectedValue = this.UnitId;
|
|
}
|
|
|
|
ProjectService.InitUnitProjectDropDownList(this.drpProject, this.drpCompany.SelectedValue, false);
|
|
Funs.FineUIPleaseSelect(this.drpProject, "按项目查询");
|
|
BindGrid();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = "SELECT * FROM View_Hazard_HazardRegister WHERE 1=1 ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
//strSql += " AND CheckCycle=@Type ";
|
|
//listStr.Add(new SqlParameter("@Type", this.ckType.SelectedValue));
|
|
if (this.drpCompany.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.drpCompany.SelectedValue))
|
|
{
|
|
strSql += " AND PUnitId = @PUnitId";
|
|
listStr.Add(new SqlParameter("@PUnitId", this.drpCompany.SelectedValue));
|
|
}
|
|
|
|
if (this.drpProject.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.drpProject.SelectedValue))
|
|
{
|
|
strSql += " AND ProjectId = @ProjectId";
|
|
listStr.Add(new SqlParameter("@ProjectId", this.drpProject.SelectedValue));
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(this.txtStartTime.Text))
|
|
{
|
|
strSql += " AND CheckTime >= @StartTime";
|
|
listStr.Add(new SqlParameter("@StartTime", this.txtStartTime.Text));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtEndTime.Text))
|
|
{
|
|
strSql += " AND CheckTime < @End";
|
|
listStr.Add(new SqlParameter("@End", this.txtEndTime.Text));
|
|
}
|
|
|
|
if (this.drpStates.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql += " AND States LIKE @States";
|
|
listStr.Add(new SqlParameter("@States", "%" + this.drpStates.SelectedValue + "%"));
|
|
}
|
|
|
|
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();
|
|
}
|
|
#endregion
|
|
|
|
#region 过滤表头、排序、分页、关闭窗口
|
|
/// <summary>
|
|
/// 过滤表头
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_FilterChange(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <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 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)
|
|
{
|
|
btnMenuSee_Click(null, null);
|
|
}
|
|
#endregion
|
|
|
|
#region 查看
|
|
/// <summary>
|
|
/// 查看按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuSee_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string RegistrationId = Grid1.SelectedRowID;
|
|
var registration = BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByHazardRegisterId(RegistrationId);
|
|
if (registration != null)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("HiddenRectificationView.aspx?HazardRegisterId={0}", RegistrationId, "查看 - ")));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Grid行点击事件
|
|
/// <summary>
|
|
/// Grid行点击事件
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
string RegistrationId = Grid1.DataKeys[e.RowIndex][0].ToString();
|
|
var hazardRegister = BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByHazardRegisterId(RegistrationId);
|
|
if (hazardRegister != null)
|
|
{
|
|
if (e.CommandName == "click") //// 查看整改单
|
|
{
|
|
var getRe = RectifyNoticesService.GetRectifyNoticesById(hazardRegister.ResultId);
|
|
if (getRe != null)
|
|
{
|
|
if (getRe.CompleteManId == this.CurrUser.UserId && (string.IsNullOrEmpty(getRe.States) || getRe.States == Const.State_0))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../Check/RectifyNoticesAdd.aspx?RectifyNoticesId={0}", getRe.RectifyNoticesId, "编辑 - ")));
|
|
}
|
|
else
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../Check/RectifyNoticesView.aspx?RectifyNoticesId={0}", getRe.RectifyNoticesId, "查看 - ")));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#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 = Encoding.UTF8;
|
|
this.Grid1.PageSize = this.Grid1.RecordCount;
|
|
this.BindGrid();
|
|
Response.Write(GetGridTableHtml(Grid1));
|
|
Response.End();
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 企业下拉框
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpCompany_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
ProjectService.InitUnitProjectDropDownList(this.drpProject, this.drpCompany.SelectedValue, false);
|
|
Funs.FineUIPleaseSelect(this.drpProject, "按项目查询");
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
} |