Esempio n. 1
0
        private void mnuStripAllMovie_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dtAllMovie = new DataTable();
                dtAllMovie = Movie_SP.GetList(false);

                if (FormManager.IsFormOpen(enForms.frmMovieList, null) == false)
                {
                    frmMovieList movieTemp = new frmMovieList(dtAllMovie);
                    movieTemp.Show();
                }
                else
                {
                    foreach (Form frm in Application.OpenForms)
                    {
                        if (frm is frmMovieList && !frm.GetType().IsSubclassOf(typeof(frmMovieList)))
                        {
                            (frm as frmMovieList).DataSource = dtAllMovie;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 2
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;
                }

                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.FilterSearch(movieName, productLow, productUp, imdbLow, imdbUp,
                                                           durationLow, durationUp, isSeen, isFavorite, "MovieName", enOrderType.asc, director, directorFilter,
                                                           actor, actorFilter, genre, genreFilter, language, languageFilter, quality, duplicateMovies);

                Movie[] searchedMovies = new Movie[0];

                searchedMovies = Movie.FetchAllMovie(dtMovies);

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

                        movieTemp.Show();
                    }
                }
                else if (searchedMovies.Length > 1)
                {
                    if (FormManager.IsFormOpen(enForms.frmMovieList, null) == false)
                    {
                        frmMovieList movieList = new frmMovieList(dtMovies);

                        movieList.Show();
                    }
                    else
                    {
                        foreach (Form frm in Application.OpenForms)
                        {
                            if (frm is frmMovieList)
                            {
                                (frm as frmMovieList).TextBoxFocus = false;
                                (frm as frmMovieList).DataSource   = dtMovies;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show(Messages.NoMovieFound, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }