예제 #1
0
        private void btnView_Click(object sender, EventArgs e)
        {
            try
            {
                enFilterType languageFilter = enFilterType.Any;

                if (radExactLanguage.Checked == true)
                {
                    languageFilter = enFilterType.Exact;
                }

                enFilterType genreFilter = enFilterType.Any;

                if (radExactGenre.Checked == true)
                {
                    genreFilter = enFilterType.Exact;
                }

                enFilterType directorFilter = enFilterType.Any;

                if (radExactDirector.Checked == true)
                {
                    directorFilter = enFilterType.Exact;
                }

                enFilterType actorFilter = enFilterType.Any;

                if (radExactActor.Checked == true)
                {
                    actorFilter = enFilterType.Exact;
                }

                int count = Convert.ToInt32(txtCount.Value);

                bool?isSeen = null;

                if (chkSeen.Checked == true && chkNotSeen.Checked == false)
                {
                    isSeen = true;
                }
                else if (chkSeen.Checked == false && chkNotSeen.Checked == true)
                {
                    isSeen = false;
                }

                bool?isFavorite = null;

                if (chkFavorite.Checked == true)
                {
                    isFavorite = true;
                }

                double imdbLow = Convert.ToDouble(dropRateLow.SelectedItem);
                double imdbUp  = Convert.ToDouble(dropRateUp.SelectedItem);

                int productLow = 1900;
                int productUp  = DateTime.Now.Year;

                if (Movie.IsProductYear(txtProductLow.Text) == true)
                {
                    productLow = Convert.ToInt32(txtProductLow.Text);
                }

                if (Movie.IsProductYear(txtProductUp.Text) == true)
                {
                    productUp = Convert.ToInt32(txtProductUp.Text);
                }

                string durationLow = "00:00:00";
                string durationUp  = "20:00:00";

                if (Movie.IsDuration(txtDurationLow.Text) == true)
                {
                    durationLow = txtDurationLow.Text;
                }

                if (Movie.IsDuration(txtDurationUp.Text) == true)
                {
                    durationUp = txtDurationUp.Text;
                }

                string movieName = txtMovieName.Text;

                string[] quality = chkQuality.SelectedID;

                if (quality.Length == 0 || chkQuality.SelectAll == true)
                {
                    quality = null;
                }

                string[] language = chkLanguage.SelectedID;

                if (language.Length == 0 || chkLanguage.SelectAll == true)
                {
                    language = null;
                }

                string[] genre = dgvGenre.SelectedID;

                if (genre.Length == 0 || dgvGenre.SelectAll == true)
                {
                    genre = null;
                }

                string[] director = dgvDirector.SelectedID;

                if (director.Length == 0 || dgvDirector.SelectAll == true)
                {
                    director = null;
                }

                string[] actor = dgvActor.SelectedID;

                if (actor.Length == 0 || dgvActor.SelectAll == true)
                {
                    actor = null;
                }

                InsertManager insertManager  = new InsertManager(false, false);
                List <Movie>  excludedMovies = new List <Movie>();

                foreach (PathSource pathSource in pathListBox.DataSource)
                {
                    excludedMovies.AddRange(insertManager.GetMovieListFromPath(pathSource.PathString));
                }

                List <Movie> duplicateMovies = new List <Movie>();

                duplicateMovies = Movie_SP.GetDuplicateMoviesInSource(excludedMovies);

                DataTable dtMovies = Movie_SP.SuggestRandom(count, movieName, productLow, productUp, imdbLow, imdbUp,
                                                            durationLow, durationUp, isSeen, isFavorite, director, directorFilter,
                                                            actor, actorFilter, genre, genreFilter, language, languageFilter, quality, duplicateMovies);

                Movie[] suggestedMovies = new Movie[0];

                suggestedMovies = Movie.FetchAllMovie(dtMovies);

                if (suggestedMovies.Length == 1)
                {
                    if (FormManager.IsFormOpen(enForms.frmMovie, suggestedMovies[0].MovieID) == false)
                    {
                        frmMovie movieTemp = new frmMovie(suggestedMovies[0].MovieID);

                        movieTemp.Show();
                    }
                }
                else if (suggestedMovies.Length > 1)
                {
                    if (FormManager.IsFormOpen(enForms.frmMovieSuggestList, suggestedMovies) == false)
                    {
                        frmMovieSuggestList suggestList = new frmMovieSuggestList(suggestedMovies);

                        suggestList.Show();
                    }
                }
                else
                {
                    MessageBox.Show(Messages.NoMovieFound, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #2
0
        private void btnQuick_Click(object sender, EventArgs e)
        {
            try
            {
                bool seen    = chkSeen.Checked;
                bool notSeen = chkNotSeen.Checked;
                bool?fav     = chkFavorite.Checked;
                int  count   = Convert.ToInt32(txtCount.Value);
                bool?isSeen  = null;


                if (fav != true)
                {
                    fav = null;
                }

                if (seen == true && notSeen == true)
                {
                    isSeen = null;
                }
                else if (seen == true && notSeen == false)
                {
                    isSeen = true;
                }
                else if (seen == false && notSeen == true)
                {
                    isSeen = false;
                }
                else
                {
                    isSeen = null;
                }

                double rateLow  = 0;
                double rateHigh = 10;

                int productLow  = 1900;
                int productHigh = 2100;

                string durationLow  = "00:00:00";
                string durationHigh = "20:00:00";

                string[] qualityID = null;

                switch (dropPreset.SelectedIndex)
                {
                case 0:     // All Movies

                    break;

                case 1:     // Top Movies

                    qualityID = new string[] { "3", "4" };
                    rateLow   = 8;

                    break;

                case 2:     // High Rated Movies

                    rateLow = 7;

                    break;

                case 3:     // High Quality Movies

                    qualityID = new string[] { "3", "4" };

                    break;

                case 4:     // Recent Movies

                    productLow  = (DateTime.Now.Year - 3);
                    productHigh = DateTime.Now.Year;

                    break;

                case 5:     // Old Movies

                    productLow  = 1901;
                    productHigh = (DateTime.Now.Year - 40);

                    break;

                case 6:     // Short Movies

                    durationHigh = "01:40:00";

                    break;

                case 7:     // Long Movies

                    durationLow = "02:15:00";

                    break;
                }


                DataTable dtMovies = new DataTable();
                dtMovies = Movie_SP.SuggestRandom(count, "", productLow, productHigh, rateLow, rateHigh, durationLow,
                                                  durationHigh, isSeen, fav, null, enFilterType.Any, null, enFilterType.Any,
                                                  null, enFilterType.Any, null, enFilterType.Any, qualityID);

                Movie[] suggestedMovies = new Movie[0];

                suggestedMovies = Movie.FetchAllMovie(dtMovies);

                if (suggestedMovies.Length == 1)
                {
                    if (FormManager.IsFormOpen(enForms.frmMovie, suggestedMovies[0].MovieID) == false)
                    {
                        frmMovie movieTemp = new frmMovie(suggestedMovies[0].MovieID);

                        movieTemp.Show();
                    }
                }
                else if (suggestedMovies.Length > 1)
                {
                    if (FormManager.IsFormOpen(enForms.frmMovieSuggestList, suggestedMovies) == false)
                    {
                        frmMovieSuggestList suggestList = new frmMovieSuggestList(suggestedMovies);

                        suggestList.Show();
                    }
                }
                else
                {
                    MessageBox.Show(Messages.NoMovieFound, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }