Beispiel #1
0
 public void RefreshTable()
 {
     lblNoTable.Visible = false;
     try
     {
         chosenId = -1;
         NpgsqlDataReader dataReader = PgSql.SelectTable(currTable, currTableStringName, filterString);
         //PgSql.SelectAllFromWhere(currTableStringName, filterString);
         dataGridView.RowCount    = 0;
         dataGridView.ColumnCount = dataReader.FieldCount;
         int  row = 0;
         bool collumnsLocalized = false;
         while (dataReader.Read())
         {
             int cell = 0;
             dataGridView.RowCount++;
             for (int i = 0; i < dataReader.FieldCount; i++)
             {
                 if (!collumnsLocalized)
                 {
                     dataGridView.Columns[i].HeaderText = StringHelper.Localize(dataReader.GetName(i), currTable);
                 }
                 dataGridView.Rows[row].Cells[cell].Value = dataReader[i].ToString();
                 cell++;
             }
             collumnsLocalized = true;
             dataGridView.Rows[row].HeaderCell.Value = (row + 1).ToString();
             row++;
         }
         dataGridView_SelectionChanged();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         lblNoTable.Visible = true;
         dataGridView.Rows.Clear();
         dataGridView.Refresh();
     }
 }