/// <summary>
        /// Adds a new rating and comment to the database for the selected movie.
        /// </summary>
        private void AddRating()
        {
            //Variable Declarations.
            LimelightBusiness business = new LimelightBusiness(repository);

            try
            {
                //Insert the new movie review.
                business.AddRating((int)cmbRating.SelectedValue, (int)lstMovieList.SelectedValue, txtComment.Text);

                //Refresh the list of movies.
                movies = business.GetAllMovies();
            }
            catch (Exception ex)
            {
                //Handle the exception.
                ApplicationUtilities.CatchExceptions(ex);
                return;
            }

            //Re-display the movie information on the form.
            DisplayMovieInfo();

            cmbRating.SelectedIndex = 0;
            txtComment.Text         = "";
        }
        /// <summary>
        /// Fills the ratings combobox with the various rating levels.
        /// </summary>
        private void FillRatingsList()
        {
            //Variable Declarations.
            DataSet           movieRatings;
            LimelightBusiness business = new LimelightBusiness(repository);

            //Get the movie titles from the database.
            try
            {
                movieRatings = business.GetAllRatingTitles();
            }
            catch (Exception ex)
            {
                ApplicationUtilities.CatchExceptions(ex);
                return;
            }

            //Add the genre titles to the ratings combobox.
            DataRow emptyDataRow = movieRatings.Tables[0].NewRow();

            emptyDataRow[0] = 0;
            emptyDataRow[1] = "Select A Rating";
            movieRatings.Tables[0].Rows.InsertAt(emptyDataRow, 0);


            cmbRating.DataSource    = movieRatings.Tables[0];
            cmbRating.ValueMember   = "RatingID";
            cmbRating.DisplayMember = "RatingTitle";
        }
        private void ViewRecords_Load(object sender, EventArgs e)
        {
            //Variable Declarations.
            LimelightBusiness business = new LimelightBusiness(repository);

            //Fill the list of movies and reviews.
            try
            {
                movies = business.GetAllMovies();
            }
            catch (Exception ex)
            {
                ApplicationUtilities.CatchExceptions(ex);
                return;
            }

            //Fill the movie titles listbox.
            FillMovieList();
            lstMovieList.SelectedIndex = -1;

            //Fill the ratings combobox.
            FillRatingsList();

            //Clear the controls on the form.
            ResetForm();
        }
        /// <summary>
        /// Adds the information about the new movie to the database.
        /// </summary>
        private void AddNewMovie()
        {
            //Variable Declarations.
            Movie             newMovie = new Movie();
            LimelightBusiness business = new LimelightBusiness(repository);

            //Take the image from the picture box and store in a byte array.
            MemoryStream ms = new MemoryStream();

            pbMoviePoster.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            byte[] moviePoster = ms.GetBuffer();

            //Set the information entered by the user into a movie object.
            newMovie.Title       = txtMovieTitle.Text;
            newMovie.Synopsis    = txtMovieSynopsis.Text;
            newMovie.ReleaseDate = dtpReleaseDate.Value;
            newMovie.GenreID     = (int)cmbGenre.SelectedValue;

            //Insert the new movie information into the database.
            try
            {
                //Insert the new movie information into the database.
                business.AddMovie(newMovie, moviePoster);

                //Tell the user the information was added successfully.
                MessageBox.Show("The Information has been Added Successfully!!");
            }
            catch (Exception ex)
            {
                //Handle an exceptions thrown.
                throw ex;
            }
        }
        /// <summary>
        /// Deletes the selected movie from the database.
        /// </summary>
        private void DeleteAMovie()
        {
            //Variable Declarations.
            LimelightBusiness business = new LimelightBusiness(repository);

            try
            {
                //Delete the selected movie.
                business.DeleteMovie((int)lstMovieList.SelectedValue);
            }
            catch (Exception ex)
            {
                //Handle the exception.
                ApplicationUtilities.CatchExceptions(ex);
            }
        }
        /// <summary>
        /// Fills the movie listbox with a list of titles for all movies in the database.
        /// </summary>
        private void FillMovieList()
        {
            //Variable Declarations.
            DataSet movieTitles;
            //AccessRepository repository = new AccessRepository();
            LimelightBusiness business = new LimelightBusiness(repository);

            //Get the movie titles from the database.
            //using (repositoy)
            //{
            //    movieTitles = repository.GetAllMovieTitles();
            //}
            movieTitles = business.GetAllMovieTitles();

            lstMovieList.DataSource    = movieTitles.Tables[0];
            lstMovieList.ValueMember   = "MovieID";
            lstMovieList.DisplayMember = "Title";
        }
        /// <summary>
        /// Updates the movie information in the database.
        /// </summary>
        private void UpdateMovieInfo()
        {
            //Variable Declarations.
            //AccessRepository repository = new AccessRepository();
            LimelightBusiness business = new LimelightBusiness(repository);

            //Find the movie information based on the ID value of the movie title selected.
            foreach (Movie movie in movies)
            {
                //Check the movie object with the matching MovieID.
                if (movie.MovieID == (int)lstMovieList.SelectedValue)
                {
                    //Update the information for the movie selected in the movie list.
                    movie.Title       = txtMovieTitle.Text;
                    movie.Synopsis    = txtMovieSynopsis.Text;
                    movie.ReleaseDate = dtpReleaseDate.Value;
                    movie.GenreID     = (int)cmbGenre.SelectedValue;
                    movie.GenreTitle  = cmbGenre.Text;
                    movie.MoviePoster = new Bitmap(pbMoviePoster.Image);

                    //Take the image from the picture box and store in a byte array.
                    MemoryStream ms = new MemoryStream();
                    pbMoviePoster.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                    byte[] moviePoster = ms.GetBuffer();

                    //Update the movie info.
                    try
                    {
                        //Insert the new movie information into the database.
                        business.UpdateMovie(movie, moviePoster);

                        //Tell the user the information has ben updated successfully.
                        MessageBox.Show("The information has been updated successsfully.");
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }

                    break;
                }
            }
        }
        /// <summary>
        /// Fills the movie listbox with a list of titles for all movies in the database.
        /// </summary>
        private void FillMovieList()
        {
            //Variable Declarations.
            DataSet           movieTitles;
            LimelightBusiness business = new LimelightBusiness(repository);

            //Get the movie titles from the database.
            try
            {
                movieTitles = business.GetAllMovieTitles();
            }
            catch (Exception ex)
            {
                ApplicationUtilities.CatchExceptions(ex);
                return;
            }

            //Fill the movie listbox with the movie titles.
            lstMovieList.DataSource    = movieTitles.Tables[0];
            lstMovieList.ValueMember   = "MovieID";
            lstMovieList.DisplayMember = "Title";
        }
        private void Search_Load(object sender, EventArgs e)
        {
            //Variable Declarations.
            LimelightBusiness business = new LimelightBusiness(repository);

            //Fill the list of movies and reviews.
            try
            {
                movies = business.GetAllMovies();
            }
            catch (Exception ex)
            {
                ApplicationUtilities.CatchExceptions(ex);
                return;
            }

            //Fill the genres combobox.
            FillGenreList();

            //Clear the controls on the form.
            ResetForm();
        }
