using BLL; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace FineUIPro.Web.HSSE.Hazard { public partial class ConstructionRiskView : PageBase { #region 定义变量 /// /// 主键 /// public string ConstructionRiskId { get { return (string)ViewState["ConstructionRiskId"]; } set { ViewState["ConstructionRiskId"] = value; } } /// /// 项目主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } /// /// 办理类型 /// public string State { get { return (string)ViewState["State"]; } set { ViewState["State"] = value; } } /// /// 定义集合 /// private static List constructionRiskControls = new List(); #endregion #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ProjectId = this.CurrUser.LoginProjectId; this.InitDropDownList(); this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); constructionRiskControls.Clear(); this.ConstructionRiskId = Request.Params["ConstructionRiskId"]; var constructionRisk = Funs.DB.HSSE_ConstructionRisk.FirstOrDefault(x => x.ConstructionRiskId == this.ConstructionRiskId); if (constructionRisk != null) { this.hdConstructionRiskId.Text = this.ConstructionRiskId; this.ProjectId = constructionRisk.ProjectId; this.dpDateA.Text = string.Format("{0:yyyy-MM-dd}", constructionRisk.DateA); this.dpDateZ.Text = string.Format("{0:yyyy-MM-dd}", constructionRisk.DateZ); if (!string.IsNullOrEmpty(constructionRisk.WorkAreaId)) { drpWorkArea.SelectedValue = constructionRisk.WorkAreaId; } if (!string.IsNullOrEmpty(constructionRisk.UnitId)) { drpUnit.SelectedValue = constructionRisk.UnitId; } if (!string.IsNullOrEmpty(constructionRisk.RefLicense)) { drpRefLicense.SelectedValueArray = constructionRisk.RefLicense.Split(','); this.drpRiskLevel.DataSource = BLL.ConstructionRiskListService.RiskLevelList2(); this.drpRiskLevel.DataBind(); Funs.FineUIPleaseSelect(this.drpRiskLevel); } if (!string.IsNullOrEmpty(constructionRisk.RiskLevel)) { drpRiskLevel.SelectedValue = constructionRisk.RiskLevel; } if (!string.IsNullOrEmpty(constructionRisk.ConstructionContent)) { this.txtConstructionContent.Text = HttpUtility.HtmlDecode(constructionRisk.ConstructionContent); } this.hdConstructionContentId.Text = constructionRisk.ConstructionContentId; if (!string.IsNullOrEmpty(constructionRisk.RiskLevel)) { this.drpRiskLevel.SelectedValueArray = constructionRisk.RiskLevel.Split(','); } if (!string.IsNullOrEmpty(constructionRisk.LicenseDes)) { this.drpLicenseDes.SelectedValueArray = constructionRisk.LicenseDes.Split(','); } this.hdCoordinate.Text = constructionRisk.Coordinate; constructionRiskControls = (from x in Funs.DB.HSSE_ConstructionRiskControl where x.ConstructionRiskId == this.ConstructionRiskId orderby x.ShowIndex select x).ToList(); gvApprove.DataSource = BLL.ConstructionRiskApproveService.getListData(this.ConstructionRiskId); gvApprove.DataBind(); if (!string.IsNullOrEmpty(constructionRisk.States)) { State = constructionRisk.States; } else { State = BLL.Const.ConstructionRisk_Compile; } } else { this.drpUnit.SelectedValue = this.CurrUser.UnitId; } Grid1.DataSource = constructionRiskControls; Grid1.DataBind(); } } #endregion /// /// 初始化下拉框 /// private void InitDropDownList() { ///区域下拉框 UnitWorkService.InitUnitWorkDownList(this.drpWorkArea, this.CurrUser.LoginProjectId, true); drpRefLicense.DataValueField = "LicenseTypeName"; drpRefLicense.DataTextField = "LicenseTypeName"; drpRefLicense.DataSource = (from x in Funs.DB.Base_LicenseType orderby x.LicenseTypeCode select x).ToList(); drpRefLicense.DataBind(); Funs.FineUIPleaseSelect(this.drpRefLicense); this.drpRiskLevel.DataTextField = "Text"; this.drpRiskLevel.DataValueField = "Value"; this.drpRiskLevel.DataSource = BLL.ConstructionRiskListService.RiskLevelList(); this.drpRiskLevel.DataBind(); Funs.FineUIPleaseSelect(this.drpRiskLevel); Funs.FineUIPleaseSelect(this.drpLicenseDes); UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpUnit, this.ProjectId, Const.ProjectUnitType_2, false); } #region 关闭弹出窗 /// /// 关闭弹出窗 /// /// /// protected void Window1_Close(object sender, EventArgs e) { constructionRiskControls = (from x in Funs.DB.HSSE_ConstructionRiskControl where x.ConstructionRiskId == this.hdConstructionRiskId.Text orderby x.ShowIndex select x).ToList(); Grid1.DataSource = constructionRiskControls; Grid1.DataBind(); } /// /// 关闭弹出窗 /// /// /// protected void Window2_Close(object sender, EventArgs e) { } #endregion #region Grid双击事件 /// /// Grid行双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { btnMenuEdit_Click(null, null); } #endregion #region 编辑 /// /// 编辑按钮 /// /// /// protected void btnMenuEdit_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string rowID = Grid1.SelectedRowID; PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ConstructionRiskControlEdit.aspx?ConstructionRiskId={0}&ControlId={1}", ConstructionRiskId, rowID, "编辑 - "))); } #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 constructionRiskControl = Funs.DB.HSSE_ConstructionRiskControl.FirstOrDefault(x => x.ControlId == rowID); Funs.DB.HSSE_ConstructionRiskControl.DeleteOnSubmit(constructionRiskControl); Funs.DB.SubmitChanges(); } constructionRiskControls = (from x in Funs.DB.HSSE_ConstructionRiskControl where x.ConstructionRiskId == this.ConstructionRiskId orderby x.ShowIndex select x).ToList(); Grid1.DataSource = constructionRiskControls; Grid1.DataBind(); ShowNotify("删除数据成功!(表格数据已重新绑定)"); } } #endregion #region 区域选择框事件 /// /// 区域选择框事件 /// /// /// protected void dpDateA_SelectedIndexChanged(object sender, EventArgs e) { } #endregion protected void btnAdd_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.ConstructionRiskId)) { this.hdConstructionRiskId.Text = SQLHelper.GetNewID(typeof(Model.Hazard_EnvironmentalRiskList)); } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ConstructionRiskControlEdit.aspx?ConstructionRiskId=" + this.hdConstructionRiskId.Text, "添加 - "))); } protected void btnMap_Click(object sender, EventArgs e) { string window = String.Format("LocationSelect.aspx?type=see&ConstructionRiskId=" + this.ConstructionRiskId); PageContext.RegisterStartupScript(Window2.GetSaveStateReference(hdCoordinate.ClientID) + Window2.GetShowReference(window)); //PageContext.RegisterStartupScript(Window2.GetShowReference()); } protected void drpRefLicense_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpRefLicense.SelectedValueArray.Length == 1 && this.drpRefLicense.SelectedValue == BLL.Const._Null) { this.drpRiskLevel.DataSource = BLL.ConstructionRiskListService.RiskLevelList(); } else { this.drpRiskLevel.DataSource = BLL.ConstructionRiskListService.RiskLevelList2(); } this.drpRiskLevel.DataBind(); Funs.FineUIPleaseSelect(this.drpRiskLevel); this.drpRiskLevel.SelectedValue = BLL.Const._Null; } #region 关闭弹出窗口 /// /// 关闭弹出窗口 /// /// /// protected void Window3_Close(object sender, WindowCloseEventArgs e) { if (!string.IsNullOrEmpty(hdConstructionContentId.Text)) { var c = BLL.ControlItemAndCycleService.GetControlItemAndCycleById(hdConstructionContentId.Text); if (c != null) { this.txtConstructionContent.Text = c.ControlItemContent; } } } #endregion } }