private void btGenerar_Viaje_Click(object sender, EventArgs e) { Regex datePattern = new Regex("^[0-9]{2}([/][0-9]{2}([/][0-9]{4}))?$"); Regex hourPattern = new Regex("^[0-9]{2}([:][0-9]{2}([:][0-9]{2}))?$"); if (!datePattern.IsMatch(this.txt_fsal.Text)) { MessageBox.Show("Formato de Fecha Salida incorrecto: \"DD/MM/AAAA\""); } else if (!datePattern.IsMatch(this.txt_flleg.Text)) { MessageBox.Show("Formato de Fecha Llegada incorrecto: \"DD/MM/AAAA\""); } else if (!hourPattern.IsMatch(txt_hsal.Text)) { MessageBox.Show("Formato de Hora Salida incorrecto: \"HH:MM:SS\""); } else if (!hourPattern.IsMatch(txt_hlleg.Text)) { MessageBox.Show("Formato de Hora Salida incorrecto: \"HH:MM:SS\""); } else if (validarFechaSalida()) { if (validarFechaLlegada()) { if (dgv_listado.Rows.Count == 0) { MessageBox.Show("No se encuentran cruceros disponibles"); } else { DateTime fechaHoraSalida = DateTime.Now; DateTime fechaHoraLlegada = DateTime.Now; String fechaHoraLlegadastr = String.Concat(txt_flleg.Text, " ", txt_hlleg.Text); String fechaHoraSalidastr = String.Concat(txt_fsal.Text, " ", txt_hsal.Text); String format = "G"; CultureInfo provider = new CultureInfo("fr-FR"); fechaHoraSalida = DateTime.ParseExact(fechaHoraSalidastr, format, provider); fechaHoraLlegada = DateTime.ParseExact(fechaHoraLlegadastr, format, provider); Viaje viaje = new Viaje(); viaje.cru_id = Convert.ToString(dgv_listado.CurrentRow.Cells[0].Value); viaje.rec_id = dgv_listado2.CurrentRow.Cells[0].Value.ToString(); viaje.fecha_salida = fechaHoraSalida; viaje.fecha_llegada = fechaHoraLlegada; ViajeFunc.CrearViaje(viaje); int via_id = ViajeFunc.ObtenerIDViaje(viaje); ViajeFunc.CrearCabinasViaje(via_id, viaje.cru_id); MessageBox.Show("Viaje creado"); this.Close(); } } } }
private void CargarComboPuerto() { SqlDataReader reader = ViajeFunc.ObtenerPuerto(); if (reader.HasRows) { while (reader.Read()) { Puerto puerto = new Puerto(); puerto.id = Convert.ToInt32(reader.GetDecimal(0)); puerto.nombre = reader.GetString(1); ComboboxItem item = new ComboboxItem(); item.Text = puerto.nombre; item.Value = puerto; cmb_pue_desde.Items.Add(item); cmb_pue_hasta.Items.Add(item); } } reader.Close(); }
private void bt_buscar_Click(object sender, EventArgs e) { if (ValidarCamposVacios()) { MessageBox.Show("Seleccionar puerto desde y hasta"); } else { ComboboxItem item = new ComboboxItem(); Puerto puertoDesde = new Puerto(); Puerto puertoHasta = new Puerto(); if (cmb_pue_desde.SelectedItem != null) { item = (ComboboxItem)cmb_pue_desde.SelectedItem; puertoDesde = (Puerto)item.Value; } if (cmb_pue_hasta.SelectedItem != null) { item = (ComboboxItem)cmb_pue_hasta.SelectedItem; puertoHasta = (Puerto)item.Value; } DateTime fechaDesde = DateTime.Now; fechaDesde = dtpDe.Value; fechaDesde = ChangeTime(fechaDesde, 0, 0, 0, 0); DateTime fechaHasta = DateTime.Now; fechaHasta = dtpHasta.Value; fechaHasta = ChangeTime(fechaHasta, 23, 59, 59, 0); dgv_viaje.DataSource = ViajeFunc.ListarViaje(puertoDesde.id, puertoHasta.id, fechaDesde, fechaHasta).Tables[0]; dgv_viaje.Columns[0].Visible = false; dgv_viaje.Columns[4].Visible = false; } }
private void btBuscarRecorrido_Click(object sender, EventArgs e) { dgv_listado2.DataSource = ViajeFunc.ListarRecorrido(txt_puerto_desde.Text.Trim(), txt_puerto_hasta.Text.Trim()).Tables[0]; }
public FormGenerarViaje() { InitializeComponent(); dgv_listado2.DataSource = ViajeFunc.ListarRecorrido("", "").Tables[0]; }