コード例 #1
0
ファイル: Bridge.cs プロジェクト: tyler94/CIS560Project
        // Search for a movie based on how to search, what to show, and the search prompt
        public static DataTable SearchForMovie(MovieSearchType type, MoviesToShow moviesToShow, string input)
        {
            string sql;

            if (input == "")
            {
                type = MovieSearchType.None;
            }

            if (moviesToShow == MoviesToShow.AllMovies)
            {
                switch (type)
                {
                case MovieSearchType.None:
                {
                    sql = SqlProcedures.RetrieveMovies();
                    return(Call(sql));
                }

                case MovieSearchType.MovieTitle:
                {
                    sql = SqlProcedures.GetMoviesByTitle(input);
                    return(Call(sql));
                }

                case MovieSearchType.MovieGenre:
                {
                    sql = SqlProcedures.GetMoviesByGenre(input);
                    return(Call(sql));
                }

                case MovieSearchType.MovieDirector:
                {
                    sql = SqlProcedures.GetMoviesByDirector(input);
                    return(Call(sql));
                }
                }
            }
            else
            {
                bool isRemoved = (moviesToShow == MoviesToShow.OnlyUnavailable);

                switch (type)
                {
                case MovieSearchType.None:
                {
                    sql = SqlProcedures.GetFilteredMovies(isRemoved);
                    return(Call(sql));
                }

                case MovieSearchType.MovieTitle:
                {
                    sql = SqlProcedures.GetFilteredMoviesByTitle(input, isRemoved);
                    return(Call(sql));
                }

                case MovieSearchType.MovieGenre:
                {
                    sql = SqlProcedures.GetFilteredMoviesByGenre(input, isRemoved);
                    return(Call(sql));
                }

                case MovieSearchType.MovieDirector:
                {
                    sql = SqlProcedures.GetFilteredMoviesByDirector(input, isRemoved);
                    return(Call(sql));
                }
                }
            }

            return(null);
        }