//actions to take when deleting booking private void btnDelete_Click(object sender, RoutedEventArgs e) { var result = MessageBox.Show("Are you sure you want to delete this booking?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { bookingInUse.CustomerOwner.Bookings.Remove(bookingInUse.CustomerOwner.Bookings.Find(booking => booking.Equals(bookingInUse))); dbAccess.deleteEntry(bookingInUse); //refreshing main window's result after this operation mainWindow = (MainWindow)this.Owner; mainWindow.btnBookSearch_Click(sender, e); this.Close(); } }
//when we want to delete our customer file writer will do that for us private void btnDelete_Click(object sender, RoutedEventArgs e) { var result = MessageBox.Show("Are you sure you want to delete this customer?", "Confirmation", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { //preventing delete customer if there are any bookings in future if (lstFutureBookings.Items.Count > 0) { MessageBox.Show("Customer has planned booking. Unable to delete.", "Planned Bookings", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { dbAccess.deleteEntry(customerInUse); //refreshing customer search results to contain valid data mainWindow = (MainWindow)this.Owner; mainWindow.btnCustSearch_Click(sender, e); this.Close(); } } }