/// <summary> /// Handles the Delete event of the gBatchList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param> protected void gBatchList_Delete( object sender, RowEventArgs e ) { var rockContext = new RockContext(); FinancialBatchService financialBatchService = new FinancialBatchService( rockContext ); FinancialBatch financialBatch = financialBatchService.Get( e.RowKeyId ); if ( financialBatch != null ) { string errorMessage; if ( !financialBatchService.CanDelete( financialBatch, out errorMessage ) ) { mdGridWarning.Show( errorMessage, ModalAlertType.Information ); return; } financialBatchService.Delete( financialBatch ); rockContext.SaveChanges(); } BindGrid(); }
/// <summary> /// Handles the Delete event of the gBatchList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param> protected void gBatchList_Delete( object sender, RowEventArgs e ) { var rockContext = new RockContext(); var batchService = new FinancialBatchService( rockContext ); var batch = batchService.Get( e.RowKeyId ); if ( batch != null ) { if ( UserCanEdit || batch.IsAuthorized( Rock.Security.Authorization.EDIT, CurrentPerson ) ) { string errorMessage; if ( !batchService.CanDelete( batch, out errorMessage ) ) { mdGridWarning.Show( errorMessage, ModalAlertType.Information ); return; } batchService.Delete( batch ); rockContext.SaveChanges(); } } BindGrid(); }
/// <summary> /// Handles the Delete event of the gBatchList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param> protected void gBatchList_Delete( object sender, RowEventArgs e ) { var rockContext = new RockContext(); var batchService = new FinancialBatchService( rockContext ); var batch = batchService.Get( e.RowKeyId ); if ( batch != null ) { if ( UserCanEdit || batch.IsAuthorized( Rock.Security.Authorization.EDIT, CurrentPerson ) ) { string errorMessage; if ( !batchService.CanDelete( batch, out errorMessage ) ) { mdGridWarning.Show( errorMessage, ModalAlertType.Information ); return; } rockContext.WrapTransaction( () => { HistoryService.SaveChanges( rockContext, typeof( FinancialBatch ), Rock.SystemGuid.Category.HISTORY_FINANCIAL_BATCH.AsGuid(), batch.Id, new List<string> { "Deleted the batch" } ); batchService.Delete( batch ); rockContext.SaveChanges(); } ); } } BindGrid(); }