private void textBoxSearch_TextChanged(object sender, EventArgs e)
 {
     if (textBoxSearch.Text == "")
     {
         viewsFlghtsUpdate(flights);
     }
     else
     {
         int option = 0;
         if (radioButtonRoute.Checked)
         {
             option = 1;
         }
         else if (radioButtonOrigin.Checked)
         {
             option = 2;
         }
         else if (radioButtonDestination.Checked)
         {
             option = 3;
         }
         filterFlightsList = flights.searchMatches(textBoxSearch.Text, option);
         viewsFlghtsUpdate(filterFlightsList);
     }
 }
 public ViewsFlights(FlightsList flights, Graph graph)
 {
     InitializeComponent();
     this.flights = flights;
     this.graph   = graph;
     viewsFlghtsUpdate(flights);
 }
        public FlightsList searchMatches(string data, int option)
        {
            FlightsList filterFlightsList = new FlightsList();

            switch (option)
            {
            case 1:
            {
                for (int i = 0; i < this.Count; i++)
                {
                    int j;
                    for (j = 0; j < data.Length && j < this[i].getRoute().Length; j++)
                    {
                        if (data[j] != this[i].getRoute()[j])
                        {
                            break;
                        }
                    }
                    if (j == data.Length)
                    {
                        filterFlightsList.Add(this[i]);
                    }
                }
                break;
            }

            case 2:
            {
                for (int i = 0; i < this.Count; i++)
                {
                    if (data == this[i].getOriginCity().ToString())
                    {
                        filterFlightsList.Add(this[i]);
                    }
                }
                break;
            }

            case 3:
            {
                for (int i = 0; i < this.Count; i++)
                {
                    if (data == this[i].getDestinationCity().ToString())
                    {
                        filterFlightsList.Add(this[i]);
                    }
                }
                break;
            }

            default:
                break;
            }


            return(filterFlightsList);
        }
 public FlightReservation(FlightsList flights, string route)
 {
     InitializeComponent();
     this.flights    = flights;
     seatNumber      = -1;
     sell            = false;
     this.route      = route;
     labelRoute.Text = route;
     seatsUpdate();
 }
Ejemplo n.º 5
0
        static void Main()
        {
            FlightsList flights = new FlightsList();
            Graph       graph   = new Graph();

            if (File.Exists("Flights.bin"))
            {
                using (Stream s = File.Open("Flights.bin", FileMode.Open))
                {
                    var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    flights = (FlightsList)formatter.Deserialize(s);
                    s.Close();
                }
            }

            if (File.Exists("Graph.bin"))
            {
                using (Stream s = File.Open("Graph.bin", FileMode.Open))
                {
                    var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    graph = (Graph)formatter.Deserialize(s);
                    s.Close();
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new MainMenu());
            MainMenu mainMenu = new MainMenu(flights, graph);

            mainMenu.ShowDialog();

            File.Delete("Flights.bin");
            using (Stream s = File.Create("Flights.bin"))
            {
                var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                formatter.Serialize(s, flights);
                s.Close();
            }

            File.Delete("Graph.bin");
            using (Stream s = File.Create("Graph.bin"))
            {
                var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                formatter.Serialize(s, graph);
                s.Close();
            }
        }
Ejemplo n.º 6
0
 public GraphForm(int create, Graph graph, FlightsList flights)
 {
     this.create  = create;
     this.graph   = graph;
     this.flights = flights;
     positionX    = positionY = 0;
     InitializeComponent();
     initializeGraph();
     if (create == 1)
     {
         MessageBox.Show("Selecciona posicion de las nuevas ciudades", "Informacion",
                         MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     updateOriDesti();
     recorridoOD = "";
 }
        public void viewsFlghtsUpdate(FlightsList flightsList)
        {
            listViewFlights.Items.Clear();
            string[] arrString = new string[5];

            foreach (Flight flight in flightsList)
            {
                arrString[0] = flight.getRoute();
                arrString[1] = flight.getOriginCity();
                arrString[2] = flight.getDestinationCity();
                arrString[3] = flight.getFlightTime().ToString();
                arrString[4] = flight.getCost().ToString();
                ListViewItem item = new ListViewItem(arrString);
                listViewFlights.Items.Add(item);
            }
        }
 public FlightReservation(FlightsList flights, string route, Passenger passenge, int ingreso)
 {
     InitializeComponent();
     this.flights    = flights;
     seatNumber      = -1;
     sell            = false;
     this.route      = route;
     labelRoute.Text = route;
     seatsUpdate();
     if (ingreso > 0)
     {
         textBoxPassengerName.Text        = passenge.getName();
         textBoxPassengerName.Enabled     = false;
         textBoxPassengerLastName.Text    = passenge.getLastname();
         textBoxPassengerLastName.Enabled = false;
         textBoxPassengerAge.Text         = passenge.getAge().ToString();
         textBoxPassengerAge.Enabled      = false;
     }
 }
Ejemplo n.º 9
0
        public void viewsPassengersUpdate(FlightsList flights)
        {
            listViewPassengers.Items.Clear();
            string[] arrString = new string[6];

            foreach (Flight flight in flights)
            {
                foreach (Passenger passenger in flight.getPassengers())
                {
                    arrString[0] = passenger.getId();
                    arrString[1] = passenger.getFlightRoute();
                    arrString[2] = passenger.getName();
                    arrString[3] = passenger.getLastname();
                    arrString[4] = Convert.ToString(passenger.getAge());
                    arrString[5] = Convert.ToString(passenger.getSeatNumber() + 1);
                    ListViewItem item = new ListViewItem(arrString);
                    listViewPassengers.Items.Add(item);
                }
            }
        }
Ejemplo n.º 10
0
 public MainMenu(FlightsList flights, Graph graph)
 {
     this.graph   = graph;
     this.flights = flights;
     InitializeComponent();
 }
Ejemplo n.º 11
0
 public ViewsPassengers(FlightsList flights)
 {
     InitializeComponent();
     this.flights = flights;
     viewsPassengersUpdate(flights);
 }