/// <summary> /// This method charge all information of database in datagridview /// </summary> /// <param name="dataGridView1"></param> public void Cargar_Data_Grid(DataGridView dataGridView1) { DB_CRUD_Hoteles db_hoteles = new DB_CRUD_Hoteles(); NpgsqlConnection conn = db_hoteles.Conexion(); conn.Open(); DataSet dataSet = new DataSet(); NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(select, conn); adapter.Fill(dataSet, "Hoteles"); dataGridView1.DataSource = dataSet.Tables[0]; dataGridView1.Columns[0].HeaderCell.Value = "Identificacion Hotel"; dataGridView1.Columns[1].HeaderCell.Value = "Nombre Hotel"; dataGridView1.Columns[2].HeaderCell.Value = "Lugar"; dataGridView1.Columns[3].HeaderCell.Value = "Habitaciones"; dataGridView1.Columns[4].HeaderCell.Value = "Precio"; DataGridViewImageColumn imgCol = new DataGridViewImageColumn(); imgCol.HeaderText = "Foto Hotel"; imgCol.Name = "Foto Hotel"; dataGridView1.Columns.Add(imgCol); dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; //dataGridView1.Rows.RemoveAt((dataGridView1.RowCount - 1)); conn.Close(); }
/// <summary> /// This method charge with countries the combobox /// </summary> /// <param name="cbPaises"></param> public void Cargar_Combobox(ComboBox cbPaises) { DB_CRUD_Hoteles db_hoteles = new DB_CRUD_Hoteles(); NpgsqlConnection conn = db_hoteles.Conexion(); NpgsqlDataReader dr = null; try { conn.Open(); cmd = new NpgsqlCommand("SELECT nombre_pais FROM paises;", conn); dr = cmd.ExecuteReader(); while (dr.Read()) { cbPaises.Items.Add(dr[0].ToString()); } dr.Close(); conn.Close(); } catch (Exception ex) { dr.Close(); conn.Close(); Console.WriteLine("asa" + ex); } }
/// <summary> /// This method charge the datagridview with places /// </summary> /// <param name="dataGridView1"></param> public void Cargar_Data_Grid(DataGridView dataGridView1) { DB_CRUD_Hoteles db_hoteles = new DB_CRUD_Hoteles(); NpgsqlConnection conn = db_hoteles.Conexion(); conn.Open(); DataSet dataSet = new DataSet(); NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(select, conn); adapter.Fill(dataSet, "Lugar"); dataGridView1.DataSource = dataSet.Tables[0]; dataGridView1.Columns[0].HeaderCell.Value = "Identificacion Lugar"; dataGridView1.Columns[1].HeaderCell.Value = "Nombre Lugar"; dataGridView1.Columns[2].HeaderCell.Value = "Pais"; dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; conn.Close(); }
/// <summary> /// This method charge with flights the datagridview /// </summary> /// <param name="dataGridView1"></param> public void Cargar_Data_Grid(DataGridView dataGridView1) { DB_CRUD_Hoteles db_hoteles = new DB_CRUD_Hoteles(); NpgsqlConnection conn = db_hoteles.Conexion(); conn.Open(); DataSet dataSet = new DataSet(); NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(select, conn); adapter.Fill(dataSet, "Lugar"); dataGridView1.DataSource = dataSet.Tables[0]; dataGridView1.Columns[0].HeaderCell.Value = "Identificacion Tarifa Vuelo"; dataGridView1.Columns[1].HeaderCell.Value = "Ruta del vuelo"; dataGridView1.Columns[2].HeaderCell.Value = "Precio"; dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; // dataGridView1.Rows.RemoveAt((dataGridView1.RowCount - 1)); conn.Close(); }
/// <summary> /// This method search the flags of the countries /// </summary> /// <returns>And return them</returns> public List <object> Cargar_Bandera() { List <object> list = new List <object>(); DB_CRUD_Hoteles db_hoteles = new DB_CRUD_Hoteles(); NpgsqlConnection conn = db_hoteles.Conexion(); NpgsqlDataReader dr; NpgsqlCommand cmd; try { conn.Open(); cmd = new NpgsqlCommand("SELECT foto_hotel FROM hoteles ORDER BY id_hotel ASC;", conn); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { list.Add(dr.GetString(0)); } return(list); } else { return(null); } } catch (Exception ex) { Console.WriteLine(ex); return(null); } finally { conn.Close(); } }