using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Threading.Tasks; namespace FineUIPro.Web.HSSE.Hazard { public partial class ConstructionRiskCheckSee : PageBase { #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { // 表头过滤 //FilterDataRowItem = FilterDataRowItemImplement; if (!IsPostBack) { //权限按钮方法 GetButtonPower(); // 绑定表格 BindGrid(); } } #endregion protected DataTable insklistData() { string strSql = @"SELECT ins.*,u.UserName as CheckManName" + @" FROM HSSE_ConstructionRiskCheck ins" + @" left join Sys_User u on u.UserId = ins.CheckMan" + @" where ins.ConstructionRiskId=@ConstructionRiskId "; List listStr = new List(); listStr.Add(new SqlParameter("@ConstructionRiskId", Request.Params["ConstructionRiskId"])); SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); return tb; } /// /// 绑定数据 /// public void BindGrid() { DataTable tb = insklistData(); // 2.获取当前分页数据 //var table = this.GetPagedDataTable(Grid1, tb1); Grid1.RecordCount = tb.Rows.Count; tb = GetFilteredTable(Grid1.FilteredData, tb); var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } #region 查询 /// /// 查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } #endregion #region 过滤表头、排序、分页、关闭窗口 /// /// 过滤表头 /// /// /// protected void Grid1_FilterChange(object sender, EventArgs e) { BindGrid(); } /// /// 分页 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { //Grid1.SortDirection = e.SortDirection; //Grid1.SortField = e.SortField; BindGrid(); } /// /// 关闭弹出窗 /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } #endregion #region Grid双击事件 /// /// Grid行双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { btnMenuModify_Click(null, null); } #endregion #region 编辑 /// /// 编辑按钮 /// /// /// protected void btnMenuModify_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string id = Grid1.SelectedRowID; var check = BLL.ConstructionRiskCheckService.GetConstructionRiskCheck(id); if (this.CurrUser.UserId == check.CheckMan || CurrUser.UserId == Const.sysglyId) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ConstructionRiskControlCheck.aspx?ConstructionRiskCheckId={0}", id, "编辑 - "))); return; } else { Alert.ShowInTop("您不是巡检人,无法编辑!", MessageBoxIcon.Warning); return; } } #endregion #region 删除 /// /// 批量删除 /// /// /// protected void btnMenuDel_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string id = Grid1.SelectedRowID; var check = BLL.ConstructionRiskCheckService.GetConstructionRiskCheck(id); if (this.CurrUser.UserId == check.CheckMan || CurrUser.UserId == Const.sysglyId) { BLL.ConstructionRiskCheckService.DeleteConstructionRiskCheck(id); BindGrid(); Alert.ShowInTop("删除数据成功!", MessageBoxIcon.Success); } else { Alert.ShowInTop("您不是巡检人,无法删除!", MessageBoxIcon.Warning); return; } } #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == "0") { return; } var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ConstructionRiskMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnModify)) { this.btnMenuModify.Hidden = false; } if (buttonList.Contains(BLL.Const.BtnDelete)) { this.btnMenuDel.Hidden = false; } } } #endregion /// /// 获取整改情况 /// /// /// protected string ConvertRectification(object Rectification) { if (Rectification != null) { if (Rectification.ToString() == "A") { return "隐患整改单"; } else if (Rectification.ToString() == "B") { return "安全巡检记录"; } else if (Rectification.ToString() == "C") { return "口头通知,现场已整改"; } else { return ""; } } return ""; } protected void Grid1_RowDataBound(object sender, GridRowEventArgs e) { } } }