| 
									
										
										
										
											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 StaticEquipmentEdit : 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; | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(Id)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     var model = Funs.DB.Transfer_StaticEquipment.FirstOrDefault(x => x.Id == Id); | 
					
						
							|  |  |  |  |                     if (model != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							| 
									
										
										
										
											2024-12-14 10:27:27 +08:00
										 |  |  |  |                         txtSN.Text = model.SN.ToString(); | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |                         txtStaticEquipment.Text = model.StaticEquipment; | 
					
						
							|  |  |  |  |                         txtSYSTEM.Text = model.SYSTEM; | 
					
						
							|  |  |  |  |                         txtSubsystem.Text = model.Subsystem; | 
					
						
							|  |  |  |  |                         txtTestPackage.Text = model.TestPackage; | 
					
						
							|  |  |  |  |                         ddlInternalinspection.SelectedValue = model.Internalinspection; | 
					
						
							|  |  |  |  |                         ddlInternalsPacking.SelectedValue = model.InternalsPacking; | 
					
						
							|  |  |  |  |                         ddlBOXupRecord.SelectedValue = model.BOXupRecord; | 
					
						
							| 
									
										
										
										
											2024-08-09 10:48:15 +08:00
										 |  |  |  |                         txtDescriptions.Text = model.Descriptions; | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2024-12-14 10:27:27 +08:00
										 |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     var model = Funs.DB.Transfer_StaticEquipment.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
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected void btnSave_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var model = new Model.Transfer_StaticEquipment | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-12-14 10:27:27 +08:00
										 |  |  |  |                 SN = Convert.ToInt32(txtSN.Text), | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |                 ProjectId = ProjectId, | 
					
						
							|  |  |  |  |                 StaticEquipment = txtStaticEquipment.Text, | 
					
						
							|  |  |  |  |                 SYSTEM = txtSYSTEM.Text, | 
					
						
							|  |  |  |  |                 Subsystem = txtSubsystem.Text, | 
					
						
							|  |  |  |  |                 TestPackage = txtTestPackage.Text, | 
					
						
							|  |  |  |  |                 Internalinspection = ddlInternalinspection.SelectedValue, | 
					
						
							|  |  |  |  |                 InternalsPacking = ddlInternalsPacking.SelectedValue, | 
					
						
							| 
									
										
										
										
											2024-08-09 10:48:15 +08:00
										 |  |  |  |                 BOXupRecord = ddlBOXupRecord.SelectedValue, | 
					
						
							|  |  |  |  |                 Descriptions= txtDescriptions.Text | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |             }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             #region 判断状态 | 
					
						
							|  |  |  |  |             var listObj = new List<string>(); | 
					
						
							|  |  |  |  |             listObj.Add(model.Internalinspection); | 
					
						
							|  |  |  |  |             listObj.Add(model.InternalsPacking); | 
					
						
							|  |  |  |  |             listObj.Add(model.BOXupRecord); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-24 19:25:18 +08:00
										 |  |  |  |             model.MechanicalFINALStatus = "Not Start"; | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |             //全是NA或Completed 状态是Completed | 
					
						
							|  |  |  |  |             if (listObj.Where(x => x == "NA" || x == "Completed").ToList().Count == 3) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 model.MechanicalFINALStatus = "Completed"; | 
					
						
							| 
									
										
										
										
											2024-11-20 11:29:46 +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.MechanicalFINALStatus = "Not Start"; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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.MechanicalFINALStatus = "In progress"; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             #endregion | 
					
						
							| 
									
										
										
										
											2024-12-14 10:27:27 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |             if (!string.IsNullOrEmpty(Id)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var newModel = Funs.DB.Transfer_StaticEquipment.FirstOrDefault(x => x.Id == Id); | 
					
						
							|  |  |  |  |                 if (newModel != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     newModel.StaticEquipment = txtStaticEquipment.Text; | 
					
						
							| 
									
										
										
										
											2024-12-14 10:27:27 +08:00
										 |  |  |  |                     newModel.SN = model.SN; | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |                     newModel.SYSTEM = txtSYSTEM.Text; | 
					
						
							|  |  |  |  |                     newModel.Subsystem = txtSubsystem.Text; | 
					
						
							|  |  |  |  |                     newModel.TestPackage = txtTestPackage.Text; | 
					
						
							|  |  |  |  |                     newModel.Internalinspection = ddlInternalinspection.SelectedValue; | 
					
						
							|  |  |  |  |                     newModel.InternalsPacking = ddlInternalsPacking.SelectedValue; | 
					
						
							|  |  |  |  |                     newModel.BOXupRecord = ddlBOXupRecord.SelectedValue; | 
					
						
							|  |  |  |  |                     newModel.MechanicalFINALStatus = model.MechanicalFINALStatus; | 
					
						
							| 
									
										
										
										
											2024-08-09 10:48:15 +08:00
										 |  |  |  |                     newModel.Descriptions = txtDescriptions.Text; | 
					
						
							| 
									
										
										
										
											2024-07-31 17:38:02 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 model.Id = Id = Guid.NewGuid().ToString(); | 
					
						
							|  |  |  |  |                 Funs.DB.Transfer_StaticEquipment.InsertOnSubmit(model); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             Funs.DB.SubmitChanges(); | 
					
						
							|  |  |  |  |             ShowNotify("保存成功", MessageBoxIcon.Success); | 
					
						
							|  |  |  |  |             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |