| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | using BLL; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Web; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.HSSE.Solution | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class LargerHazardEdit : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         #region 定义变量 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 主键 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public string HazardId | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["HazardId"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["HazardId"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 项目主键 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public string ProjectId | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["ProjectId"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["ProjectId"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 加载页面 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 加载页面 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.ProjectId = this.CurrUser.LoginProjectId; | 
					
						
							|  |  |  |  |                 this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); | 
					
						
							|  |  |  |  |                 //类型              | 
					
						
							|  |  |  |  |                 BLL.ConstValue.InitConstValueDropDownList(this.drpHazardType, ConstValue.Group_LargerHazardType, true); | 
					
						
							|  |  |  |  |                 //是否需要专家论证               | 
					
						
							|  |  |  |  |                 BLL.ConstValue.InitConstValueRadioButtonList(this.rblIsArgument, ConstValue.Group_0001, "False"); | 
					
						
							| 
									
										
										
										
											2023-06-07 18:55:33 +08:00
										 |  |  |  |                 //是否超危大工程               | 
					
						
							|  |  |  |  |                 BLL.ConstValue.InitConstValueRadioButtonList(this.rblIsSuperLargerHazard, ConstValue.Group_0001, "False"); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                 this.HazardId = Request.Params["HazardId"]; | 
					
						
							|  |  |  |  |                 var largerHazard = BLL.LargerHazardService.GetLargerHazardByHazardId(this.HazardId); | 
					
						
							|  |  |  |  |                 if (largerHazard != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.ProjectId = largerHazard.ProjectId; | 
					
						
							|  |  |  |  |                     this.txtLargerHazardCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(this.HazardId); | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(largerHazard.HazardType)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.drpHazardType.SelectedValue = largerHazard.HazardType; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     this.txtAddress.Text = largerHazard.Address; | 
					
						
							|  |  |  |  |                     if (largerHazard.ExpectedTime != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.txtExpectedTime.Text = string.Format("{0:yyyy-MM-dd}", largerHazard.ExpectedTime); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     if (largerHazard.RecordTime != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.txtRecordTime.Text = string.Format("{0:yyyy-MM-dd}", largerHazard.RecordTime); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     if (largerHazard.IsArgument == true) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.rblIsArgument.SelectedValue = "True"; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.rblIsArgument.SelectedValue = "False"; | 
					
						
							|  |  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2023-06-07 18:55:33 +08:00
										 |  |  |  |                     if (largerHazard.IsSuperLargerHazard == true) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.rblIsSuperLargerHazard.SelectedValue = "True"; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.rblIsSuperLargerHazard.SelectedValue = "False"; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     if (largerHazard.TrainPersonNum != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.txtTrainPersonNum.Text = largerHazard.TrainPersonNum.ToString(); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     this.drpStates.SelectedValue = largerHazard.States; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                     this.txtRemark.Text = HttpUtility.HtmlDecode(largerHazard.Remark); | 
					
						
							|  |  |  |  |                     this.txtDescriptions.Text = largerHazard.Descriptions; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     ////自动生成编码 | 
					
						
							|  |  |  |  |                     this.txtLargerHazardCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectLargerHazardListMenuId, this.ProjectId, this.CurrUser.UnitId); | 
					
						
							|  |  |  |  |                     this.txtExpectedTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); | 
					
						
							|  |  |  |  |                     this.txtRemark.Text = HttpUtility.HtmlDecode("描述"); | 
					
						
							|  |  |  |  |                     this.txtRecordTime.Text = string.Format("{0:yyyy-MM-dd}",DateTime.Now); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 保存按钮 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 保存按钮 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnSave_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (this.drpHazardType.SelectedValue == BLL.Const._Null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ShowNotify("请选择类型!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             this.SaveData(BLL.Const.BtnSave); | 
					
						
							|  |  |  |  |             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 保存数据 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="type"></param> | 
					
						
							|  |  |  |  |         private void SaveData(string type) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.Solution_LargerHazard largerHazard = new Model.Solution_LargerHazard | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 HazardCode = this.txtLargerHazardCode.Text.Trim(), | 
					
						
							|  |  |  |  |                 HazardType = this.drpHazardType.SelectedValue, | 
					
						
							|  |  |  |  |                 Address = this.txtAddress.Text.Trim(), | 
					
						
							|  |  |  |  |                 ExpectedTime = Funs.GetNewDateTime(this.txtExpectedTime.Text.Trim()), | 
					
						
							|  |  |  |  |                 IsArgument = Convert.ToBoolean(this.rblIsArgument.SelectedValue), | 
					
						
							| 
									
										
										
										
											2023-06-07 18:55:33 +08:00
										 |  |  |  |                 IsSuperLargerHazard = Convert.ToBoolean(this.rblIsSuperLargerHazard.SelectedValue), | 
					
						
							|  |  |  |  |                 TrainPersonNum=Funs.GetNewIntOrZero(this.txtTrainPersonNum.Text.Trim()), | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                 Remark = HttpUtility.HtmlEncode(this.txtRemark.Text.Trim()), | 
					
						
							|  |  |  |  |                 Descriptions = this.txtDescriptions.Text.Trim(), | 
					
						
							|  |  |  |  |                 RecordTime = Funs.GetNewDateTime(this.txtRecordTime.Text.Trim()), | 
					
						
							|  |  |  |  |                 ProjectId = this.ProjectId, | 
					
						
							| 
									
										
										
										
											2023-06-07 18:55:33 +08:00
										 |  |  |  |                 States = this.drpStates.SelectedValue, | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             }; | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(this.HazardId)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 largerHazard.HazardId = this.HazardId; | 
					
						
							|  |  |  |  |                 BLL.LargerHazardService.UpdateLargerHazard(largerHazard); | 
					
						
							|  |  |  |  |                 BLL.LogService.AddSys_Log(this.CurrUser, largerHazard.HazardCode, largerHazard.HazardId,BLL.Const.ProjectLargerHazardListMenuId,BLL.Const.BtnModify); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 largerHazard.HazardId = SQLHelper.GetNewID(typeof(Model.Solution_LargerHazard)); | 
					
						
							|  |  |  |  |                 largerHazard.RecardMan = this.CurrUser.UserId; | 
					
						
							|  |  |  |  |                 this.HazardId = largerHazard.HazardId; | 
					
						
							|  |  |  |  |                 BLL.LargerHazardService.AddLargerHazard(largerHazard); | 
					
						
							|  |  |  |  |                 BLL.LogService.AddSys_Log(this.CurrUser, largerHazard.HazardCode, largerHazard.HazardId, BLL.Const.ProjectLargerHazardListMenuId, BLL.Const.BtnAdd);               | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-06-07 18:55:33 +08:00
										 |  |  |  |             Project_HSSEData_HSSEService.StatisticalData(this.CurrUser.LoginProjectId, Project_HSSEData_HSSEService.HSSEDateType.ProjectInformation); | 
					
						
							|  |  |  |  |             Project_HSSEData_HSSEService.StatisticalData(this.CurrUser.LoginProjectId, Project_HSSEData_HSSEService.HSSEDateType.DangerousProject); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 附件上传 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 上传附件 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnAttachUrl_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (string.IsNullOrEmpty(this.HazardId)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 SaveNew(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/LargerHazard&menuId={1}", this.HazardId, BLL.Const.ProjectLargerHazardListMenuId))); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void SaveNew() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.Solution_LargerHazard largerHazard = new Model.Solution_LargerHazard | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 HazardCode = this.txtLargerHazardCode.Text.Trim(), | 
					
						
							|  |  |  |  |                 HazardType = this.drpHazardType.SelectedValue, | 
					
						
							|  |  |  |  |                 Address = this.txtAddress.Text.Trim(), | 
					
						
							|  |  |  |  |                 ExpectedTime = Funs.GetNewDateTime(this.txtExpectedTime.Text.Trim()), | 
					
						
							|  |  |  |  |                 IsArgument = Convert.ToBoolean(this.rblIsArgument.SelectedValue), | 
					
						
							|  |  |  |  |                 Remark = HttpUtility.HtmlEncode(this.txtRemark.Text.Trim()), | 
					
						
							|  |  |  |  |                 ProjectId = this.ProjectId, | 
					
						
							| 
									
										
										
										
											2023-06-07 18:55:33 +08:00
										 |  |  |  |                 States = this.drpStates.SelectedValue, | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                 HazardId = SQLHelper.GetNewID(typeof(Model.Solution_LargerHazard)), | 
					
						
							|  |  |  |  |                 RecardMan = this.CurrUser.UserId, | 
					
						
							|  |  |  |  |                 RecordTime = Funs.GetNewDateTime(this.txtRecordTime.Text.Trim()) | 
					
						
							|  |  |  |  |             }; | 
					
						
							|  |  |  |  |             this.HazardId = largerHazard.HazardId; | 
					
						
							|  |  |  |  |             BLL.LargerHazardService.AddLargerHazard(largerHazard); | 
					
						
							|  |  |  |  |             BLL.LogService.AddSys_Log(this.CurrUser, largerHazard.HazardCode, largerHazard.HazardId,BLL.Const.ProjectLargerHazardListMenuId,BLL.Const.BtnAdd); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |