| 
									
										
										
										
											2025-02-12 09:27:47 +08:00
										 |  |  |  | namespace FineUIPro.Web.common.ProjectSet | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     using System; | 
					
						
							|  |  |  |  |     using BLL; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public partial class WorkAreaEdit : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         #region 定义项 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 项目主键 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private string ProjectId | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["ProjectId"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["ProjectId"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 施工区域主键 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public string WorkAreaId | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["WorkAreaId"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["WorkAreaId"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 加载页面 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 加载页面 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.WorkAreaId = Request.Params["workAreaId"]; | 
					
						
							|  |  |  |  |                 this.ProjectId = this.CurrUser.LoginProjectId; | 
					
						
							|  |  |  |  |                 var workArea = BLL.WorkAreaService.getWorkAreaByWorkAreaId(this.WorkAreaId); | 
					
						
							|  |  |  |  |                 if (workArea != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.ProjectId = workArea.ProjectId; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 ///施工单位 | 
					
						
							|  |  |  |  |                 UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpUnit, this.ProjectId, Const.ProjectUnitType_2, true); | 
					
						
							|  |  |  |  |                 ///装置 | 
					
						
							|  |  |  |  |                 this.drpInstallation.DataTextField = "Text"; | 
					
						
							|  |  |  |  |                 this.drpInstallation.DataValueField = "Value"; | 
					
						
							|  |  |  |  |                 this.drpInstallation.DataSource = BLL.Project_InstallationService.GetInstallationList(this.ProjectId); | 
					
						
							|  |  |  |  |                 this.drpInstallation.DataBind(); | 
					
						
							|  |  |  |  |                 Funs.FineUIPleaseSelect(this.drpInstallation); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 ///监理单位 | 
					
						
							|  |  |  |  |                 UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpSupervisorUnit, this.ProjectId, Const.ProjectUnitType_3, true); | 
					
						
							|  |  |  |  |                 ////初始化页面信息 | 
					
						
							|  |  |  |  |                 this.PersonLoad(workArea); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 初始化页面信息 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 初始化页面信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         protected void PersonLoad(Model.ProjectData_WorkArea workArea) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (workArea != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(workArea.UnitId)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.drpUnit.SelectedValue = workArea.UnitId; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 this.txtWorkAreaCode.Text = workArea.WorkAreaCode; | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(workArea.InstallationId)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.drpInstallation.SelectedValue = workArea.InstallationId; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 this.txtRemark.Text = workArea.Remark; | 
					
						
							|  |  |  |  |                 this.txtWorkAreaName.Text = workArea.WorkAreaName; | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(workArea.SupervisorUnitId)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.drpSupervisorUnit.SelectedValue = workArea.SupervisorUnitId; | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2025-09-08 11:30:40 +08:00
										 |  |  |  |                 this.txtCompletionDate.Text = workArea.CompletionDate.HasValue ? string.Format("{0:yyyy-MM-dd}", workArea.CompletionDate) : ""; | 
					
						
							| 
									
										
										
										
											2025-02-12 09:27:47 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 保存按钮 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 保存按钮 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnSave_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (this.drpUnit.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.txtWorkAreaCode.Text.Trim()) || string.IsNullOrEmpty(this.txtWorkAreaName.Text.Trim()) || this.drpInstallation.SelectedValue == BLL.Const._Null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Alert.ShowInTop("区域编号、区域名称、单位、装置不能为空!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (BLL.WorkAreaService.IsExistWorkAreaCode(this.ProjectId, this.txtWorkAreaCode.Text.Trim(), this.WorkAreaId, this.drpInstallation.SelectedValue)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Alert.ShowInTop("该项目装置下此区域编号已存在!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             Model.ProjectData_WorkArea workArea = new Model.ProjectData_WorkArea(); | 
					
						
							|  |  |  |  |             workArea.ProjectId = this.ProjectId; | 
					
						
							|  |  |  |  |             workArea.WorkAreaCode = this.txtWorkAreaCode.Text.Trim(); | 
					
						
							|  |  |  |  |             workArea.Remark = this.txtRemark.Text; | 
					
						
							|  |  |  |  |             workArea.WorkAreaName = this.txtWorkAreaName.Text.Trim(); | 
					
						
							|  |  |  |  |             if (this.drpUnit.SelectedValue != BLL.Const._Null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 workArea.UnitId = this.drpUnit.SelectedValue; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (this.drpInstallation.SelectedValue != BLL.Const._Null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 workArea.InstallationId = this.drpInstallation.SelectedValue; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (this.drpSupervisorUnit.SelectedValue != BLL.Const._Null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 workArea.SupervisorUnitId = this.drpSupervisorUnit.SelectedValue; | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-09-08 11:30:40 +08:00
										 |  |  |  |             workArea.CompletionDate = Funs.GetNewDateTime(this.txtCompletionDate.Text); | 
					
						
							| 
									
										
										
										
											2025-02-12 09:27:47 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (string.IsNullOrEmpty(this.WorkAreaId)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 BLL.WorkAreaService.AddWorkArea(workArea); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 workArea.WorkAreaId = this.WorkAreaId; | 
					
						
							|  |  |  |  |                 BLL.WorkAreaService.UpdateWorkArea(workArea); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             ShowNotify("保存成功!", MessageBoxIcon.Success); | 
					
						
							|  |  |  |  |             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |