Exemplo n.º 1
0
        private void Button_Add_Click(object sender, EventArgs e)
        {
            // add new reservation.
            var reservationDialog = new AddReservationDialog(Passenger);

            if (reservationDialog.ShowDialog() == DialogResult.OK)
            {
                BoardingPasses.Add(new BoardingPass(0, Convert.ToInt32(reservationDialog.comboBox_Flight.Text), Passenger.ID, 0, reservationDialog.comboBox_Class.Text, false));
                LoadFormData();
            }
        }
Exemplo n.º 2
0
        public AddPassengerDialog(int id = 0)
        {
            InitializeComponent();

            // Make column titles bold.
            for (int i = 0; i < listView_Reservations.Columns.Count; i++)
            {
                listView_Reservations.Columns[i].ListView.Font = new Font(listView_Reservations.Font, FontStyle.Bold);
            }

            DialogResult = DialogResult.Cancel;

            // if the id isnt 0, then we are editing an existing passenger.
            if (id == 0)
            {
                Text      = "Add Passenger";
                Passenger = new Passenger();
            }
            else
            {
                Text = "Edit Passenger";

                //retrieve passenger information from the database.
                Passenger = Database.GetPassenger(id);

                // populate form with passenger data.
                dateTimePicker_DOB.Value           = Passenger.DateOfBirth;
                textBox_Name.Text                  = Passenger.Name;
                textBox_Address.Text               = Passenger.Address;
                textBox_Cost.Text                  = Passenger.Cost.ToString();
                textBox_Email.Text                 = Passenger.Email;
                textBox_Number.Text                = Passenger.Number;
                textBox_SpecialAccommodations.Text = Passenger.SpecialAccommodations;
                comboBox_Preference.SelectedIndex  = (int)Passenger.SeatingPreference;

                // add all boarding passes associated with the passenger to the list.
                foreach (var boardingPass in Passenger.BoardingPasses.FindAll(x => x.Issued == false))
                {
                    BoardingPasses.Add(boardingPass);
                }

                LoadFormData(); // load form data.
            }
        }