//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(); }
//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 } }
//carga en los campos la información del viaje seleccionado private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { button2.Enabled = true; viaje selec = comboBox1.SelectedItem as viaje; textBox1.Text = selec.dev_origen(); //ORIGEN textBox2.Text = selec.dev_destino(); //DESTINO textBox3.Text = selec.dev_categoria(); //CATEGORIA textBox4.Text = selec.dev_empresa(); //EMPRESA textBox5.Text = selec.dev_fecha(); //FECHA textBox6.Text = selec.dev_hora(); //HORA textBox7.Text = (selec.asientos_libres().Last()).ToString(); //ASIENTO COMPRADO textBox8.Text = selec.devolver_tipo(); //TIPO DE PASAJE }
//muestra en pantalla los datos del viaje seleccionado private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { viaje nuevo = comboBox1.SelectedItem as viaje; textBox1.Text = nuevo.dev_fecha(); //FECHA textBox2.Text = nuevo.dev_hora(); //HORA CATEGORIAtextBox2.Text = nuevo.dev_categoria(); //CATEGORIA EPRESAtextBox3.Text = nuevo.dev_empresa(); //EMPRESA label10.Text = (nuevo.numero_de_asientos()).ToString(); //N° DE ASIENTOS LIBRES //carga en el combobox la lista de asientos disponibles comboBox4.Items.Clear(); foreach (var item in nuevo.asientos_libres()) { comboBox4.Items.Add(item); } }