示例#10
0
        private void btnSearchMovie_Click(object sender, EventArgs e)
        {
            //Variable Declarations.
            LimelightBusiness business = new LimelightBusiness(repository);
            List <Movie>      results  = new List <Movie>();

            //Validate the title if it is being used as a search criteria.
            if (chkSearchTitle.Checked == true)
            {
                try
                {
                    business.ValidateSearchTitle(txtSearchTitle.Text);
                }
                catch (Exception ex)
                {
                    //Handle an exceptions thrown.
                    ApplicationUtilities.CatchExceptions(ex);
                    return;
                }
            }

            //Validate the release date range if it is being used as a search criteria.
            if (chkSearchReleaseDate.Checked == true)
            {
                try
                {
                    business.ValidateSearchDates(dtpSearchDateFrom.Value, dtpSearchDateTo.Value);
                }
                catch (Exception ex)
                {
                    //Handle an exceptions thrown.
                    ApplicationUtilities.CatchExceptions(ex);
                    return;
                }
            }

            //Validate the release date range if it is being used as a search criteria.
            if (chkSearchGenre.Checked == true)
            {
                try
                {
                    business.ValidateSearchGenre(cmbGenre.Text);
                }
                catch (Exception ex)
                {
                    //Handle an exceptions thrown.
                    ApplicationUtilities.CatchExceptions(ex);
                    return;
                }
            }

            //Search for the movies.
            //xxx();

            //Search for the movies with that match the entered criteria.
            results = SortMovies(SearchForMovies());

            //Add the movie titles from the search result to the movie list box.
            lstMovieList.Items.Clear();
            foreach (Movie movie in results)
            {
                lstMovieList.Items.Add(movie.Title);
            }
        }