Ejemplo n.º 1
0
        public void CreateMovie()
        {
            string title = txtTitle.Text;
            int genre_id = 0;
            string genre_name = "";
            int country_id = 0;
            string country_name = "";
            int language_id = 0;
            string language_name = "";

            try
            {
                ComboBoxItem comboBoxItem = (ComboBoxItem)cbBoxGenre.SelectedItem;
                genre_id = comboBoxItem.HiddenValue;
                genre_name = comboBoxItem.DisplayValue;
                lblGenreFault.Text = "";
            }
            catch (Exception)
            {
                genre_id = 0;
                lblGenreFault.Text = "Please choose a valid Genre";

            }
            
            try
            {
                ComboBoxItem comboBoxItem = (ComboBoxItem)cbBoxCountry.SelectedItem;
                country_id = comboBoxItem.HiddenValue;
                country_name = comboBoxItem.DisplayValue;
                lblCountryFault.Text = "";
            }
            catch (Exception)
            {
                country_id = 0;
                lblCountryFault.Text = "Please choose a valid Country";
            }
            
            try
            {
                ComboBoxItem comboBoxItem = (ComboBoxItem)cbBoxLanguage.SelectedItem;
                language_id = comboBoxItem.HiddenValue;
                language_name = comboBoxItem.DisplayValue;
                lblLanguageFault.Text = "";
            }
            catch (Exception)
            {
                language_id = 0;
                lblLanguageFault.Text = "Please choose a valid Language";
            }
            
            string storyline = txtStoryline.Text;
            string filmingLocation = txtFilmingLocation.Text;
            string information = txtInformation.Text;
            bool isMovie = true;
            if (title != "" && storyline != "" && information != "" && filmingLocation !="" && genre_id > 0 && country_id > 0 && language_id > 0)
            {
                try
                {
                    DateTime date = DateTime.ParseExact(txtReleaseDate.Text, "dd-MM-yyyy", null);

                    DC.InsertMovieIntoEntertainment(genre_id, genre_name, title, country_id, country_name, language_id, language_name, date, storyline, filmingLocation, information, isMovie);
                    ClearMovie();
                    MessageBox.Show("Your movie is saved!");
                }
                catch (Exception)
                {
                    lblDateFormat.Text = "Date format is not correctly written: dd-MM-yyyy";
                }
            }
            else
            {
                MessageBox.Show("Please fill all information!");
            }

        }