Exemplo n.º 1
0
        private void btnVideoUpdate_Click(object sender, EventArgs e)
        {
            var video = txtVideoName.Text;

            if (string.IsNullOrWhiteSpace(video)|| (nmrDaysToBeRent.Value == 0))
            {
                MessageBox.Show("Please enter valid Video name.", "Error Message");
                txtVideoName.Clear();
                txtVideoName.Focus();
            }
            else
            {
                try
                {
                    var booking = new Booking(database);
                    var result = booking.UpdateVideo(((Video)cboVideoVideo.SelectedItem).Id,
                                                    ((Genre) cboVideoGenre.SelectedItem).Id,
                                                    txtVideoName.Text,
                                                    Convert.ToInt16(nmrDaysToBeRent.Value));
                    if (result)
                    {
                        cboVideoVideo.DataSource = booking.GetVideo().ToList();
                        cboVideoVideo.DisplayMember = "Name";
                        txtVideoName.Clear();

                        cboVideoGenre.DataSource = booking.GetGenre().ToList();
                        cboVideoGenre.DisplayMember = "Name";
                        //cboVideoGenre.SelectedText= ((Video)cboVideoVideo.SelectedItem).GenreId

                        FillBookingList();
                        FillAvailableVideoList();

                    }
                }
                catch (VideoRentalException ex)
                {
                    MessageBox.Show(String.Format("Error occured: {0} is not updated succesfully", ex.Item.Name));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Error Occoured:  {0}", ex.Message));
                }

            }
        }