예제 #1
0
        private void update()
        {
            if (lbAirports.SelectedIndex != -1)
            {
                Aiport aiport = (Aiport)lbAirports.SelectedItem;
                lbDestinations.Items.Clear();
                foreach (Destination destination in aiport.destinations)
                {
                    lbDestinations.Items.Add(destination);
                }

                if (aiport.destinations.Count >= 1)
                {
                    Destination expensive = aiport.mostExpensiveDestination();
                    textBox1.Text = expensive.ToString();
                    textBox2.Text = aiport.averageLen().ToString();
                }
                else
                {
                    textBox1.Clear();
                    textBox2.Clear();
                }
            }
            else
            {
                lbDestinations.Items.Clear();
                textBox1.Clear();
                textBox2.Clear();
            }
        }
 private void btnSubmitAirport_Click(object sender, EventArgs e)
 {
     if (tbAirportName.Text.Length == 0 || tbCityName.Text.Length == 0 || tbAbbr.Text.Length == 0)
     {
         MessageBox.Show("You must enter all fields first!");
     }
     else
     {
         String cityName    = tbCityName.Text;
         String airportName = tbAirportName.Text;
         String abbr        = tbAbbr.Text;
         airport      = new Aiport(cityName, airportName, abbr, new List <Destination>());
         DialogResult = DialogResult.OK;
     }
 }
예제 #3
0
        private void btnAddDestination_Click(object sender, EventArgs e)
        {
            Nova_destinacija nova_Destinacija = new Nova_destinacija();
            DialogResult     result           = nova_Destinacija.ShowDialog();

            if (result == DialogResult.OK)
            {
                lbDestinations.Items.Add(nova_Destinacija.destination);
            }

            Aiport selected = (Aiport)lbAirports.SelectedItem;

            selected.addDestination(nova_Destinacija.destination);

            update();
        }
예제 #4
0
        private void btnRemoveAirport_Click(object sender, EventArgs e)
        {
            Deletion_notice deletion = new Deletion_notice();
            DialogResult    result   = deletion.ShowDialog();

            if (result == DialogResult.Yes)
            {
                if (lbAirports.SelectedIndex != -1)
                {
                    Aiport aiport = (Aiport)lbAirports.SelectedItem;
                    aiport.destinations.Clear();


                    lbAirports.Items.RemoveAt(lbAirports.SelectedIndex);
                    update();
                }
                btnRemoveAirport.Enabled = false;
            }
        }