/// <summary>
/// Handles the Click event of the btnDelete control. Deletes all the specified Team Box Score, as well as any corresponding
/// Player Box Scores, from the database.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">
/// The <see cref="RoutedEventArgs" /> instance containing the event data.
/// </param>
private void btnDelete_Click(object sender, RoutedEventArgs e)
{
var r =
MessageBox.Show(
"Are you sure you want to delete this/these box score(s)?\n" + "This action cannot be undone.\n\n"
+ "Any changes made to Team Stats by automatically adding this/these box score(s) to them won't be reverted by its deletion.",
"NBA Stats Tracker",
MessageBoxButton.YesNo);
if (r == MessageBoxResult.Yes)
{
foreach (var bse in dgvBoxScores.SelectedItems.Cast <BoxScoreEntry>().ToList())
{
if (bse != null)
{
var id = bse.BS.ID;
_db.Delete("GameResults", "GameID = " + id);
_db.Delete("PlayerResults", "GameID = " + id);
}
_bsHist.Remove(bse);
MainWindow.BSHist.Remove(bse);
}
}
}