Exemplo n.º 1
0
        /// <summary>
        ///     创建计划飞机
        /// </summary>
        /// <returns>计划飞机</returns>
        public static PlanAircraft CreatePlanAircraft()
        {
            var planAircraft = new PlanAircraft();

            planAircraft.GenerateNewIdentity();
            return planAircraft;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 创建运营计划明细
        /// 同一架计划飞机在一份计划中的明细项不得超过两条,且两条不得为同种操作类型(含运营计划与变更计划)
        /// </summary>
        /// <param name="plan"></param>
        /// <param name="planAircraft"></param>
        /// <param name="actionType"></param>
        /// <param name="service"></param>
        /// <returns></returns>
        internal OperationPlan CreateOperationPlan(Plan plan, PlanAircraft planAircraft, string actionType, IFleetService service)
        {
            if (plan == null) return null;
            // 创建新的计划历史
            var planDetail = new OperationPlan
                {
                    PlanHistoryID = Guid.NewGuid(),
                    Plan = plan,
                    ActionType = actionType,
                    Airlines = service.CurrentAirlines,
                    Annual = service.CurrentAnnual,
                    PerformMonth = 1,
                };
            // 1、计划飞机为空
            if (planAircraft == null)
            {
                // 创建新的计划飞机
                var pa = new PlanAircraft
                    {
                        PlanAircraftID = Guid.NewGuid(),
                        Airlines = service.CurrentAirlines,
                        Status = (int)ManageStatus.Plan,
                        IsOwn = true
                    };
                planDetail.PlanAircraft = pa;
            }
            // 2、计划飞机非空
            else
            {
                // 获取计划飞机的所有计划明细集合
                var phs = planAircraft.PlanHistories;
                // 获取计划飞机在当前计划中的计划明细集合
                var planDetails = phs.Where(ph => ph.Plan == plan).ToList();
                // 2.1、不是针对现有飞机的计划明细
                if (planAircraft.Aircraft == null)
                {
                    if (phs.Any())
                    {
                        // 获取计划飞机的最后一条计划明细,用于复制数据
                        var planHistory =
                            phs.OrderBy(ph => ph.Annual.Year)
                               .ThenBy(ph => ph.Plan.VersionNumber)
                               .LastOrDefault();
                        if (planHistory != null)
                        {
                            // 1、计划飞机在当前计划中没有明细项
                            if (!planDetails.Any())
                            {
                                planDetail.AircraftType = planAircraft.AircraftType;
                                planDetail.ActionCategory = planHistory.ActionCategory;
                                planDetail.TargetCategory = planHistory.TargetCategory;
                                planDetail.SeatingCapacity = planHistory.SeatingCapacity;
                                planDetail.CarryingCapacity = planHistory.CarryingCapacity;
                                planAircraft.Status = (int)ManageStatus.Plan;
                            }
                            // 2、计划飞机在当前计划中已有明细项
                            else
                            {
                                planDetail.AircraftType = planAircraft.AircraftType;
                                planDetail.SeatingCapacity = -planHistory.SeatingCapacity;
                                planDetail.CarryingCapacity = -planHistory.CarryingCapacity;
                            }
                        }
                    }
                }
                // 2.2、是针对现有飞机的计划明细,肯定是退出计划,无需改变计划飞机管理状态
                else
                {
                    planDetail.AircraftType = planAircraft.AircraftType;
                    planDetail.SeatingCapacity = planAircraft.Aircraft.SeatingCapacity;
                    planDetail.CarryingCapacity = planAircraft.Aircraft.CarryingCapacity;
                }
                planDetail.PlanAircraft = planAircraft;
            }

            return planDetail;
        }
Exemplo n.º 3
0
        /// <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;
        }
Exemplo n.º 4
0
        /// <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, () => { }));
                    }
                }
            }
        }
Exemplo n.º 5
0
 //更新计划飞机
 private void UpdatePlanAircraft(PlanAircraft NewPlanAircraft)
 {
     if (NewPlanAircraft != null)
     {
         PlanAircraft OriginPlanAircraft = this._FE.PlanAircrafts.Where(q => q.PlanAircraftID == NewPlanAircraft.PlanAircraftID).FirstOrDefault();
         //原来为空,新增
         if (OriginPlanAircraft == null)
         {
             NewPlanAircraft.PlanHistories = null;
             this._FE.PlanAircrafts.Add(NewPlanAircraft);
         }
         //原来已有,更新
         else
         {
             NewPlanAircraft.PlanHistories = null;
             this._FE.Update<PlanAircraft>(OriginPlanAircraft, NewPlanAircraft);
         }
     }
 }