//this method will charge the information on the combobox public void llenarCombo(ComboBox combo, string consulta) { bd.Conexion(); ConexionBD.conexion.Open(); NpgsqlCommand cmd = new NpgsqlCommand(consulta, ConexionBD.conexion); NpgsqlDataReader reader = cmd.ExecuteReader(); try { while (reader.Read()) { combo.Items.Add(reader.GetString(0)); } } finally { reader.Close(); cmd.Dispose(); ConexionBD.conexion.Close(); } }
//this method will charge the information on the table public void MostrarDatosconcombo(DataGridView data) { bd.Conexion(); ConexionBD.conexion.Open(); NpgsqlCommand cmd = new NpgsqlCommand("SELECT * FROM aeropuerto", ConexionBD.conexion); NpgsqlDataReader reader = cmd.ExecuteReader(); try { while (reader.Read()) { data.Rows.Add(reader.GetInt32(0), reader.GetString(1), reader.GetString(3), reader.GetString(2)); } } finally { reader.Close(); cmd.Dispose(); ConexionBD.conexion.Close(); } data.Refresh(); data.ClearSelection(); }
//this method will charge the information on the combobox public void cargarCombo(ComboBox combo) { bd.Conexion(); ConexionBD.conexion.Open(); NpgsqlCommand cmd = new NpgsqlCommand("SELECT nombre FROM pais", ConexionBD.conexion); NpgsqlDataReader reader = cmd.ExecuteReader(); try { while (reader.Read()) { combo.Items.Add(reader.GetString(0)); } } finally { reader.Close(); cmd.Dispose(); ConexionBD.conexion.Close(); } }
//this method will show the first report public ArrayList cantidad() { ArrayList canti = new ArrayList(); bd.Conexion(); ConexionBD.conexion.Open(); NpgsqlCommand cmd = new NpgsqlCommand("SELECT COUNT(r.hotel), h.nombre FROM reserva AS r JOIN hotel AS h on h.nombre = r.hotel WHERE r.hotel = h.nombre GROUP BY h.nombre;", ConexionBD.conexion); NpgsqlDataReader reader = cmd.ExecuteReader(); try { while (reader.Read()) { canti.Add(reader.GetString(0)); } } finally { reader.Close(); cmd.Dispose(); ConexionBD.conexion.Close(); } return(canti); }