コード例 #1
0
        public void OrdenamientoAsiento()
        {
            if (lpC.Count() != 0)
            {
                ListaPasajeros lp0 = new ListaPasajeros();

                if (lpC.Count() == listBoxListaPasajeros.Items.Count) //ESTO REVISA SI ORDENARA UN LISTA COMPLETA O LA FLTRADA ANTERIORMENTE
                {
                    lp0 = lpC.quicksortAsiento(lpC, 0, lpC.Count() - 1);
                }
                else
                {
                    lp0 = lpCF.quicksortAsiento(lpCF, 0, lpCF.Count() - 1);
                }

                listBoxListaPasajeros.Items.Clear();

                for (int i = 0; i < lp0.Count(); i++)                        //SE AGREGAN LOS ELEMENTOS A LAS LISTA CON EL ORDENAMIENTO
                {
                    listBoxListaPasajeros.Items.Add(lp0[i]);
                }
            }
            else
            {
                MessageBox.Show("No hay elmentos para ordenar", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #2
0
        public FormPasajeros(ListaVuelos lv)
        {
            this.lv = lv;

            ListaPasajeros lpC = new ListaPasajeros();

            this.lpC = lpC;

            foreach (ClassVuelo v in lv)
            {
                foreach (ClassPasajero pas in v.getListaPasajeros())
                {
                    this.lpC.Add(pas);
                }
            }



            InitializeComponent();
            actualizaListaCompleta();


            groupBoxOrdenar.Controls.OfType <RadioButton>().ToList().ForEach((radiobutton) =>
            {
                radiobutton.AutoCheck = false;
                radiobutton.Checked   = false;
                radiobutton.AutoCheck = true;
            });
        }
コード例 #3
0
        /////////////////////////////
        public ClassVuelo(string ori, string dest, int cost, int tiem)
        {
            lp      = new ListaPasajeros();
            origen  = ori;
            destino = dest;
            costo   = cost;
            tiempo  = tiem;
            ruta    = "SK1" + ori + dest;

            ///////////////////////////
        }
コード例 #4
0
        public ListaPasajeros quicksortAsiento(ListaPasajeros lista, int primero, int ultimo)
        {
            int    i, j, central;
            double pivote;

            central = (primero + ultimo) / 2;
            pivote  = lista[central].getAsiento();
            i       = primero;
            j       = ultimo;


            do
            {
                while (lista[i].getAsiento() < pivote)
                {
                    i++;
                }
                while (lista[j].getAsiento() > pivote)
                {
                    j--;
                }
                if (i <= j)
                {
                    ClassPasajero temp;
                    temp     = lista[i];
                    lista[i] = lista[j];
                    lista[j] = temp;
                    i++;
                    j--;
                }
            } while (i <= j);

            if (primero < j)
            {
                quicksortAsiento(lista, primero, j);
            }
            if (i < ultimo)
            {
                quicksortAsiento(lista, i, ultimo);
            }



            return(lista);
        }
コード例 #5
0
        public ListaPasajeros quicksortRuta(ListaPasajeros lista, int primero, int ultimo)
        {
            int    i, j, central;
            double pivote;

            central = (primero + ultimo) / 2;
            pivote  = Asc(lista[central].getVuelo().getRuta()[3].ToString());
            i       = primero;
            j       = ultimo;


            do
            {
                while (Asc(lista[i].getVuelo().getRuta()[3].ToString()) < pivote)
                {
                    i++;
                }
                while (Asc(lista[j].getVuelo().getRuta()[3].ToString()) > pivote)
                {
                    j--;
                }
                if (i <= j)
                {
                    ClassPasajero temp;
                    temp     = lista[i];
                    lista[i] = lista[j];
                    lista[j] = temp;
                    i++;
                    j--;
                }
            } while (i <= j);

            if (primero < j)
            {
                quicksortRuta(lista, primero, j);
            }
            if (i < ultimo)
            {
                quicksortRuta(lista, i, ultimo);
            }



            return(lista);
        }
コード例 #6
0
        private void textBoxBusca_TextChanged(object sender, EventArgs e)
        {
            listBoxListaPasajeros.Items.Clear();
            if (textBoxBusca.Text == " ")
            {
                textBoxBusca.Text = "";
                actualizaListaCompleta();
            }


            if (radioButtonNombres.Checked == true)
            {
                lpCF = lpC.busquedaCoincidenciasNomApel(textBoxBusca.Text, 1);
            }
            else
            {
                if (radioButtonApellidos.Checked == true)
                {
                    lpCF = lpC.busquedaCoincidenciasNomApel(textBoxBusca.Text, 2);
                }
                else
                {
                    if (radioButtonAsiento.Checked == true)
                    {
                        lpCF = lpC.busquedaCoincidenciasNomApel(textBoxBusca.Text, 3);
                    }
                    else  //EDAD
                    {
                        lpCF = lpC.busquedaCoincidenciasNomApel(textBoxBusca.Text, 4);
                    }
                }
            }


            listBoxListaPasajeros.Items.Clear();
            for (int i = 0; i < lpCF.Count; i++)                        //SE AGREGAN LOS ELEMENTOS A LAS LISTA CON EL FILTRO
            {
                listBoxListaPasajeros.Items.Add(lpCF[i]);
            }
        }
コード例 #7
0
        public ListaPasajeros busquedaCoincidenciasNomApel(string dato, int opc)
        {
            ListaPasajeros lpF = new ListaPasajeros();

            switch (opc)
            {
            case 1:        //Buscar por nombre
            {
                for (int i = 0; i < this.Count; i++)
                {
                    string nombre = this[i].getNombre();
                    int    j;

                    if (dato.Length > this[i].getNombre().Length)
                    {
                        break;
                    }


                    for (j = 0; j < dato.Length; j++)
                    {
                        if (nombre[j] != dato[j])
                        {
                            break;
                        }
                    }

                    if (j == dato.Length)
                    {
                        lpF.Add(this[i]);
                    }
                }


                break;
            }

            case 2:        //buscar por apellido
            {
                for (int i = 0; i < this.Count; i++)
                {
                    string apellido = this[i].getApellido().ToString();
                    int    j;


                    if (dato.Length > this[i].getApellido().Length)
                    {
                        break;
                    }
                    for (j = 0; j < dato.Length; j++)
                    {
                        if (apellido[j] != dato[j])
                        {
                            break;
                        }
                    }
                    if (j == dato.Length)
                    {
                        lpF.Add(this[i]);
                    }
                }

                break;
            }

            case 3:            //buscar por asiento
            {
                for (int i = 0; i < this.Count; i++)
                {
                    string asiento = this[i].getAsiento().ToString();
                    int    j;


                    if (dato.Length > asiento.Length)
                    {
                        break;
                    }
                    for (j = 0; j < dato.Length; j++)
                    {
                        if (asiento[j] != dato[j])
                        {
                            break;
                        }
                    }
                    if (j == dato.Length)
                    {
                        lpF.Add(this[i]);
                    }
                }

                break;
            }

            case 4:            //buscar por edad
            {
                for (int i = 0; i < this.Count; i++)
                {
                    string edad = this[i].getEdad().ToString();
                    int    j;


                    if (dato.Length > this[i].getEdad().ToString().Length)
                    {
                        break;
                    }
                    for (j = 0; j < dato.Length; j++)
                    {
                        if (edad[j] != dato[j])
                        {
                            break;
                        }
                    }
                    if (j == dato.Length)
                    {
                        lpF.Add(this[i]);
                    }
                }

                break;
            }
            }


            return(lpF);
        }