| 
									
										
										
										
											2024-01-25 15:21:19 +08:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Web; | 
					
						
							|  |  |  |  | using System.Web.UI; | 
					
						
							|  |  |  |  | using System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | using BLL; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.TestRun.DriverPrepare | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class SchemePlanItemAdd : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 string SchemePlanItemId = Request.Params["SchemePlanItemId"]; | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(SchemePlanItemId)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     Model.DriverPrepare_SchemePlanItem item = DriverPrepareSchemePlanItemService.GetSchemePlanItemById(SchemePlanItemId); | 
					
						
							|  |  |  |  |                     if (item != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.txtSolutionName.Text = item.SolutionName; | 
					
						
							| 
									
										
										
										
											2024-01-25 16:16:18 +08:00
										 |  |  |  |                         this.txtSolutionType.Text = item.SolutionType; | 
					
						
							| 
									
										
										
										
											2024-01-25 15:21:19 +08:00
										 |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2024-01-25 16:16:18 +08:00
										 |  |  |  |                 var solutionType = (from x in Funs.DB.DriverPrepare_SchemePlan | 
					
						
							|  |  |  |  |                                     join y in Funs.DB.DriverPrepare_SchemePlanItem on x.SchemePlanId equals y.SchemePlanId | 
					
						
							|  |  |  |  |                                     where y.SolutionType != null && x.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                                     select y).FirstOrDefault(); | 
					
						
							|  |  |  |  |                 if (solutionType != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.txtSolutionType.Hidden = false; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.txtSolutionType.Hidden = true; | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2024-01-25 15:21:19 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected void btnSave_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string SchemePlanItemId = Request.Params["SchemePlanItemId"]; | 
					
						
							|  |  |  |  |             if (!BLL.DriverPrepareSchemePlanItemService.IsExistSolutionName(this.CurrUser.LoginProjectId, this.txtSolutionName.Text.Trim(), SchemePlanItemId)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Model.DriverPrepare_SchemePlanItem newItem = new Model.DriverPrepare_SchemePlanItem(); | 
					
						
							|  |  |  |  |                 newItem.SolutionName = this.txtSolutionName.Text.Trim(); | 
					
						
							|  |  |  |  |                 Model.DriverPrepare_SchemePlan plan = BLL.DriverPrepareSchemePlanService.GetDriverPlanByProjectId(this.CurrUser.LoginProjectId); | 
					
						
							|  |  |  |  |                 int sortIndex = 200; | 
					
						
							|  |  |  |  |                 if (plan != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     var items = BLL.DriverPrepareSchemePlanItemService.GetSchemePlanItemByschemePlanId(plan.SchemePlanId); | 
					
						
							|  |  |  |  |                     sortIndex += items.Count; | 
					
						
							|  |  |  |  |                     newItem.SchemePlanId = plan.SchemePlanId; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     Model.DriverPrepare_SchemePlan newData = new Model.DriverPrepare_SchemePlan(); | 
					
						
							|  |  |  |  |                     newData.SchemePlanCode = "001"; | 
					
						
							|  |  |  |  |                     newData.SchemePlanName = "开车方案编制计划"; | 
					
						
							|  |  |  |  |                     newData.CompileMan = this.CurrUser.UserId; | 
					
						
							|  |  |  |  |                     newData.CompileDate = DateTime.Now; | 
					
						
							|  |  |  |  |                     newData.ProjectId = this.CurrUser.LoginProjectId; | 
					
						
							|  |  |  |  |                     newData.SchemePlanId = SQLHelper.GetNewID(typeof(Model.DriverPrepare_SchemePlan)); | 
					
						
							|  |  |  |  |                     BLL.DriverPrepareSchemePlanService.AddDriverPrepareDriverPlan(newData); | 
					
						
							|  |  |  |  |                     newItem.SchemePlanId = newData.SchemePlanId; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 newItem.SortIndex = sortIndex; | 
					
						
							| 
									
										
										
										
											2024-01-25 16:16:18 +08:00
										 |  |  |  |                 var solutionType = (from x in Funs.DB.DriverPrepare_SchemePlan | 
					
						
							|  |  |  |  |                                     join y in Funs.DB.DriverPrepare_SchemePlanItem on x.SchemePlanId equals y.SchemePlanId | 
					
						
							|  |  |  |  |                                     where y.SolutionType != null && x.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                                     select y).FirstOrDefault(); | 
					
						
							|  |  |  |  |                 if (solutionType != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     newItem.SolutionType = this.txtSolutionType.Text.Trim(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2024-01-25 15:21:19 +08:00
										 |  |  |  |                 if (string.IsNullOrEmpty(SchemePlanItemId)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     newItem.SchemePlanItemId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                     BLL.DriverPrepareSchemePlanItemService.AddSchemePlanItem(newItem); | 
					
						
							|  |  |  |  |                     BLL.LogService.AddSys_Log(this.CurrUser, newItem.SolutionName, newItem.SolutionName, BLL.Const.ControlItemInitSetMenuId, "增加开车方案!"); | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2024-01-25 16:16:18 +08:00
										 |  |  |  |                 else | 
					
						
							| 
									
										
										
										
											2024-01-25 15:21:19 +08:00
										 |  |  |  |                 { | 
					
						
							|  |  |  |  |                     newItem.SchemePlanItemId = SchemePlanItemId; | 
					
						
							|  |  |  |  |                     BLL.DriverPrepareSchemePlanItemService.UpdateSchemePlanItem(newItem); | 
					
						
							|  |  |  |  |                     BLL.LogService.AddSys_Log(this.CurrUser, newItem.SolutionName, newItem.SolutionName, BLL.Const.ControlItemInitSetMenuId, "修改开车方案!"); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ShowNotify("此方案已存在!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |