private void btnVideoAdd_Click(object sender, EventArgs e) { string video = txtVideoName.Text; if (string.IsNullOrWhiteSpace(video) || (nmrDaysToBeRent.Value == 0)) { MessageBox.Show(string.Format("Please enter valid Video name or Number of days to be rented.","Error Message")); txtVideoName.Focus(); } else { try { var booking = new Booking(database); var result = booking.AddVideo(((Genre) cboVideoGenre.SelectedItem).Id, txtVideoName.Text, Convert.ToInt16(nmrDaysToBeRent.Value)); if (result) { cboVideoVideo.DataSource = booking.GetVideo().ToList(); cboVideoVideo.DisplayMember = "Name"; txtVideoName.Clear(); FillBookingList(); FillAvailableVideoList(); } else { MessageBox.Show(txtVideoName.Text + " video already exists."); } } catch (VideoRentalException ex) { MessageBox.Show(String.Format("Error occured: {0} is not added succesfully", ex.Item.Name)); } catch (Exception ex) { MessageBox.Show(string.Format("Error Occoured: {0}", ex.Message)); } } }