using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using BLL; namespace FineUIPro.Web.Customization.ZJ.HSSE.HiddenInspection { public partial class SuperviseCheck : PageBase { #region 项目主键 /// /// 项目主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } #endregion protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Funs.DropDownPageSize(this.ddlPageSize); this.ProjectId = this.CurrUser.LoginProjectId; if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId) { this.ProjectId = Request.Params["projectId"]; } this.ucTree.UnitId = this.CurrUser.UnitId; this.ucTree.ProjectId = this.ProjectId; if (!string.IsNullOrEmpty(this.ProjectId)) { this.panelLeftRegion.Hidden = true; ////权限按钮方法 this.GetButtonPower(); } this.btnNew.OnClientClick = Window1.GetShowReference("SuperviseCheckEdit.aspx?Type=0") + "return false;"; if (this.CurrUser != null && this.CurrUser.PageSize.HasValue) { Grid1.PageSize = this.CurrUser.PageSize.Value; } this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); // 绑定表格 this.BindGrid(); } } /// /// 公司级树加载 /// /// /// protected void changeTree(object sender, EventArgs e) { this.ProjectId = this.ucTree.ProjectId; if (string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) { btnNew.Hidden = true; } this.GetButtonPower(); this.BindGrid(); } #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == "0") { return; } var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, BLL.Const.SuperviseCheckMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnAdd)) { this.btnNew.Hidden = false; } if (buttonList.Contains(BLL.Const.BtnModify)) { this.btnMenuEdit.Hidden = false; } if (buttonList.Contains(BLL.Const.BtnDelete)) { this.btnMenuDelete.Hidden = false; } } if (!string.IsNullOrEmpty(this.ProjectId)) { this.btnNew.Hidden = true; } } #endregion /// /// 搜索 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// 改变索引事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } /// /// 关闭弹出窗 /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } #region 加载数据 protected void BindGrid() { if (string.IsNullOrEmpty(this.ProjectId)) { return; } var result = (from supervise in Funs.DB.ZJ_SuperviseCheck join project in Funs.DB.Base_Project on supervise.ProjectId equals project.ProjectId join user in Funs.DB.Sys_User on supervise.RecUserId equals user.UserId select new { supervise.SuperviseCheckId, project.ProjectName, project.ProjectId, supervise.SuperviseCheckReportCode, user.UserName, supervise.CheckDate, State = supervise.State == 0 ? "未提交" : supervise.State == 1 ? "未整改" : supervise.State == 2 ? "部分整改" : supervise.State == 3 ? "已整改" : "", supervise.CheckTeam, }).ToList(); if (!string.IsNullOrEmpty(this.ProjectId)) { result = result.Where(p => p.ProjectId == this.ProjectId).ToList(); } Grid1.RecordCount = result.Count; Grid1.DataSource = this.GetPagedDataTable(Grid1, Funs.LINQToDataTable(result)); Grid1.DataBind(); } #endregion #region 编辑 protected void btnMenuView_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string id = Grid1.SelectedRowID; PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SuperviseCheckEdit.aspx?SuperviseCheckId={0}", id, "查看 - "))); } /// /// 双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { this.EditData(); } /// /// 右键编辑事件 /// /// /// protected void btnMenuEdit_Click(object sender, EventArgs e) { this.EditData(); } /// /// 编辑 /// protected void EditData() { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string id = Grid1.SelectedRowID; var ProblemNoticeItem = SupervisecheckService.GetZJ_SuperviseCheckById(id); if (ProblemNoticeItem != null) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SuperviseCheckEdit.aspx?SuperviseCheckId={0} ", id, "查看 - "))); } } #endregion #region 删除 /// /// 右键删除事件 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length > 0) { foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); var getV = SupervisecheckService.GetZJ_SuperviseCheckById(rowID); if (getV.State != 0) { ShowNotify("只能删除待提交的数据!", MessageBoxIcon.Warning); return; } if (getV != null) { BLL.SupervisecheckService.DeleteZJ_SuperviseCheckById(rowID); } } this.BindGrid(); ShowNotify("删除数据成功!", MessageBoxIcon.Success); } } #endregion } }