コード例 #1
0
        public static ViajeDiario buscarPorId(int id)
        {
            ViajeDiario viajeDiario = null;

            if (id > -1)
            {
                MySqlConnection con = conexionDB.ObtenerConexion();
                try
                {
                    string sql = "select ID, TRAYECTO, FECHA, BUS, CHOFER, AUXILIAR, ASIENTOS_DISPONIBLES, RUTA_ARCHIVO FROM VIAJES_DIARIOS WHERE ID = " + id;
                    MySqlCommand cmd = new MySqlCommand(sql, con);
                    MySqlDataReader dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        viajeDiario = new ViajeDiario(dr.GetInt32(0), TrayectoFacade.buscarPorId(dr.GetInt32(1)), dr.GetString(2), dr.GetString(3), dr.GetString(4), dr.GetString(5), dr.GetInt32(6));
                    }
                    dr.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    viajeDiario = null;
                }
                finally
                {
                    con.Close();
                }
            }
            return viajeDiario;
        }
コード例 #2
0
        public void editarViajeDiario_Click(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;
            var fila   = button.Tag;

            ViajeDiario viajeBuscado = ViajeDiarioFacade.buscarViajeUnico(this.id_viaje, Convert.ToString(fila));

            this.comboBus.Text      = viajeBuscado.bus;
            this.comboAuxiliar.Text = obtenerNombrePersonaByRut(viajeBuscado.auxiliar, "AUXILIAR");
            this.comboChofer.Text   = obtenerNombrePersonaByRut(viajeBuscado.chofer, "CHOFER");
            this.fecha.Text         = fila.ToString();
        }
