Exemple #1
0
        public RoundTripFlights(Flight SelectedFlight, User user, EFlightType type)
        {
            InitializeComponent();

            this.user = user;

            foreach (Flight f in Data.Instance.Flights)
            {
                if (SelectedFlight.DeparturePlace.City.Equals(f.Destination.City) && SelectedFlight.Destination.City.Equals(f.DeparturePlace.City))
                {
                    roundtripFlights.Add(f);
                }
            }

            foreach (Flight f in Data.Instance.Flights)
            {
                if (SelectedFlight.DeparturePlace.City.Equals(f.Destination.City) && SelectedFlight.Destination.City.Equals(f.DeparturePlace.City) && SelectedFlight.CompanyPassword.CompanyPassword.Equals(f.CompanyPassword.CompanyPassword))
                {
                    aircompanyFlights.Add(f);
                }
            }

            view = CollectionViewSource.GetDefaultView(roundtripFlights);
            DgRoundtrip.ItemsSource = view;
            DgRoundtrip.IsReadOnly  = true;
            DgRoundtrip.IsSynchronizedWithCurrentItem = true;
            DgRoundtrip.ColumnWidth = new DataGridLength(1, DataGridLengthUnitType.Star);
        }
 private void BtnPickSeat_Click(object sender, RoutedEventArgs e)
 {
     if (ValidationPick() == true)
     {
         SelectedFlight = DGFlights.SelectedItem as Flight;
         type           = (EFlightType)CbFlightType.SelectedItem;
         BookFlightPassenger bf = new BookFlightPassenger(SelectedFlight, user, type);
         bf.ShowDialog();
         this.Close();
     }
 }
        public BookFlightPassenger(Flight flight, User user, EFlightType type)
        {
            InitializeComponent();
            this.user   = user;
            this.flight = flight;
            this.type   = type;

            if (user != null)
            {
                txtFlight.IsEnabled  = false;
                txtName.IsEnabled    = false;
                txtSeat.IsEnabled    = false;
                CbGender.IsEnabled   = false;
                txtSurname.IsEnabled = false;
                txtAddress.IsEnabled = false;
                txtEmail.IsEnabled   = false;


                txtName.Text          = user.Name;
                txtSurname.Text       = user.Surname;
                txtEmail.Text         = user.Email;
                CbGender.SelectedItem = user.Gender;
                txtAddress.Text       = user.Address;
            }

            this.txtSeat.DataContext  = SelectedSeat;
            this.cbClass.DataContext  = SelectedSeat;
            this.txtPrice.DataContext = flight;

            this.txtName.DataContext    = user;
            this.txtSurname.DataContext = user;
            this.txtEmail.DataContext   = user;
            this.CbGender.DataContext   = user;
            this.txtAddress.DataContext = user;

            this.txtFlight.DataContext = flight;

            CbGender.ItemsSource = Enum.GetValues(typeof(EGender));
            cbClass.ItemsSource  = Enum.GetValues(typeof(EClass));


            txtPrice.Text = flight.OneWayTicketPrice.ToString();

            gate.Add("A5");
            gate.Add("B4");
            gate.Add("D5");

            CbGate.ItemsSource = gate;
        }
        public FilterFlightsWindow(User user, EFlightType type)
        {
            InitializeComponent();
            this.user = user;
            BtnPickFlight.IsEnabled = false;

            CbFlightType.ItemsSource = Enum.GetValues(typeof(EFlightType));


            view = CollectionViewSource.GetDefaultView(Data.Instance.Flights);
            DGFlights.ItemsSource = view;
            view.Filter           = RangeFilter;
            DGFlights.IsReadOnly  = true;
            DGFlights.IsSynchronizedWithCurrentItem = true;
            DGFlights.ColumnWidth   = new DataGridLength(1, DataGridLengthUnitType.Star);
            BtnPickFlight.IsEnabled = true;
            view.SortDescriptions.Add(new SortDescription("OneWayTicketPrice", ListSortDirection.Descending));
        }