private void DeleteClick(object sender, RoutedEventArgs e) { var messageBoxResult = MessageBox.Show("Are you sure you want to delete the selected entries?", "Delete Confirmation", MessageBoxButton.YesNo); if (messageBoxResult != MessageBoxResult.Yes) { return; } Delete.IsEnabled = false; if (CurrentCharges.SelectedItems.Count == 0) { return; } var bgWorker = new BackgroundWorker(); var epicor = new Epicor(Settings.Default.ResourceID); var times = CurrentCharges.SelectedItems.OfType <Time>(); bgWorker.DoWork += (o, args) => { epicor.SaveTimes(times, TimeStates.Deleted); Dispatcher.BeginInvoke(DispatcherPriority.Background, new ThreadStart(() => { Delete.IsEnabled = true; Messages.Text = "Deleted Successfully"; InitializeCurrentCharges(); })); }; bgWorker.RunWorkerAsync(); }
private void ApproveClick(object sender, RoutedEventArgs e) { Approve.IsEnabled = false; if (CurrentCharges.SelectedItems.Count == 0) { return; } var bgWorker = new BackgroundWorker(); var epicor = new Epicor(Settings.Default.ResourceID); var times = CurrentCharges.SelectedItems.OfType <Time>(); bgWorker.DoWork += (o, args) => { epicor.SaveTimes(times, TimeStates.Modified); Dispatcher.BeginInvoke(DispatcherPriority.Background, new ThreadStart(() => { Approve.IsEnabled = true; Messages.Text = "Marked for Approval Successfully"; InitializeCurrentCharges(); })); }; bgWorker.RunWorkerAsync(); }