Rock.Apps.CheckScannerUtility.BatchPage.btnDeleteBatch_Click C# (CSharp) Méthode

btnDeleteBatch_Click() private méthode

Handles the Click event of the btnDeleteBatch control.
private btnDeleteBatch_Click ( object sender, RoutedEventArgs e ) : void
sender object The source of the event.
e System.Windows.RoutedEventArgs The instance containing the event data.
Résultat void
        private void btnDeleteBatch_Click( object sender, RoutedEventArgs e )
        {
            if ( MessageBox.Show( "Are you sure you want to delete this batch and all of its transactions?", "Confirm", MessageBoxButton.OKCancel ) == MessageBoxResult.OK )
            {
                try
                {
                    if ( this.SelectedFinancialBatch != null )
                    {
                        RockConfig config = RockConfig.Load();
                        RockRestClient client = new RockRestClient( config.RockBaseUrl );
                        client.Login( config.Username, config.Password );

                        var transactions = grdBatchItems.DataContext as BindingList<FinancialTransaction>;
                        if ( transactions != null )
                        {
                            foreach ( var transaction in transactions )
                            {
                                client.Delete( string.Format( "api/FinancialTransactions/{0}", transaction.Id ) );
                            }
                        }

                        client.Delete( string.Format( "api/FinancialBatches/{0}", this.SelectedFinancialBatch.Id ) );
                    }
                }
                catch ( Exception ex )
                {
                    ShowException( ex );
                }

                LoadFinancialBatchesGrid();
            }
        }