Ejemplo n.º 1
0
        private void btnFirePilot_Click(object sender, RoutedEventArgs e)
        {
            PilotMVVM pilot = (PilotMVVM)((Button)sender).Tag;

            if (pilot.Pilot.Airliner == null)
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2117"), string.Format(Translator.GetInstance().GetString("MessageBox", "2117", "message"), pilot.Pilot.Profile.Name), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    this.Airline.removePilot(pilot);
                }
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2116"), string.Format(Translator.GetInstance().GetString("MessageBox", "2116", "message"), pilot.Pilot.Profile.Name), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    pilot.Pilot.Airliner.Status = FleetAirliner.AirlinerStatus.Stopped;
                    pilot.Pilot.Airliner.removePilot(pilot.Pilot);

                    this.Airline.removePilot(pilot);
                }
            }
        }
Ejemplo n.º 2
0
        //removes a pilot
        public void removePilot(PilotMVVM pilot)
        {
            this.Pilots.Remove(pilot);
            this.Airline.removePilot(pilot.Pilot);

            this.UnassignedPilots = this.Pilots.Count(p => p.Pilot.Airliner == null);
            this.PilotsToRetire   = this.Pilots.Count(p => p.Pilot.Profile.Age == Pilot.RetirementAge - 1);
            this.NeededPilots     = this.DeliveredFleet.Sum(f => f.Airliner.Type.CockpitCrew - f.Pilots.Count);
        }
Ejemplo n.º 3
0
        private void btnTrainPilot_Click(object sender, RoutedEventArgs e)
        {
            double substituteDayPrice = 500;

            PilotMVVM pilot = (PilotMVVM)((Button)sender).Tag;

            ComboBox cbAirlinerFamily = new ComboBox();

            cbAirlinerFamily.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbAirlinerFamily.ItemTemplate        = this.Resources["TrainingFacility"] as DataTemplate;
            cbAirlinerFamily.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbAirlinerFamily.Width = 350;

            var airlinerFamilies = AirlinerTypes.GetTypes(t => t.Produced.From.Year <= GameObject.GetInstance().GameTime.Year&& t.Produced.To > GameObject.GetInstance().GameTime.AddYears(-30)).Select(t => t.AirlinerFamily).Where(t => !pilot.Pilot.Aircrafts.Contains(t)).Distinct().OrderBy(a => a);

            foreach (string family in airlinerFamilies)
            {
                double price = AirlineHelpers.GetTrainingPrice(pilot.Pilot, family);;
                cbAirlinerFamily.Items.Add(new PilotTrainingMVVM(family, AirlineHelpers.GetTrainingDays(pilot.Pilot, family), price));
            }

            cbAirlinerFamily.SelectedIndex = 0;

            if (PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PageAirlineEmployees", "1014"), cbAirlinerFamily) == PopUpSingleElement.ButtonSelected.OK && cbAirlinerFamily.SelectedItem != null)
            {
                PilotTrainingMVVM pilotTraining = (PilotTrainingMVVM)cbAirlinerFamily.SelectedItem;

                if (pilot.Pilot.Airliner == null)
                {
                    AirlineHelpers.SendForTraining(GameObject.GetInstance().HumanAirline, pilot.Pilot, pilotTraining.Family, pilotTraining.TrainingDays, pilotTraining.Price);

                    pilot.OnTraining = true;
                }
                else
                {
                    double substitutePrice = GeneralHelpers.GetInflationPrice(pilotTraining.TrainingDays * substituteDayPrice);

                    WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2129"), string.Format(Translator.GetInstance().GetString("MessageBox", "2129", "message"), new ValueCurrencyConverter().Convert(substitutePrice), pilotTraining.TrainingDays), WPFMessageBoxButtons.YesNo);

                    if (result == WPFMessageBoxResult.Yes)
                    {
                        AirlineHelpers.AddAirlineInvoice(this.Airline.Airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Airline_Expenses, -substitutePrice);
                        AirlineHelpers.SendForTraining(GameObject.GetInstance().HumanAirline, pilot.Pilot, pilotTraining.Family, pilotTraining.TrainingDays, pilotTraining.Price);

                        pilot.OnTraining = true;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        //removes a pilot
        public void removePilot(PilotMVVM pilot)
        {
            this.Pilots.Remove(pilot);
            this.Airline.removePilot(pilot.Pilot);

            this.UnassignedPilots = this.Pilots.Count(p => p.Pilot.Airliner == null);
            this.PilotsToRetire = this.Pilots.Count(p => p.Pilot.Profile.Age == Pilot.RetirementAge - 1);
            this.NeededPilots = this.DeliveredFleet.Sum(f => f.Airliner.Type.CockpitCrew - f.Pilots.Count);
        }