Beispiel #1
0
        private void populateHotelDataGridView(string name, string cidade, int[] categoria, bool[] restaurante)
        {
            MySqlDataAdapter da = adapter.hotelAdapter(name, cidade, categoria, restaurante);

            if (da != null)
            {
                DataTable dt = new DataTable();
                try
                {
                    da.Fill(dt);
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show("Ocorreu um erro \n", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Console.WriteLine($"Hotel Erro: \n{ex.Message}\n");
                }
                DataTable dtCloned = dt.Clone();
                dtCloned.Columns[3].DataType = typeof(Int64);
                foreach (DataRow row in dt.Rows)
                {
                    dtCloned.ImportRow(row);
                }

                dataGridViewHotel.DataSource = dtCloned;

                dataGridViewHotel.Columns[3].DefaultCellStyle.Format = "(##) # ####-####";

                dataGridViewHotel.Columns[0].HeaderText = "ID";
                dataGridViewHotel.Columns[1].HeaderText = "Nome";
                dataGridViewHotel.Columns[2].HeaderText = "Categoria";
                dataGridViewHotel.Columns[3].HeaderText = "Contato";
                dataGridViewHotel.Columns[4].HeaderText = "Tipo Endereço";
                dataGridViewHotel.Columns[5].HeaderText = "Logadouro";
                dataGridViewHotel.Columns[6].HeaderText = "Numero";
                dataGridViewHotel.Columns[7].HeaderText = "Complemento";
                dataGridViewHotel.Columns[8].HeaderText = "Bairro";
            }
            else
            {
                MessageBox.Show("Falha");
            }
        }