Пример #1
0
        //cancela el viaje seleccionado
        private void button2_Click(object sender, EventArgs e)
        {
            //vacia los campos
            textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = "";
            textBox5.Text = textBox6.Text = textBox7.Text = "";
            textBox8.Text = comboBox1.Text = "";

            viaje selec = comboBox1.SelectedItem as viaje;

            string empresa = selec.dev_empresa();

            //recoge el asiento devuelto...
            int asiento_devuelto = selec.asientos_libres().Last();

            //elimina el viaje
            bd.usuario_activo.viajes.Remove(selec);

            //devuelve el asiento al viaje
            foreach (var item in bd.viajes)
            {
                if (item.dev_colectivo() == selec.dev_colectivo())
                {
                    item.cargar_asiento(asiento_devuelto);
                }
            }

            //y actualiza los viajes disponibles en el combobox
            comboBox1.Items.Clear();
            foreach (var item in bd.usuario_activo.viajes)
            {
                comboBox1.Items.Add(item);
            }
            bd.Save();
        }
Пример #2
0
 //muestra en pantalla los datos del viaje seleccionado
 private void button2_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text != "")
     {
         viaje viaje = comboBox1.SelectedItem as viaje;
         ORIGENtextBox1.Text    = viaje.dev_origen();                            //ORIGEN
         DESTINOtextBox1.Text   = viaje.dev_destino();                           //DESTINO
         textBox1.Text          = viaje.dev_fecha();                             //FECHA
         textBox2.Text          = viaje.dev_hora();                              //HORA
         CATEGORIAtextBox2.Text = viaje.dev_categoria();                         //CATEGORÍA
         EPRESAtextBox3.Text    = viaje.dev_empresa();                           //EMPRESA
         textBox3.Text          = viaje.dev_colectivo();                         //COLECTIVO ASIGNADO
         textBox4.Text          = (viaje.devolver_km()).ToString("N2") + " Km."; //DISTANCIA
     }
 }