| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  | using BLL; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Data; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.Transfer | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class PipingEdit : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         #region 定义项 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 主键 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private string Id | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["Id"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["Id"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 项目主键 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public string ProjectId | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["ProjectId"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["ProjectId"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Id = Request.Params["Id"]; | 
					
						
							|  |  |  |  |                 ProjectId = this.CurrUser.LoginProjectId; | 
					
						
							| 
									
										
										
										
											2024-11-18 15:14:57 +08:00
										 |  |  |  |                 if (!string.IsNullOrEmpty(Id)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |                     var model = Funs.DB.Transfer_Piping.FirstOrDefault(x => x.Id == Id); | 
					
						
							| 
									
										
										
										
											2024-11-18 15:14:57 +08:00
										 |  |  |  |                     if (model != null) | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |                     { | 
					
						
							| 
									
										
										
										
											2024-12-10 14:31:15 +08:00
										 |  |  |  |                         txtSN.Text = model.SN.ToString(); | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |                         txtPIPINGLINENUMBER.Text = model.PIPINGLINENUMBER; | 
					
						
							|  |  |  |  |                         txtSYSTEM.Text = model.SYSTEM; | 
					
						
							|  |  |  |  |                         txtSubsystem.Text = model.Subsystem; | 
					
						
							|  |  |  |  |                         txtTestPackage.Text = model.TestPackage; | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |                         txtDescriptions.Text = model.Descriptions; | 
					
						
							|  |  |  |  |                         //ddlPWD.SelectedValue = model.PWD; | 
					
						
							| 
									
										
										
										
											2024-08-30 17:45:02 +08:00
										 |  |  |  |                         //ddlApunchclosed.SelectedValue = model.Apunchclosed; | 
					
						
							|  |  |  |  |                         //ddlNDTReport.SelectedValue = model.NDTReport; | 
					
						
							|  |  |  |  |                         //ddlTemperaryMeasurement.SelectedValue = model.TemperaryMeasurement; | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |                         //ddlHydrostaticTest.SelectedValue = model.HydrostaticTest; | 
					
						
							|  |  |  |  |                         //ddlReport.SelectedValue = model.Report; | 
					
						
							|  |  |  |  |                         //ddlBlowingflushing.SelectedValue = model.Blowingflushing; | 
					
						
							| 
									
										
										
										
											2024-08-30 17:45:02 +08:00
										 |  |  |  |                         //ddlFWDfinished.SelectedValue = model.FWDfinished; | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |                         //ddlSystemreinstalled.SelectedValue = model.Systemreinstalled; | 
					
						
							|  |  |  |  |                         //txtBlowingReport.Text = model.BlowingReport; | 
					
						
							| 
									
										
										
										
											2024-08-09 10:48:15 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-18 15:14:57 +08:00
										 |  |  |  |                         txtTotalFactor.Text = model.TotalFactor.ToString(); | 
					
						
							|  |  |  |  |                         txtCompleteFactor.Text = model.CompleteFactor.ToString(); | 
					
						
							|  |  |  |  |                         txtCompleteProportion.Text = model.CompleteProportion.ToString(); | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |                         ddlPressureTestCompleted.SelectedValue = model.PressureTestCompleted; | 
					
						
							|  |  |  |  |                         ddlRinseAndBlowClean.SelectedValue = model.RinseAndBlowClean; | 
					
						
							|  |  |  |  |                         ddlReduction.SelectedValue = model.Reduction; | 
					
						
							|  |  |  |  |                         ddlElectricHeatTracing.SelectedValue = model.ElectricHeatTracing; | 
					
						
							|  |  |  |  |                         ddlInsulation.SelectedValue = model.Insulation; | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2024-12-10 14:31:15 +08:00
										 |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     var model = Funs.DB.Transfer_Piping.OrderByDescending(x => x.SN).FirstOrDefault(x => x.ProjectId == CurrUser.LoginProjectId); | 
					
						
							|  |  |  |  |                     if (model == null) | 
					
						
							|  |  |  |  |                         txtSN.Text = "1001"; | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                         txtSN.Text = (model.SN + 1).ToString(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-18 15:14:57 +08:00
										 |  |  |  |         protected void btnSave_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var model = new Model.Transfer_Piping() | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-12-10 14:31:15 +08:00
										 |  |  |  |                 SN = Convert.ToInt32(txtSN.Text), | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |                 ProjectId = ProjectId, | 
					
						
							|  |  |  |  |                 PIPINGLINENUMBER = txtPIPINGLINENUMBER.Text, | 
					
						
							|  |  |  |  |                 SYSTEM = txtSYSTEM.Text, | 
					
						
							|  |  |  |  |                 Subsystem = txtSubsystem.Text, | 
					
						
							|  |  |  |  |                 TestPackage = txtTestPackage.Text, | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |                 //PWD = ddlPWD.SelectedValue, | 
					
						
							| 
									
										
										
										
											2024-08-30 17:45:02 +08:00
										 |  |  |  |                 //Apunchclosed = ddlApunchclosed.SelectedValue, | 
					
						
							|  |  |  |  |                 //NDTReport= ddlNDTReport.SelectedValue, | 
					
						
							|  |  |  |  |                 //TemperaryMeasurement= ddlTemperaryMeasurement.SelectedValue, | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |                 //HydrostaticTest=ddlHydrostaticTest.SelectedValue, | 
					
						
							|  |  |  |  |                 //Report= ddlReport.SelectedValue, | 
					
						
							|  |  |  |  |                 //Blowingflushing= ddlBlowingflushing.SelectedValue, | 
					
						
							| 
									
										
										
										
											2024-08-30 17:45:02 +08:00
										 |  |  |  |                 //FWDfinished= ddlFWDfinished.SelectedValue, | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |                 //Systemreinstalled= ddlSystemreinstalled.SelectedValue, | 
					
						
							|  |  |  |  |                 //BlowingReport= txtBlowingReport.Text, | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-18 15:14:57 +08:00
										 |  |  |  |                 TotalFactor = Convert.ToDecimal(txtTotalFactor.Text.Trim()), | 
					
						
							|  |  |  |  |                 CompleteFactor = Convert.ToDecimal(txtCompleteFactor.Text.Trim()), | 
					
						
							|  |  |  |  |                 CompleteProportion = Convert.ToDecimal(txtCompleteProportion.Text.Trim()), | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |                 PressureTestCompleted = ddlPressureTestCompleted.SelectedValue, | 
					
						
							|  |  |  |  |                 RinseAndBlowClean = ddlRinseAndBlowClean.SelectedValue, | 
					
						
							|  |  |  |  |                 Reduction = ddlReduction.SelectedValue, | 
					
						
							|  |  |  |  |                 ElectricHeatTracing = ddlElectricHeatTracing.SelectedValue, | 
					
						
							|  |  |  |  |                 Insulation = ddlInsulation.SelectedValue, | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 Descriptions = txtDescriptions.Text | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |             }; | 
					
						
							|  |  |  |  |             #region 判断状态 | 
					
						
							|  |  |  |  |             var listObj = new List<string>(); | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |             //listObj.Add(model.PWD); | 
					
						
							| 
									
										
										
										
											2024-08-30 17:45:02 +08:00
										 |  |  |  |             //listObj.Add(model.Apunchclosed); | 
					
						
							|  |  |  |  |             //listObj.Add(model.NDTReport); | 
					
						
							|  |  |  |  |             //listObj.Add(model.TemperaryMeasurement); | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |             //listObj.Add(model.HydrostaticTest); | 
					
						
							|  |  |  |  |             //listObj.Add(model.Report); | 
					
						
							|  |  |  |  |             //listObj.Add(model.Blowingflushing); | 
					
						
							| 
									
										
										
										
											2024-08-30 17:45:02 +08:00
										 |  |  |  |             //listObj.Add(model.FWDfinished); | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |             //listObj.Add(model.Systemreinstalled); | 
					
						
							| 
									
										
										
										
											2024-08-30 17:45:02 +08:00
										 |  |  |  |             //listObj.Add(model.BlowingReport); | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             //listObj.Add(model.TotalFactor); | 
					
						
							|  |  |  |  |             //listObj.Add(model.CompleteFactor); | 
					
						
							|  |  |  |  |             //listObj.Add(model.CompleteProportion); | 
					
						
							|  |  |  |  |             listObj.Add(model.PressureTestCompleted); | 
					
						
							|  |  |  |  |             listObj.Add(model.RinseAndBlowClean); | 
					
						
							|  |  |  |  |             listObj.Add(model.Reduction); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-24 19:25:18 +08:00
										 |  |  |  |             model.FINALStatus = "Not Start"; | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |             //全是NA或Completed 状态是Completed | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |             if (listObj.Where(x => x == "NA" || x == "Completed").ToList().Count == 3) | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |             { | 
					
						
							|  |  |  |  |                 model.FINALStatus = "Completed"; | 
					
						
							| 
									
										
										
										
											2024-11-18 15:14:57 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-02-17 12:15:10 +08:00
										 |  |  |  |             //如果全是NA或Not Start、空 就是 Not Start | 
					
						
							|  |  |  |  |             else if (listObj.Where(x => string.IsNullOrWhiteSpace(x) || x == "NA" || x == "Not Start").ToList().Count == 3) | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |             { | 
					
						
							|  |  |  |  |                 model.FINALStatus = "Not Start"; | 
					
						
							| 
									
										
										
										
											2024-11-18 15:14:57 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-02-17 12:15:10 +08:00
										 |  |  |  |             //如果其中有一项是In progress 或Not Start、空 是 In progress | 
					
						
							|  |  |  |  |             else if (listObj.Where(x => string.IsNullOrWhiteSpace(x) || x == "In progress" || x == "Not Start").ToList().Count >= 1) | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |             { | 
					
						
							|  |  |  |  |                 model.FINALStatus = "In progress"; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-18 15:14:57 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |             #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(Id)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var newModel = Funs.DB.Transfer_Piping.FirstOrDefault(x => x.Id == Id); | 
					
						
							| 
									
										
										
										
											2024-12-10 14:31:15 +08:00
										 |  |  |  |                 newModel.SN = model.SN; | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |                 newModel.PIPINGLINENUMBER = model.PIPINGLINENUMBER; | 
					
						
							|  |  |  |  |                 newModel.SYSTEM = model.SYSTEM; | 
					
						
							| 
									
										
										
										
											2024-12-26 10:07:26 +08:00
										 |  |  |  |                 newModel.Subsystem = model.Subsystem; | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |                 newModel.TestPackage = txtTestPackage.Text; | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |                 //newModel.PWD = ddlPWD.SelectedValue; | 
					
						
							| 
									
										
										
										
											2024-08-30 17:45:02 +08:00
										 |  |  |  |                 //newModel.Apunchclosed = ddlApunchclosed.SelectedValue; | 
					
						
							|  |  |  |  |                 //newModel.NDTReport = ddlNDTReport.SelectedValue; | 
					
						
							|  |  |  |  |                 //newModel.TemperaryMeasurement = ddlTemperaryMeasurement.SelectedValue; | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |                 //newModel.HydrostaticTest = ddlHydrostaticTest.SelectedValue; | 
					
						
							|  |  |  |  |                 //newModel.Report = ddlReport.SelectedValue; | 
					
						
							|  |  |  |  |                 //newModel.Blowingflushing = ddlBlowingflushing.SelectedValue; | 
					
						
							| 
									
										
										
										
											2024-08-30 17:45:02 +08:00
										 |  |  |  |                 //newModel.FWDfinished = ddlFWDfinished.SelectedValue; | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |                 //newModel.Systemreinstalled = ddlSystemreinstalled.SelectedValue; | 
					
						
							|  |  |  |  |                 //newModel.BlowingReport = txtBlowingReport.Text; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-18 15:14:57 +08:00
										 |  |  |  |                 newModel.TotalFactor = Convert.ToDecimal(txtTotalFactor.Text.Trim()); | 
					
						
							|  |  |  |  |                 newModel.CompleteFactor = Convert.ToDecimal(txtCompleteFactor.Text.Trim()); | 
					
						
							|  |  |  |  |                 newModel.CompleteProportion = Convert.ToDecimal(txtCompleteProportion.Text.Trim()); | 
					
						
							| 
									
										
										
										
											2024-10-31 19:11:00 +08:00
										 |  |  |  |                 newModel.PressureTestCompleted = ddlPressureTestCompleted.SelectedValue; | 
					
						
							|  |  |  |  |                 newModel.RinseAndBlowClean = ddlRinseAndBlowClean.SelectedValue; | 
					
						
							|  |  |  |  |                 newModel.Reduction = ddlReduction.SelectedValue; | 
					
						
							|  |  |  |  |                 newModel.ElectricHeatTracing = ddlElectricHeatTracing.SelectedValue; | 
					
						
							|  |  |  |  |                 newModel.Insulation = ddlInsulation.SelectedValue; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |                 newModel.FINALStatus = model.FINALStatus; | 
					
						
							| 
									
										
										
										
											2024-08-09 10:48:15 +08:00
										 |  |  |  |                 newModel.Descriptions = txtDescriptions.Text; | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2024-11-18 15:14:57 +08:00
										 |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 model.Id = Id = Guid.NewGuid().ToString(); | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |                 Funs.DB.Transfer_Piping.InsertOnSubmit(model); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             Funs.DB.SubmitChanges(); | 
					
						
							|  |  |  |  |             ShowNotify("保存成功", MessageBoxIcon.Success); | 
					
						
							|  |  |  |  |             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-18 15:14:57 +08:00
										 |  |  |  |         protected void TextBox_OnTextChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             decimal num1 = 0, num2 = 0; | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(this.txtTotalFactor.Text.Trim())) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 num1 = Convert.ToDecimal(this.txtTotalFactor.Text.Trim()); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(this.txtCompleteFactor.Text.Trim())) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 num2 = Convert.ToDecimal(this.txtCompleteFactor.Text.Trim()); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (num1 > 0 && num2 > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var dCompleteProportion = Math.Round(((num2 / num1) * 100), 2); | 
					
						
							|  |  |  |  |                 this.txtCompleteProportion.Text = dCompleteProportion.ToString(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | } |