//function that runs if the update database button is clicked private void buttonUpdate_Click(object sender, RoutedEventArgs e) { //disables buttons and gives mouse waiting symbol Mouse.OverrideCursor = Cursors.Wait; circleAnimationUpdate.Opacity = 100; labelID.Text = "Updating Database..."; buttonScan.IsEnabled = false; buttonUpdate.IsEnabled = false; //pulls new sql data from databases backgroundWorker.DoWork += delegate(object s, DoWorkEventArgs args) { // Will be run on background thread SQLPuller sqlPuller = new SQLPuller(); sqlPuller.pullAuthorizedCheckers(); sqlPuller.pullEvents(); sqlPuller.pullStudents(); }; backgroundWorker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) { //enables buttons buttonUpdate.IsEnabled = true; buttonScan.IsEnabled = true; circleAnimationUpdate.Opacity = 0; //statements to display whether updates failed or succeeded if (MainWindow.AppWindow.getDatabaseUpdated() == true) { attendanceWriter.CreateDateTextFile(); labelID.Text = "Database Update Successful\n\nSign in with Gordon ID"; } else { labelID.Text = "Database Update Failed\n\nCheck Internet Connection"; } //give mouse normal cursor Mouse.OverrideCursor = null; }; backgroundWorker.RunWorkerAsync(); }
//function that runs if the update database button is clicked private void buttonUpdate_Click(object sender, RoutedEventArgs e) { //disables buttons and gives mouse waiting symbol Mouse.OverrideCursor = Cursors.Wait; circleAnimationUpdate.Opacity = 100; labelID.Text = "Updating Database..."; buttonScan.IsEnabled = false; buttonUpdate.IsEnabled = false; //pulls new sql data from databases backgroundWorker.DoWork += delegate (object s, DoWorkEventArgs args) { // Will be run on background thread SQLPuller sqlPuller = new SQLPuller(); sqlPuller.pullAuthorizedCheckers(); sqlPuller.pullEvents(); sqlPuller.pullStudents(); }; backgroundWorker.RunWorkerCompleted += delegate (object s, RunWorkerCompletedEventArgs args) { //enables buttons buttonUpdate.IsEnabled = true; buttonScan.IsEnabled = true; circleAnimationUpdate.Opacity = 0; //statements to display whether updates failed or succeeded if (MainWindow.AppWindow.getDatabaseUpdated() == true) { attendanceWriter.CreateDateTextFile(); labelID.Text = "Database Update Successful\n\nSign in with Gordon ID"; } else { labelID.Text = "Database Update Failed\n\nCheck Internet Connection"; } //give mouse normal cursor Mouse.OverrideCursor = null; }; backgroundWorker.RunWorkerAsync(); }