예제 #1
0
        public List <int> getPlace(String keyword)
        {
            connect();
            string query = "SELECT * FROM TUKHOADIADIEM";

            adapter = new SqlDataAdapter(query, connection);
            DataSet dataset = new DataSet();

            adapter.Fill(dataset);
            ArrayList  ls  = ConvertDataSetToArrayList(dataset);
            List <int> arr = new List <int>();

            foreach (Object o in ls)
            {
                KeyPlace key = (KeyPlace)o;
                keyword = FormatString.FormatSrt(keyword);
                String           str        = FormatString.FormatSrt(key.NameKeyPlace);
                ApproximatString approximat = new ApproximatString(keyword);
                if (approximat.SoSanh(str))
                {
                    arr.Add(key.IdPlace);
                }
            }
            disconnect();
            return(arr);
        }
예제 #2
0
        public KeyWord getCategory(String keyword)
        {
            connect();
            string query = "SELECT * FROM TUKHOADICHVU";

            adapter = new SqlDataAdapter(query, connection);
            DataSet dataset = new DataSet();

            adapter.Fill(dataset);
            ArrayList ls = ConvertDataSetToArrayList(dataset);
            KeyWord   kw = new KeyWord();

            foreach (Object o in ls)
            {
                KeyCategory key = (KeyCategory)o;
                keyword = FormatString.FormatSrt(keyword);
                String str = FormatString.FormatSrt(key.NameKeyCategory);
                int    ps  = keyword.IndexOf(str);
                if (keyword == str)
                {
                    kw.Id          = key.IdCateggory;
                    kw.StrKeyFirst = "";
                    kw.StrKeyLast  = "";
                    return(kw);
                }
                if (ps == 0 && keyword.Length > str.Length)
                {
                    kw.Id          = key.IdCateggory;
                    kw.StrKeyFirst = "";
                    kw.StrKeyLast  = keyword.Substring(str.Length - ps);
                    return(kw);
                }
                if (ps > 0 && ((ps + str.Length) <= keyword.Length))
                {
                    kw.Id          = key.IdCateggory;
                    kw.StrKeyFirst = keyword.Substring(ps + str.Length);
                    kw.StrKeyLast  = keyword.Substring(0, ps);
                    return(kw);
                }
                if (ps > 0)
                {
                    kw.Id          = key.IdCateggory;
                    kw.StrKeyFirst = "";
                    kw.StrKeyLast  = keyword.Substring(0, ps);
                    return(kw);
                }
            }
            disconnect();
            return(null);
        }
예제 #3
0
        public int getDistrict(String keyword)
        {
            connect();
            string query = "SELECT * FROM TUKHOAQUANHUYEN";

            adapter = new SqlDataAdapter(query, connection);
            DataSet dataset = new DataSet();

            adapter.Fill(dataset);
            ArrayList ls = ConvertDataSetToArrayList(dataset);

            foreach (Object o in ls)
            {
                KeyDistrict key = (KeyDistrict)o;
                keyword = FormatString.FormatSrt(keyword);
                String str = FormatString.FormatSrt(key.NameKeyDistrict);
                if (keyword == str)
                {
                    return(key.IdDistrict);
                }
            }
            disconnect();
            return(-1);
        }
예제 #4
0
        public int getCity(String keyword)
        {
            connect();
            string query = "SELECT * FROM TUKHOATINHTHANH";

            adapter = new SqlDataAdapter(query, connection);
            DataSet dataset = new DataSet();

            adapter.Fill(dataset);
            ArrayList ls = ConvertDataSetToArrayList(dataset);

            foreach (Object o in ls)
            {
                KeyCity key = (KeyCity)o;
                keyword = FormatString.FormatSrt(keyword);
                String str = FormatString.FormatSrt(key.NameKeyCity);
                if (str == keyword)
                {
                    return(key.IdCity);
                }
            }
            disconnect();
            return(-1);
        }