/// <summary> /// 更新商业数据历史 /// </summary> /// <param name="NewChangePlan"></param> private void UpdateAircraftBusiness(ChangePlan NewChangePlan) { if (NewChangePlan.AircraftBusiness != null) { DecodeAircraftBusiness IDO = new DecodeAircraftBusiness(); IDO.SetDbContext(this._FE); IDO.Decode(NewChangePlan.AircraftBusiness); } }
/// <summary> /// 创建变更计划明细 /// 同一架计划飞机在一份计划中的明细项不得超过两条,且两条不得为同种操作类型(含运营计划与变更计划) /// </summary> /// <param name="plan"></param> /// <param name="planAircraft"></param> /// <param name="actionType"></param> /// <param name="service"></param> /// <returns></returns> internal ChangePlan CreateChangePlan(Plan plan, PlanAircraft planAircraft, string actionType, IFleetService service) { if (plan == null || planAircraft == null) return null; // 创建新的变更计划明细 var planDetail = new ChangePlan { Plan = plan, ActionType = actionType, PlanHistoryID = Guid.NewGuid(), PlanAircraft = planAircraft, AircraftType = planAircraft.AircraftType, Annual = service.CurrentAnnual, PerformMonth = 1, Airlines = service.CurrentAirlines, }; // 获取飞机的当前商业数据,赋予新创建的变更计划明细 var abs = planAircraft.Aircraft.AircraftBusinesses; if (abs.Any()) { var aircraftBusiness = abs.FirstOrDefault(a => a.EndDate == null); if (aircraftBusiness != null) { planDetail.ActionCategory = aircraftBusiness.ImportCategory; planDetail.TargetCategory = aircraftBusiness.ImportCategory; planDetail.SeatingCapacity = aircraftBusiness.SeatingCapacity; planDetail.CarryingCapacity = aircraftBusiness.CarryingCapacity; } } return planDetail; }
private void OnChange() { if (this._changePlan == null) this._changePlan = this.service.CreateChangePlans(this.CurrentPlan, this._planAircraft, "变更"); this.PlanDetail = this._changePlan; this.IsChangeable = true; }
/// <summary> /// 打开子窗体之前判断是否要打开 /// </summary> /// <param name="planAircraft">计划飞机</param> /// <param name="source">调用的来源</param> internal void OpenEditDialog(PlanAircraft planAircraft, PlanDetailCreateSource source) { if (this.ViewPlanHistory == null || (!this.ViewPlanHistory.Any(p => p.HasValidationErrors))) { this._planAircraft = planAircraft; this._operationPlan = null; this._changePlan = null; // 获取计划飞机在当前计划中的明细项集合 var planDetails = new List<PlanHistory>(); if(planAircraft!=null) planDetails = this.ViewPlanHistory.Where(ph => ph.PlanAircraft == planAircraft).ToList(); // 1、计划飞机在当前计划中没有明细项 if (!planDetails.Any()) this.ShowEditDialog(null, source); // 2、计划飞机在当前计划中已有明细项 else { if (planDetails.Count == 1) { string content; switch (source) { case PlanDetailCreateSource.New: break; case PlanDetailCreateSource.PlanAircraft: content = "计划飞机在当前计划中已有引进计划明细项,是否要针对该计划飞机添加退出计划明细项?"; RadWindow.Confirm(this.SetConfirm("确认添加计划明细", "确认", "取消", content, 13, 250, (o, e) => { if (e.DialogResult == true) this.ShowEditDialog(planDetails[0], source); })); break; case PlanDetailCreateSource.Aircraft: content = planDetails[0].ActionType == "变更" ? "飞机在当前计划中已有变更计划明细项,是否要针对该飞机添加退出计划明细项?" : "飞机在当前计划中已有退出计划明细项,是否要针对该飞机添加变更计划明细项?"; RadWindow.Confirm(this.SetConfirm("确认添加计划明细", "确认", "取消", content, 13, 250, (o, e) => { if (e.DialogResult == true) this.ShowEditDialog(planDetails[0], source); })); break; default: throw new ArgumentOutOfRangeException("source"); } } else { RadWindow.Alert(this.SetAlter("提醒", "确认", "该计划飞机已有两条明细项,不能再添加新计划明细项!", 13, 250, () => { })); } } } }