internal void RemoveRequestDetail(ApprovalHistoryDTO requestDetail) { //先获取与这个申请明细相关的计划明细 var planHistory = CurPlanHistories.SourceCollection.Cast<PlanHistoryDTO>() .FirstOrDefault(p => p.ApprovalHistoryId == requestDetail.Id); if (planHistory != null) { var planAircraft = PlanAircrafts.SourceCollection.Cast<PlanAircraftDTO>() .FirstOrDefault(p => p.Id == planHistory.PlanAircraftId); var approvalHistoryCache = _approvalHistoryCaches.FirstOrDefault(p => p.PlanHistoryId == planHistory.Id); //如果原计划明细状态为“可再次申请”,则删除申请明细前需要将ApprovalHistoryId置为原来的,计划飞机状态还是“申请”状态 if (approvalHistoryCache != null && planAircraft != null) { planHistory.ApprovalHistoryId = approvalHistoryCache.ApprovalHistoryId; planHistory.CanRequest = (int) CanRequest.可再次申请; planHistory.CanDeliver = (int) CanDeliver.未批复; planAircraft.Status = (int) ManageStatus.申请; } //如果远计划明细状态为“可申请”,则删除申请明细前将ApprovalHistoryId置为null,并将计划飞机状态置为“计划”状态 else if (approvalHistoryCache == null && planAircraft != null) { planHistory.ApprovalHistoryId = null; planHistory.CanRequest = (int) CanRequest.可申请; planHistory.CanDeliver = (int) CanDeliver.未申请; planAircraft.Status = (int) ManageStatus.计划; } } SelRequest.ApprovalHistories.Remove(requestDetail); RefreshCommandState(); }
internal void AddNewRequestDetail(PlanHistoryDTO planHistory) { var requestDetail = new ApprovalHistoryDTO { Id = Guid.NewGuid(), RequestId = SelRequest.Id, ImportCategoryId = planHistory.TargetCategoryId, AirlinesId = planHistory.AirlinesId, RequestDeliverAnnualId = planHistory.PerformAnnualId, RequestDeliverMonth = planHistory.PerformMonth, SeatingCapacity = planHistory.SeatingCapacity, CarryingCapacity = planHistory.CarryingCapacity, AircraftType = planHistory.AircraftTypeName, AircraftRegional = planHistory.Regional, AirlineName = planHistory.AirlinesName, ImportCategoryName = planHistory.ActionType + ":" + planHistory.ActionName, }; var annual = Annuals.SourceCollection.Cast<AnnualDTO>() .FirstOrDefault(p => p.Id == requestDetail.RequestDeliverAnnualId); if (annual != null) requestDetail.RequestDeliverAnnualName = annual.Year; if (planHistory.PlanAircraftId != null) requestDetail.PlanAircraftId = Guid.Parse(planHistory.PlanAircraftId.ToString()); // 把申请明细赋给关联的计划明细 if (planHistory.CanRequest == (int) CanRequest.可再次申请 && planHistory.ApprovalHistoryId != null && _approvalHistoryCaches != null) { _approvalHistoryCaches.Add(new ApprovalHistoryCache { PlanHistoryId = planHistory.Id, ApprovalHistoryId = Guid.Parse(planHistory.ApprovalHistoryId.ToString()), }); //用于撤销操作 } planHistory.ApprovalHistoryId = requestDetail.Id; // 计划飞机管理状态修改为申请: var planAircraft = PlanAircrafts.SourceCollection.Cast<PlanAircraftDTO>() .FirstOrDefault(p => p.Id == planHistory.PlanAircraftId); if (planAircraft != null) planAircraft.Status = (int) ManageStatus.申请; planHistory.CanRequest = (int) CanRequest.已申请; planHistory.CanDeliver = (int) CanDeliver.未批准; SelRequest.ApprovalHistories.Add(requestDetail); RefreshCommandState(); }