Exemplo n.º 1
0
 //when user clicks add button, adds customer to airline coordinator & list view (table in GUI)
 private void customerAddButton_Click(object sender, EventArgs e)
 {
     if (!isCustomerDataOk(customerFirstNameTextBox.Text, customerLastNameTextBox.Text, customerPhoneNumberTextBox.Text))
     {
         return;
     }
     if (aCoord.addCustomer(customerFirstNameTextBox.Text, customerLastNameTextBox.Text, customerPhoneNumberTextBox.Text))
     {
         CustomerListViewItem clvi = new CustomerListViewItem(aCoord.getLastCustomer());
         customerLstView.Items.Add(clvi);
     }
     else
     {
         string aMessage = "Customer was not added..";
         MessageBox.Show(aMessage, "Error");
     }
     customerFirstNameTextBox.ResetText();
     customerLastNameTextBox.ResetText();
     customerPhoneNumberTextBox.ResetText();
 }
Exemplo n.º 2
0
        //when new item is selected in combo box (drop list) displays the flight information and passenger list
        private void particularFlightNumberComboBox_SelectionChangeCommitted(object sender, EventArgs e)
        {
            particularFlightListView.Items.Clear();
            Flight selectedFlight = aCoord.getFlight((int)particularFlightNumberComboBox.SelectedItem);

            particularOriginLabelContent.Text      = selectedFlight.getOrigin();
            particularDestinationLabelContent.Text = selectedFlight.getDestination();
            particularMaxSeatsLabelContent.Text    = Convert.ToString(selectedFlight.getMaxSeats());

            Customer[] flightPassengers = selectedFlight.getCustomers();

            foreach (Customer passenger in flightPassengers)
            {
                if (passenger == null)
                {
                    break;
                }
                CustomerListViewItem clvi = new CustomerListViewItem(passenger);
                particularFlightListView.Items.Add(clvi);
            }
        }