private async void btnDeleteAcademic_Click(object sender, RoutedEventArgs e) { // Delete confirmation if (selectedAcademic != null) { ContentDialog notifyDelete = new ContentDialog() { Title = "Confirm Academic Record Delete?", Content = "Are you sure you wish to delete academic record for " + selectedAcademic.EntryDate.ToShortDateString() + "?", PrimaryButtonText = "Delete Record", SecondaryButtonText = "Cancel" }; ContentDialogResult result = await notifyDelete.ShowAsync(); if (result == ContentDialogResult.Primary) { // Delete AcademicDataService.DeleteAcademic(selectedAcademic); // Somehow update the display LoadOrphansAsync(); } else { // User pressed Cancel or the back arrow. } } }
private void btnSave_Click(object sender, RoutedEventArgs e) { Academic outAcademic = new Academic(); if (!isNew) { outAcademic = InAcademic; } if (!isNew) { outAcademic.AcademicID = InAcademic.AcademicID; } outAcademic.OrphanID = InOrphan.OrphanID; outAcademic.EntryDate = dtEntryDate.Date.Value.DateTime; outAcademic.Grade = txtGrade.Text; outAcademic.KCPE = txtKCPE.Text; outAcademic.KCSE = txtKCSE.Text; outAcademic.School = txtSchool.Text; // Make sure you validate the above stuff...blows up otherwise. if (isNew) { // Update to Database AcademicDataService.AddAcademic(outAcademic); } else { // Go get the one of interest, then overwrite. // Update to Database AcademicDataService.SaveAcademic(InOrphan.OrphanID, outAcademic); } // Close the page OrphanMasterDetailPage.contentAcademic.Hide(); }