Example #1
0
        private void btnAddMovie_Click(object sender, RoutedEventArgs e)
        {
            if (!this.isUploaded)
            {
                MessageBox.Show("First, you must upload the image!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                int year = 0;

                if (!int.TryParse(this.txtYear.Text, out year))
                {
                    MessageBox.Show("Your input for year is not a number!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                int duration = 0;

                if (!int.TryParse(this.txtDuration.Text, out duration))
                {
                    MessageBox.Show("Your input for duration is not a number!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                Movie movie = new Movie(this.txtName.Text, this.txtDescription.Text, this.txtGenre.Text, year,
                                        duration, this.txtActors.Text, this.txtDirector.Text, this.poster, this.txtTrailer.Text);

                if (AdminQuery.AddMovie(movie))
                {
                    MessageBox.Show("Movie was added successfully", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                    MainWindow mainWindow = StartWindow.GetMainWindow(this);
                    mainWindow.movies.moviesContainer.Children.Clear();
                    mainWindow.movies.LoadMovies();
                    mainWindow.movies.InsertAddButton();

                    mainWindow.movieInformation.FillInformation(movie.Name);
                    this.Visibility = Visibility.Hidden;
                    mainWindow.movieInformation.Visibility = Visibility.Visible;
                    this.ClearFields();
                }
            }
        }