private void binds() { GetDataFromTable tsd = new GetDataFromTable(); DataTable tds = tsd.GetAllDataFromtblAdministrator(); rpItem.DataSource = tds; rpItem.DataBind(); }
private async void BTNCreteDBTable_Click(object sender, RoutedEventArgs e) { HeaderCreator headerCreator = new HeaderCreator(filePath); HeaderLV.Items.Clear(); List <string> header = headerCreator.CreateHeader(); foreach (string line in header) { HeaderLV.Items.Add(line); } try { string connectionString = DBConnectionString.Text; RecordFactory creator = new RecordFactory(filePath); CreateTableInDB tableCreator = new CreateTableInDB(connectionString); await tableCreator.CreateTable(@"If not exists (select name from sysobjects where name = 'Precipitation') CREATE TABLE Precipitation (Xref int, Yref int, Date date, Value int);"); var ATimer = new System.Windows.Threading.DispatcherTimer(); ATimer.Tick += ATimer_Tick; ATimer.Interval = new TimeSpan(0, 0, 0, 1); ATimer.Start(); InsertRecordToDBTable recordInsert = new InsertRecordToDBTable(connectionString); while (creator.EndOfFile == false) { await recordInsert.InsertRecordToTable(creator.GetNextRecord()); } ATimer.Stop(); MessageBox.Show("Finished adding records to DB."); recordInsert.CloseConnection(); GetDataFromTable getData = new GetDataFromTable(connectionString); await getData.GetData("SELECT * FROM Precipitation ORDER BY Xref, Yref, Date ASC"); while (getData.reader.Read()) { var data = new Record((int)getData.reader["Xref"], (int)getData.reader["Yref"], (DateTime)getData.reader["Date"], (int)getData.reader["Value"]); GeneratedTable.Items.Add(data); } getData.CloseConnection(); } catch (ArgumentException ex) { MessageBox.Show(ex.Message); } catch (InvalidOperationException ex) { MessageBox.Show(ex.Message); } }