private void reservar_Click(object sender, RoutedEventArgs e) { if (this.textoAsiento.Text != "") { try { string fechaVenta = DateTime.Today.ToString("dd-MM-yyyy"); Pasaje pasaje = new Pasaje(ViajeDiarioFacade.buscarPorId(this.idDiario), Convert.ToInt32(this.textoTotal.Text.ToString()), fechaVenta, Convert.ToInt32(this.textoAsiento.Text.ToString()), "VIGENTE"); if (textoNombre.Text != "") { pasaje.cliente = ClienteFacade.buscarPorRut(this.textoCliente.Text.ToString()); } PasajeFacade.guardar(pasaje); okAlerta alert = new okAlerta(); alert.show("Viaje reservado exitosamente."); } catch (Exception ex) { validar alert = new validar(); alert.show("No se pudo realizar la reserva del viaje."); } } else { validar alert = new validar(); alert.show("Seleccione un asiento para el viaje"); } }
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(); }
public void crearTabla() { this.fechasViajes.RowDefinitions.Clear(); TextBox celdas; try { // ENCABEZADO 3 COLUMNAS EN LA PRIMERA FILA this.fechasViajes.ColumnDefinitions.Add(new ColumnDefinition()); this.fechasViajes.ColumnDefinitions.Add(new ColumnDefinition()); this.fechasViajes.ColumnDefinitions.Add(new ColumnDefinition()); this.fechasViajes.ColumnDefinitions.Add(new ColumnDefinition()); this.fechasViajes.ColumnDefinitions.Add(new ColumnDefinition()); this.fechasViajes.RowDefinitions.Add(new RowDefinition()); Label FechaHeader = new Label(); FechaHeader.Content = "FECHA VIAJE"; FechaHeader.Style = Resources["HeaderTabla"] as Style; FechaHeader.SetValue(Grid.ColumnProperty, 0); FechaHeader.SetValue(Grid.RowProperty, 0); this.fechasViajes.Children.Add(FechaHeader); Label busHeader = new Label(); busHeader.Content = "BUS"; busHeader.Style = Resources["HeaderTabla"] as Style; busHeader.SetValue(Grid.ColumnProperty, 1); busHeader.SetValue(Grid.RowProperty, 0); this.fechasViajes.Children.Add(busHeader); Label choferHeader = new Label(); choferHeader.Content = "CHOFER"; choferHeader.Style = Resources["HeaderTabla"] as Style; choferHeader.Width = 200; choferHeader.SetValue(Grid.ColumnProperty, 2); choferHeader.SetValue(Grid.RowProperty, 0); this.fechasViajes.Children.Add(choferHeader); Label auxiliarHeader = new Label(); auxiliarHeader.Content = "AUXILIAR"; auxiliarHeader.Style = Resources["HeaderTabla"] as Style; auxiliarHeader.Width = 200; auxiliarHeader.SetValue(Grid.ColumnProperty, 3); auxiliarHeader.SetValue(Grid.RowProperty, 0); this.fechasViajes.Children.Add(auxiliarHeader); Label botonHeader = new Label(); botonHeader.Content = ""; botonHeader.Style = Resources["HeaderTabla"] as Style; botonHeader.Width = 200; botonHeader.SetValue(Grid.ColumnProperty, 4); botonHeader.SetValue(Grid.RowProperty, 0); this.fechasViajes.Children.Add(botonHeader); List <ViajeDiario> listFechasViajes = ViajeDiarioFacade.buscarViajeFecha(this.id_viaje); this.fechasViajes.ColumnDefinitions[0].Width = new System.Windows.GridLength(90); this.fechasViajes.ColumnDefinitions[1].Width = new System.Windows.GridLength(130); this.fechasViajes.ColumnDefinitions[2].Width = new System.Windows.GridLength(165); this.fechasViajes.ColumnDefinitions[3].Width = new System.Windows.GridLength(165); this.fechasViajes.ColumnDefinitions[4].Width = new System.Windows.GridLength(75); int largo = listFechasViajes.Count; for (int z = 0; z < largo; z++) { this.fechasViajes.RowDefinitions.Add(new RowDefinition()); this.fechasViajes.RowDefinitions[z].Height = new System.Windows.GridLength(30); } this.fechasViajes.RowDefinitions[0].Height = new System.Windows.GridLength(30); this.fechasViajes.RowDefinitions[fechasViajes.RowDefinitions.Count - 1].Height = new System.Windows.GridLength(30); int contador = 0; for (int row = 1; row < this.fechasViajes.RowDefinitions.Count; row++) { for (int col = 0; col < this.fechasViajes.ColumnDefinitions.Count; col++) { if (col == 0) { celdas = new TextBox(); celdas.Style = Resources["ItemTablaGuion"] as Style; celdas.Text = listFechasViajes[contador].fecha; celdas.SetValue(Grid.ColumnProperty, col); celdas.SetValue(Grid.RowProperty, row); celdas.IsReadOnly = true; this.fechasViajes.Children.Add(celdas); } if (col == 1) { celdas = new TextBox(); celdas.Style = Resources["ItemTablaGuion"] as Style; celdas.Text = listFechasViajes[contador].bus; celdas.SetValue(Grid.ColumnProperty, col); celdas.SetValue(Grid.RowProperty, row); celdas.IsReadOnly = true; this.fechasViajes.Children.Add(celdas); } if (col == 2) { celdas = new TextBox(); celdas.Style = Resources["ItemTablaGuion"] as Style; celdas.Text = obtenerNombrePersonaByRut(listFechasViajes[contador].chofer, "CHOFER"); celdas.SetValue(Grid.ColumnProperty, col); celdas.SetValue(Grid.RowProperty, row); celdas.IsReadOnly = true; this.fechasViajes.Children.Add(celdas); } if (col == 3) { celdas = new TextBox(); celdas.Style = Resources["ItemTablaGuion"] as Style; celdas.Text = obtenerNombrePersonaByRut(listFechasViajes[contador].auxiliar, "AUXILIAR"); celdas.SetValue(Grid.ColumnProperty, col); celdas.SetValue(Grid.RowProperty, row); celdas.IsReadOnly = true; this.fechasViajes.Children.Add(celdas); } if (col == 4) { Button editarViajeDiario = new Button(); editarViajeDiario.Click += new RoutedEventHandler(editarViajeDiario_Click); editarViajeDiario.Content = "Editar"; editarViajeDiario.Tag = Convert.ToString(listFechasViajes[contador].fecha); editarViajeDiario.SetValue(Grid.ColumnProperty, col); editarViajeDiario.SetValue(Grid.RowProperty, row); this.fechasViajes.Children.Add(editarViajeDiario); } } contador++; } } // Fin TRY catch (Exception ex) { validar validarError = new validar(); validarError.show(ex.Message); } }