private void dgvViajes_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     vueloSeleccionado = (Model.ViajeRegistroLlegadaModel)dgvViajes.CurrentRow.DataBoundItem;
     btnRegistrar.Enabled = true;
     dpFechaLlegada.Enabled = true;
     dpFechaLlegada.Value = vueloSeleccionado.fechaLlegadaEstimada;
 }
Пример #2
0
        public List<Model.ViajeRegistroLlegadaModel> buscarViajes(int idRuta, String matricula, DateTime fechaSalidaFiltro)
        {
            List<Model.ViajeRegistroLlegadaModel> viajes = new List<Model.ViajeRegistroLlegadaModel>();
            Model.ViajeRegistroLlegadaModel viaje = null;
            SqlConnection myConnection = null;

            string fechaSalidaFormateado = fechaSalidaFiltro.ToString("dd/MM/yyyy");
            try
            {
                myConnection = new SqlConnection(stringConexion);
                myConnection.Open();
                SqlCommand command = null;
                var query = "select	v.viaje_id, v.fecha_salida, v.fecha_llegada_estimada " +
                            "from	mondongo.viajes v " +
                            "join mondongo.rutas r on r.id_ruta = v.viaje_ruta_id " +
                            "join mondongo.ruta_tipo_servicio rts on r.id_ruta = rts.id_ruta " +
                            "join mondongo.tipos_servicio ts on ts.id_tipo_servicio = rts.id_tipo_servicio " +
                            "where	r.id_ruta = @idRuta " +
                            "and v.aeronave_matricula = @matricula "+
                            "and CONVERT(VARCHAR(10),v.fecha_salida,103) = @fechaSalida " +
                            "and v.estado = 0 "+
                            "order by v.fecha_salida asc";
                using (command = new SqlCommand(query, myConnection))
                {
                    command.Parameters.AddWithValue("@idRuta", idRuta);
                    command.Parameters.AddWithValue("@matricula", matricula);
                    command.Parameters.AddWithValue("@fechaSalida", fechaSalidaFormateado);
                }
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {

                        var idViaje = (int)(double)reader.GetDecimal(0);
                        var fechaSalida = reader.GetDateTime(1);
                        var fechaLlegadaEstimada = reader.GetDateTime(2);

                        viaje = new Model.ViajeRegistroLlegadaModel(idViaje, fechaSalida, fechaLlegadaEstimada);
                        viajes.Add(viaje);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR" + ex.Message);
            }
            finally
            {
                myConnection.Close();
            }

            return viajes;
        }