Ejemplo n.º 1
0
        /// <summary>
        /// 在数据库中搜索影片
        /// </summary>
        public async void Query()
        {
            if (Search == "")
            {
                return;
            }
            //对输入的内容进行格式化
            string FormatSearch = Search.Replace(" ", "").Replace("%", "").Replace("'", "");

            FormatSearch = FormatSearch.ToUpper();

            if (string.IsNullOrEmpty(FormatSearch))
            {
                return;
            }

            string fanhao = "";

            if (CurrentVedioType == VedioType.欧美)
            {
                fanhao = Identify.GetEuFanhao(FormatSearch);
            }
            else
            {
                fanhao = Identify.GetFanhao(FormatSearch);
            }

            string searchContent = "";

            if (fanhao == "")
            {
                searchContent = FormatSearch;
            }
            else
            {
                searchContent = fanhao;
            }



            TextType = searchContent;//当前显示内容
            cdb      = new DataBase();
            List <Movie> models = null;

            if (!cdb.IsTableExist("movie"))
            {
                cdb.CloseDB(); return;
            }

            try {
                if (Properties.Settings.Default.AllSearchType == "识别码")
                {
                    models = await cdb.SelectMoviesById(searchContent);
                }
                else if (Properties.Settings.Default.AllSearchType == "名称")
                {
                    models = cdb.SelectMoviesBySql($"SELECT * FROM movie where title like '%{searchContent}%'");
                }
                else if (Properties.Settings.Default.AllSearchType == "演员")
                {
                    models = cdb.SelectMoviesBySql($"SELECT * FROM movie where actor like '%{searchContent}%'");
                }
            }
            finally { cdb.CloseDB(); }


            MovieList = new ObservableCollection <Movie>();
            models?.ForEach(arg => { MovieList.Add(arg); });
            Sort();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 在数据库中搜索影片
        /// </summary>
        public async Task <bool> Query()
        {
            if (!DataBase.IsTableExist("movie"))
            {
                return(false);
            }

            IsSearching = true;
            if (Search == "")
            {
                return(false);
            }

            string FormatSearch = Search.ToProperSql();

            if (string.IsNullOrEmpty(FormatSearch))
            {
                return(false);
            }

            string fanhao = "";

            if (CurrentVedioType == VedioType.欧美)
            {
                fanhao = Identify.GetEuFanhao(FormatSearch);
            }
            else
            {
                fanhao = Identify.GetFanhao(FormatSearch);
            }

            string searchContent = "";

            if (fanhao == "")
            {
                searchContent = FormatSearch;
            }
            else
            {
                searchContent = fanhao;
            }



            if (Properties.Settings.Default.AllSearchType == "识别码")
            {
                TextType  = "搜索识别码:" + searchContent;
                MovieList = DataBase.SelectPartialInfo($"SELECT * FROM movie where id like '%{searchContent}%'");
            }

            else if (Properties.Settings.Default.AllSearchType == "名称")
            {
                TextType  = "搜索名称:" + searchContent;
                MovieList = DataBase.SelectPartialInfo($"SELECT * FROM movie where title like '%{searchContent}%'");
            }

            else if (Properties.Settings.Default.AllSearchType == "演员")
            {
                TextType  = "搜索演员:" + searchContent;
                MovieList = DataBase.SelectPartialInfo($"SELECT * FROM movie where actor like '%{searchContent}%'");
            }



            return(true);
        }