private void btnVideoDelete_Click(object sender, EventArgs e) { string video = txtVideoName.Text; if (string.IsNullOrWhiteSpace(video)) { MessageBox.Show("Please select Video from list.", "Error Message"); txtVideoName.Clear(); txtVideoName.Focus(); } else { try { var booking = new Booking(database); var result = booking.DeleteVideo((Video)cboVideoVideo.SelectedItem); if (result) { cboVideoVideo.DataSource = booking.GetVideo().ToList(); cboVideoVideo.DisplayMember = "Name"; txtVideoName.Clear(); cboVideoGenre.DataSource = booking.GetGenre().ToList(); cboVideoGenre.DisplayMember = "Name"; FillAvailableVideoList(); } else { MessageBox.Show("Deletion not succesfull."); } } catch (VideoRentalException ex) { MessageBox.Show(String.Format("Error Occured: {0} is not deleted succesfully", ex.Item.Name)); } catch (Exception ex) { MessageBox.Show(string.Format("Error Occoured: {0}",ex.Message)); } } }