using BLL; using System; using System.Linq; namespace FineUIPro.Web.HSSE.HiddenInspection { public partial class HiddenRectificationAdd : PageBase { #region 定义项 /// /// 主键 /// private string HazardRegisterId { get { return (string)ViewState["HazardRegisterId"]; } set { ViewState["HazardRegisterId"] = value; } } private string ControlId { get { return (string)ViewState["ControlId"]; } set { ViewState["ControlId"] = value; } } /// /// 图片路径 /// public string ImageUrl { get { return (string)ViewState["ImageUrl"]; } set { ViewState["ImageUrl"] = value; } } /// /// 整改后附件路径 /// public string RectificationImageUrl { get { return (string)ViewState["RectificationImageUrl"]; } set { ViewState["RectificationImageUrl"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpUnit, this.CurrUser.LoginProjectId, Const.ProjectUnitType_2, true); UnitWorkService.InitUnitWorkDownList(this.drpWorkArea, this.CurrUser.LoginProjectId, true); SitePerson_PersonService.InitSitePersonByUnitTypeRoletIdsDropDownList(this.drpResponsibleMan, this.CurrUser.LoginProjectId, Const.ProjectUnitType_2, null, true); Person_PersonsService.InitUserProjectIdUnitIdRoleIdDropDownList(this.drpCCManIds, this.CurrUser.LoginProjectId, null, null, true); HSSE_Hazard_HazardRegisterTypesService.InitAccidentTypeDropDownList(this.drpRegisterTypes, "1", true); HSSE_Hazard_HazardRegisterTypesService.InitAccidentTypeDropDownList(this.drpRegisterTypes2, "2", true); HSSE_Hazard_HazardRegisterTypesService.InitAccidentTypeDropDownList(this.drpRegisterTypes3, "3", true); HSSE_Hazard_HazardRegisterTypesService.InitAccidentTypeDropDownList(this.drpRegisterTypes4, "4", true); Funs.FineUIPleaseSelect(this.drpHazardValue); this.HazardRegisterId = Request.Params["HazardRegisterId"]; //新增初始化 this.txtCheckManName.Text = this.CurrUser.PersonName; this.hdCheckManId.Text = this.CurrUser.PersonId; this.txtCheckTime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now); this.txtRectificationPeriod.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now.AddDays(1)); if (!string.IsNullOrEmpty(this.HazardRegisterId)) { var registration = Funs.DB.View_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == HazardRegisterId); if (registration != null) { if (!string.IsNullOrEmpty(registration.ResponsibleUnit)) { this.drpUnit.SelectedValue = registration.ResponsibleUnit; } this.drpUnit_OnSelectedIndexChanged(null, null); if (!string.IsNullOrEmpty(registration.Place)) { this.drpWorkArea.SelectedValue = registration.Place; } if (!string.IsNullOrEmpty(registration.RegisterTypesId)) { this.drpRegisterTypes.SelectedValue = registration.RegisterTypesId; } if (!string.IsNullOrEmpty(registration.RegisterTypes2Id)) { this.drpRegisterTypes2.SelectedValue = registration.RegisterTypes2Id; } if (!string.IsNullOrEmpty(registration.RegisterTypes3Id)) { this.drpRegisterTypes3.SelectedValue = registration.RegisterTypes3Id; } if (!string.IsNullOrEmpty(registration.RegisterTypes4Id)) { this.drpRegisterTypes4.SelectedValue = registration.RegisterTypes4Id; } if (!string.IsNullOrEmpty(registration.HazardValue)) { this.drpHazardValue.SelectedValue = registration.HazardValue; } if (!string.IsNullOrEmpty(registration.ResponsibleMan)) { this.drpResponsibleMan.SelectedValue = registration.ResponsibleMan; } if (registration.RectificationPeriod != null) { this.txtRectificationPeriod.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", registration.RectificationPeriod); } this.txtRegisterDef.Text = registration.RegisterDef; this.txtRequirements.Text = registration.Requirements; this.txtCheckManName.Text = registration.CheckManName; this.hdCheckManId.Text = registration.CheckManId; if (registration.CheckTime != null) { this.txtCheckTime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", registration.CheckTime); } if (!string.IsNullOrEmpty(registration.CCManIds)) { this.drpCCManIds.SelectedValueArray = registration.CCManIds.Split(','); } if (!string.IsNullOrEmpty(registration.HandleIdea)) { this.txtHandleIdea.Hidden = false; this.txtHandleIdea.Text = registration.HandleIdea; } this.hdWorkPackageId.Text = registration.WorkPackageId; this.txtWorkPackageId.Text = registration.WorkPackageName; } } this.ControlId = Request.Params["ControlId"]; if (!string.IsNullOrEmpty(ControlId)) { var control = Funs.DB.HSSE_ConstructionRiskCheck.FirstOrDefault(x => x.ConstructionRiskCheckId == ControlId); if (control != null) { var risk = Funs.DB.HSSE_ConstructionRisk.FirstOrDefault(x => x.ConstructionRiskId == control.ConstructionRiskId); txtRegisterDef.Text = risk.LicenseDes; drpUnit.SelectedValue = risk.UnitId; drpWorkArea.SelectedValue = risk.WorkAreaId; } } } } #endregion /// /// 单位选择事件 /// /// /// protected void drpUnit_OnSelectedIndexChanged(object sender, EventArgs e) { this.drpWorkArea.Items.Clear(); this.drpResponsibleMan.Items.Clear(); if (this.drpUnit.SelectedValue != BLL.Const._Null) { UnitWorkService.InitUnitWorkDownList(this.drpWorkArea, this.CurrUser.LoginProjectId, true); Person_PersonsService.InitUserProjectIdUnitIdRoleIdDropDownList(this.drpResponsibleMan, this.CurrUser.LoginProjectId, this.drpUnit.SelectedValue, null, true); this.drpWorkArea.SelectedValue = BLL.Const._Null; this.drpResponsibleMan.SelectedValue = BLL.Const._Null; } } #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.HSSE_HiddenRectificationListMenuId, BLL.Const.BtnAdd)) { if (this.drpUnit.SelectedValue == BLL.Const._Null) { ShowNotify("请选择责任单位!", MessageBoxIcon.Warning); return; } if (this.drpWorkArea.SelectedValue == BLL.Const._Null) { ShowNotify("请选择单位工程!", MessageBoxIcon.Warning); return; } if (this.drpWorkArea.SelectedValue == BLL.Const._Null) { ShowNotify("请选择责任人!", MessageBoxIcon.Warning); return; } if (this.drpRegisterTypes.SelectedValue == BLL.Const._Null) { ShowNotify("请选择问题类型!", MessageBoxIcon.Warning); return; } SaveData(true); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } /// /// 保存数据 /// /// private void SaveData(bool isClosed) { Model.HSSE_Hazard_HazardRegister register = new Model.HSSE_Hazard_HazardRegister { ProjectId = this.CurrUser.LoginProjectId, ProblemTypes = "1", //安全隐患问题 IsEffective = "1", RectificationPeriod = Funs.GetNewDateTime(this.txtRectificationPeriod.Text.Trim()), CheckManId = this.hdCheckManId.Text, States = "1", //待整改 RegisterDef = this.txtRegisterDef.Text.Trim(), Requirements = this.txtRequirements.Text.Trim(), WorkPackageId = this.hdWorkPackageId.Text, WorkPackageName = this.txtWorkPackageId.Text, }; if (this.drpRegisterTypes.SelectedValue != BLL.Const._Null) { register.RegisterTypesId = this.drpRegisterTypes.SelectedValue; } if (this.drpRegisterTypes2.SelectedValue != BLL.Const._Null) { register.RegisterTypes2Id = this.drpRegisterTypes2.SelectedValue; } if (this.drpRegisterTypes3.SelectedValue != BLL.Const._Null) { register.RegisterTypes3Id = this.drpRegisterTypes3.SelectedValue; } if (this.drpRegisterTypes4.SelectedValue != BLL.Const._Null) { register.RegisterTypes4Id = this.drpRegisterTypes4.SelectedValue; } if (this.drpHazardValue.SelectedValue != BLL.Const._Null) { register.HazardValue = this.drpHazardValue.SelectedValue; } if (this.drpUnit.SelectedValue != BLL.Const._Null) { register.ResponsibleUnit = this.drpUnit.SelectedValue; } if (this.drpWorkArea.SelectedValue != BLL.Const._Null) { register.Place = this.drpWorkArea.SelectedValue; } if (this.drpResponsibleMan.SelectedValue != BLL.Const._Null) { register.ResponsibleMan = this.drpResponsibleMan.SelectedValue; } if (this.drpCCManIds.SelectedValue != BLL.Const._Null) { register.CCManIds = Funs.GetStringByArray(this.drpCCManIds.SelectedValueArray); } if (!string.IsNullOrEmpty(HazardRegisterId)) { register.HazardRegisterId = HazardRegisterId; BLL.HSSE_Hazard_HazardRegisterService.UpdateHazardRegister(register); BLL.LogService.AddSys_Log(this.CurrUser, register.HazardCode, register.HazardRegisterId, BLL.Const.HiddenRectificationMenuId, BLL.Const.BtnModify); } else { register.HazardRegisterId = SQLHelper.GetNewID(); HazardRegisterId = register.HazardRegisterId; register.CheckTime = DateTime.Now; register.ControlId = Request.Params["ControlId"]; BLL.HSSE_Hazard_HazardRegisterService.AddHazardRegister(register); BLL.LogService.AddSys_Log(this.CurrUser, register.HazardCode, register.HazardRegisterId, BLL.Const.HiddenRectificationMenuId, BLL.Const.BtnAdd); } if (isClosed) { PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } #endregion #region 附件上传 /// /// 上传附件资源 /// /// /// protected void btnAttachUrl_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.HazardRegisterId)) { SaveData(false); } string edit = "0"; if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.HSSE_HiddenRectificationListMenuId, BLL.Const.BtnAdd)) { edit = "1"; Model.HSSE_Hazard_HazardRegister register = BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByHazardRegisterId(this.HazardRegisterId); DateTime date = Convert.ToDateTime(register.CheckTime); string dateStr = date.Year.ToString() + date.Month.ToString(); PageContext.RegisterStartupScript(WindowAT.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/HazardRegister/" + dateStr + "&menuId={1}&edit={2}", this.HazardRegisterId, Const.HSSE_HiddenRectificationListMenuId, edit))); } } #endregion /// /// /// /// /// protected void drpCCManIds_SelectedIndexChanged(object sender, EventArgs e) { this.drpCCManIds.SelectedValueArray = Funs.RemoveDropDownListNull(this.drpCCManIds.SelectedValueArray); } /// /// 分部分项选择 /// /// /// protected void btSearch_Click(object sender, EventArgs e) { PageContext.RegisterStartupScript(Window1.GetSaveStateReference(hdWorkPackageId.ClientID) + Window1.GetShowReference(String.Format("~/DigData/ShowProjectWBS.aspx?levle={0}", 3, "选择WBS - "))); } /// /// 分部分项返回值 /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { var getReturnValues = Funs.GetStrListByStr(this.hdWorkPackageId.Text, '&'); if (getReturnValues.Count() > 1) { this.hdWorkPackageId.Text = getReturnValues[0].ToString(); this.txtWorkPackageId.Text = getReturnValues[1].ToString(); } } } }