コード例 #3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Viaje viaje = ViajeFacade.buscarPorId(this.idViaje);
            ViajeDiario viajeDiario = new ViajeDiario();
            foreach (ViajeDiario vd in viaje.viajesDiarios)
            {
                if (vd.id == idDiario) viajeDiario = vd;
            }
            foreach (Horario h in viaje.horarios)
            {
                if (h.parada.ciudad.nombre == viajeDiario.trayecto.origen.nombre) this.textoSalida.Text = h.salida;
                if (h.parada.ciudad.nombre == viajeDiario.trayecto.destino.nombre) this.textoLlegada.Text = h.llegada;
            }

            if (viajeDiario.id > -1)
            {
                int precio = viajeDiario.trayecto.precio;
                this.textoFecha.Text = viajeDiario.fecha;
                this.textoOrigen.Text = viajeDiario.trayecto.origen.nombre;
                this.textoDestino.Text = viajeDiario.trayecto.destino.nombre;
                this.textoTarifa.Text = precio.ToString();
                this.textoTotal.Text = precio.ToString();

                Button asiento;
                for (int i = 1; i <= viajeDiario.asientosDisponibles; i=i+4)
                {
                    this.gridAsientos.RowDefinitions.Add(new RowDefinition());
                    this.gridAsientos.RowDefinitions[this.gridAsientos.RowDefinitions.Count - 1].Height = new System.Windows.GridLength(35);
                    for (int n = 0; n < 5; n++)
                    {
                        //ASIENTOS LADO CHOFER
                        if (n < 2)
                        {
                            string numero = (n + i).ToString();
                            if (Convert.ToInt32(numero) > viajeDiario.asientosDisponibles) break;
                            asiento = new Button();
                            asiento.Cursor = Cursors.Hand;
                            asiento.Style = Resources["BotonAzul"] as Style;
                            asiento.Content = numero;
                            asiento.Width = 34;
                            asiento.Height = 34;
                            asiento.Click += new RoutedEventHandler(selecciona_Asiento);
                            asiento.Tag = numero;
                            asiento.SetValue(Grid.ColumnProperty, n);
                            asiento.SetValue(Grid.RowProperty, this.gridAsientos.RowDefinitions.Count - 1);
                            this.gridAsientos.Children.Add(asiento);
                        }
                        else
                        {
                            //ASIENTOS OTRO LADO
                            if (n > 2)
                            {
                                string numero = (n - 1 + i).ToString();
                                if (Convert.ToInt32(numero) > viajeDiario.asientosDisponibles) break;
                                asiento = new Button();
                                asiento.Cursor = Cursors.Hand;
                                asiento.Style = Resources["BotonAzul"] as Style;
                                asiento.Content = numero;
                                asiento.Width = 34;
                                asiento.Height = 34;
                                asiento.Click += new RoutedEventHandler(selecciona_Asiento);
                                asiento.Tag = numero;
                                asiento.SetValue(Grid.ColumnProperty, n);
                                asiento.SetValue(Grid.RowProperty, this.gridAsientos.RowDefinitions.Count - 1);
                                this.gridAsientos.Children.Add(asiento);
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Viaje       viaje       = ViajeFacade.buscarPorId(this.idViaje);
            ViajeDiario viajeDiario = new ViajeDiario();

            foreach (ViajeDiario vd in viaje.viajesDiarios)
            {
                if (vd.id == idDiario)
                {
                    viajeDiario = vd;
                }
            }
            foreach (Horario h in viaje.horarios)
            {
                if (h.parada.ciudad.nombre == viajeDiario.trayecto.origen.nombre)
                {
                    this.textoSalida.Text = h.salida;
                }
                if (h.parada.ciudad.nombre == viajeDiario.trayecto.destino.nombre)
                {
                    this.textoLlegada.Text = h.llegada;
                }
            }

            if (viajeDiario.id > -1)
            {
                int precio = viajeDiario.trayecto.precio;
                this.textoFecha.Text   = viajeDiario.fecha;
                this.textoOrigen.Text  = viajeDiario.trayecto.origen.nombre;
                this.textoDestino.Text = viajeDiario.trayecto.destino.nombre;
                this.textoTarifa.Text  = precio.ToString();
                this.textoTotal.Text   = precio.ToString();

                Button asiento;
                for (int i = 1; i <= viajeDiario.asientosDisponibles; i = i + 4)
                {
                    this.gridAsientos.RowDefinitions.Add(new RowDefinition());
                    this.gridAsientos.RowDefinitions[this.gridAsientos.RowDefinitions.Count - 1].Height = new System.Windows.GridLength(35);
                    for (int n = 0; n < 5; n++)
                    {
                        //ASIENTOS LADO CHOFER
                        if (n < 2)
                        {
                            string numero = (n + i).ToString();
                            if (Convert.ToInt32(numero) > viajeDiario.asientosDisponibles)
                            {
                                break;
                            }
                            asiento         = new Button();
                            asiento.Cursor  = Cursors.Hand;
                            asiento.Style   = Resources["BotonAzul"] as Style;
                            asiento.Content = numero;
                            asiento.Width   = 34;
                            asiento.Height  = 34;
                            asiento.Click  += new RoutedEventHandler(selecciona_Asiento);
                            asiento.Tag     = numero;
                            asiento.SetValue(Grid.ColumnProperty, n);
                            asiento.SetValue(Grid.RowProperty, this.gridAsientos.RowDefinitions.Count - 1);
                            this.gridAsientos.Children.Add(asiento);
                        }
                        else
                        {
                            //ASIENTOS OTRO LADO
                            if (n > 2)
                            {
                                string numero = (n - 1 + i).ToString();
                                if (Convert.ToInt32(numero) > viajeDiario.asientosDisponibles)
                                {
                                    break;
                                }
                                asiento         = new Button();
                                asiento.Cursor  = Cursors.Hand;
                                asiento.Style   = Resources["BotonAzul"] as Style;
                                asiento.Content = numero;
                                asiento.Width   = 34;
                                asiento.Height  = 34;
                                asiento.Click  += new RoutedEventHandler(selecciona_Asiento);
                                asiento.Tag     = numero;
                                asiento.SetValue(Grid.ColumnProperty, n);
                                asiento.SetValue(Grid.RowProperty, this.gridAsientos.RowDefinitions.Count - 1);
                                this.gridAsientos.Children.Add(asiento);
                            }
                        }
                    }
                }
            }
        }