private void DeleteTicketButton_Click(object sender, EventArgs e) { int selectedIndex = ResultGrid.CurrentCell.RowIndex; int ticketId = Convert.ToInt32(ResultGrid.Rows[selectedIndex].Cells["TicketIdCol"].Value); if (MessageBox.Show("This will delete ticket #" + ticketId + ". Are you sure?", "Delete Ticket", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { TicketRepository ticketRepo = new TicketRepository(); ticketRepo.DeleteTicketByTicketID(ticketId); TicketAlterationRepository alterationRepo = new TicketAlterationRepository(); alterationRepo.DeleteAlterationsByTicketID(ticketId); ResultGrid.Rows.RemoveAt(selectedIndex); } catch (Exception ex) { MessageBox.Show("There was an error. Please contact Jay with this message: " + ex.Message); } EnableButtonsBasedOnGrid(); } }