/// <summary> /// Handles the Delete event of the gNoteTypes 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 gNoteTypes_Delete(object sender, RowEventArgs e) { using (var rockContext = new RockContext()) { var service = new NoteTypeService(rockContext); var noteType = service.Get(e.RowKeyId); if (noteType != null && !noteType.IsSystem) { string errorMessage = string.Empty; if (service.CanDelete(noteType, out errorMessage)) { int noteTypeId = noteType.Id; service.Delete(noteType); rockContext.SaveChanges(); } else { mdGridWarning.Show(errorMessage, ModalAlertType.Information); } } } BindFilter(); BindGrid(); }
/// <summary> /// Handles the Delete event of the rGrid 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 rGrid_Delete(object sender, RowEventArgs e) { using (var rockContext = new RockContext()) { var service = new NoteTypeService(rockContext); var noteType = service.Get(e.RowKeyId); if (noteType != null) { string errorMessage = string.Empty; if (service.CanDelete(noteType, out errorMessage)) { int id = noteType.Id; service.Delete(noteType); rockContext.SaveChanges(); NoteTypeCache.Flush(id); NoteTypeCache.FlushEntityNoteTypes(); } else { nbMessage.Text = errorMessage; nbMessage.Visible = true; } } } BindFilter(); BindGrid(); }
/// <summary> /// Handles the Delete event of the rGrid 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 rGrid_Delete( object sender, RowEventArgs e ) { using ( var rockContext = new RockContext() ) { var service = new NoteTypeService( rockContext ); var noteType = service.Get( e.RowKeyId ); if ( noteType != null ) { string errorMessage = string.Empty; if ( service.CanDelete( noteType, out errorMessage ) ) { int id = noteType.Id; service.Delete( noteType ); rockContext.SaveChanges(); NoteTypeCache.Flush( id ); NoteTypeCache.FlushEntityNoteTypes(); } else { nbMessage.Text = errorMessage; nbMessage.Visible = true; } } } BindFilter(); BindGrid(); }