Ejemplo n.º 1
0
        private void btnHire_Click(object sender, RoutedEventArgs e)
        {
            Instructor instructor = (Instructor)((Button)sender).Tag;

            ComboBox cbFlightSchools = new ComboBox();

            cbFlightSchools.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbFlightSchools.Width               = 200;
            cbFlightSchools.SelectedValuePath   = "Name";
            cbFlightSchools.DisplayMemberPath   = "Name";
            cbFlightSchools.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;

            foreach (FlightSchool fs in GameObject.GetInstance().HumanAirline.FlightSchools.Where(f => f.NumberOfInstructors < FlightSchool.MaxNumberOfInstructors))
            {
                cbFlightSchools.Items.Add(fs);
            }

            cbFlightSchools.SelectedIndex = 0;

            if (PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PanelFlightSchool", "1008"), cbFlightSchools) == PopUpSingleElement.ButtonSelected.OK && cbFlightSchools.SelectedItem != null)
            {
                FlightSchool flightSchool = (FlightSchool)cbFlightSchools.SelectedItem;

                flightSchool.addInstructor(instructor);
                instructor.FlightSchool = flightSchool;

                this.AllInstructors.Remove(instructor);

                ICollectionView view = CollectionViewSource.GetDefaultView(lvFlightSchools.ItemsSource);
                view.Refresh();
            }
        }
Ejemplo n.º 2
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            FlightSchool fs = (FlightSchool)((Button)sender).Tag;

            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2812"), string.Format(Translator.GetInstance().GetString("MessageBox", "2812", "message"), fs.Airport.Profile.Town.Name), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                GameObject.GetInstance().HumanAirline.removeFlightSchool(fs);
                this.FlightSchools.Remove(fs);

                if (GameObject.GetInstance().HumanAirline.FlightSchools.Count > 0)
                {
                    ComboBox cbFlightSchools = new ComboBox();
                    cbFlightSchools.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
                    cbFlightSchools.Width               = 200;
                    cbFlightSchools.SelectedValuePath   = "Name";
                    cbFlightSchools.DisplayMemberPath   = "Name";
                    cbFlightSchools.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;

                    foreach (FlightSchool fSchool in GameObject.GetInstance().HumanAirline.FlightSchools.Where(f => f.NumberOfInstructors + fs.NumberOfInstructors <= FlightSchool.MaxNumberOfInstructors && f != fs))
                    {
                        cbFlightSchools.Items.Add(fSchool);
                    }

                    cbFlightSchools.SelectedIndex = 0;

                    if (PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PageFlightSchools", "1009"), cbFlightSchools) == PopUpSingleElement.ButtonSelected.OK && cbFlightSchools.SelectedItem != null)
                    {
                        FlightSchool nFlightSchool = (FlightSchool)cbFlightSchools.SelectedItem;

                        foreach (Instructor instructor in fs.Instructors)
                        {
                            instructor.FlightSchool = nFlightSchool;
                            nFlightSchool.addInstructor(instructor);
                        }

                        var aircrafts = new List <TrainingAircraft>(fs.TrainingAircrafts);
                        foreach (TrainingAircraft aircraft in aircrafts)
                        {
                            aircraft.FlightSchool = nFlightSchool;
                            nFlightSchool.addTrainingAircraft(aircraft);
                        }

                        ICollectionView view = CollectionViewSource.GetDefaultView(lvFlightSchools.ItemsSource);
                        view.Refresh();
                    }
                    else
                    {
                        foreach (TrainingAircraft aircraft in fs.TrainingAircrafts)
                        {
                            double price = aircraft.Type.Price * 0.75;
                            AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Airline_Expenses, price);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void btnHire_Click(object sender, RoutedEventArgs e)
        {
            Boolean isServingCountry = true;// GameObject.GetInstance().HumanAirline.Airports.Exists(a => a.Profile.Country == this.Instructor.Profile.Town.Country);

            if (isServingCountry)
            {
                ComboBox cbFlightSchools = new ComboBox();
                cbFlightSchools.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
                cbFlightSchools.Width               = 200;
                cbFlightSchools.SelectedValuePath   = "Name";
                cbFlightSchools.DisplayMemberPath   = "Name";
                cbFlightSchools.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;

                foreach (FlightSchool fs in GameObject.GetInstance().HumanAirline.FlightSchools.Where(f => f.NumberOfInstructors < FlightSchool.MaxNumberOfInstructors))
                {
                    cbFlightSchools.Items.Add(fs);
                }

                cbFlightSchools.SelectedIndex = 0;

                if (PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PanelFlightSchool", "1008"), cbFlightSchools) == PopUpSingleElement.ButtonSelected.OK && cbFlightSchools.SelectedItem != null)
                {
                    FlightSchool flightSchool = (FlightSchool)cbFlightSchools.SelectedItem;

                    flightSchool.addInstructor(this.Instructor);
                    this.Instructor.FlightSchool = flightSchool;

                    this.ParentPage.updatePage();

                    this.ParentPage.unloadSideMenu();
                }
            }
            else
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2808"), Translator.GetInstance().GetString("MessageBox", "2808", "message"), WPFMessageBoxButtons.Ok);
            }
        }