/// <summary> /// Busca los datos del vuelo /// </summary> /// <param name="id"></param> /// <returns></returns> public BoletoVuelo MBuscarDatosVuelo(int id) { BoletoVuelo vuelo = null; try { SqlConnection con = new SqlConnection(_connexionString); con.Open(); String sql = "SELECT vue_fecha_despegue, vue_fecha_aterrizaje, vue_fk_ruta FROM Vuelo WHERE vue_id =" + id + ""; System.Diagnostics.Debug.WriteLine(sql); SqlCommand cmd = new SqlCommand(sql, con); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { RutaBoleto rut = MBuscarDatosRuta(Int32.Parse(reader["vue_fk_ruta"].ToString())); vuelo = new BoletoVuelo(id, reader.GetDateTime(reader.GetOrdinal("vue_fecha_despegue")), reader.GetDateTime(reader.GetOrdinal("vue_fecha_aterrizaje")), Int32.Parse(reader["vue_fk_ruta"].ToString()), rut._origen, rut._destino, rut._nomOrigen, rut._nomDestino); } } cmd.Dispose(); con.Close(); return(vuelo); } catch (SqlException) { return(vuelo); } }
/// <summary> /// Busca los datos de la ruta del vuelo /// </summary> /// <param name="id"></param> /// <returns></returns> public RutaBoleto MBuscarDatosRuta(int id) { RutaBoleto ruta = null; try { SqlConnection con = new SqlConnection(_connexionString); con.Open(); String sql = "SELECT rut_FK_lugar_origen, rut_FK_lugar_destino FROM Ruta WHERE rut_id =" + id + ""; System.Diagnostics.Debug.WriteLine(sql); SqlCommand cmd = new SqlCommand(sql, con); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { ruta = new RutaBoleto(id, Int32.Parse(reader["rut_FK_lugar_origen"].ToString()), Int32.Parse(reader["rut_FK_lugar_destino"].ToString()), MBuscarnombreciudad(Int32.Parse(reader["rut_FK_lugar_origen"].ToString())), MBuscarnombreciudad(Int32.Parse(reader["rut_FK_lugar_destino"].ToString()))); } } cmd.Dispose(); con.Close(); return(ruta); } catch (SqlException) { return(ruta); } }