Example #1
0
        public static void AutocompleteKieuKham(string madoituongkcb, AutoCompleteTextbox txtAuto)
        {
            DataTable m_kieuKham = THU_VIEN_CHUNG.Get_KIEUKHAM(madoituongkcb, -1);

            try
            {
                if (m_kieuKham == null)
                {
                    return;
                }
                if (!m_kieuKham.Columns.Contains("ShortCut"))
                {
                    m_kieuKham.Columns.Add(new DataColumn("ShortCut", typeof(string)));
                }
                foreach (DataRow dr in m_kieuKham.Rows)
                {
                    string shortcut = "";
                    string realName = dr[DmucKieukham.Columns.TenKieukham].ToString().Trim() + " " +
                                      Utility.Bodau(dr[DmucKieukham.Columns.TenKieukham].ToString().Trim());
                    shortcut = dr[DmucKieukham.Columns.MaKieukham].ToString().Trim();
                    string[] arrWords = realName.ToLower().Split(' ');
                    string   _space   = "";
                    string   _Nospace = "";
                    foreach (string word in arrWords)
                    {
                        if (word.Trim() != "")
                        {
                            _space += word + " ";
                            //_Nospace += word;
                        }
                    }
                    shortcut += _space; // +_Nospace;
                    foreach (string word in arrWords)
                    {
                        if (word.Trim() != "")
                        {
                            shortcut += word.Substring(0, 1);
                        }
                    }
                    dr["ShortCut"] = shortcut;
                }
            }
            catch
            {
            }
            finally
            {
                var source = new List <string>();
                var query  = from p in m_kieuKham.AsEnumerable()
                             select p.Field <Int16>(DmucKieukham.Columns.IdKieukham).ToString() + "#" + p.Field <string>(DmucKieukham.Columns.MaKieukham).ToString() + "@" + p.Field <string>(DmucKieukham.Columns.TenKieukham).ToString() + "@" + p.Field <string>("shortcut").ToString();

                source = query.ToList();
                txtAuto.AutoCompleteList   = source;
                txtAuto.TextAlign          = HorizontalAlignment.Center;
                txtAuto.CaseSensitive      = false;
                txtAuto.MinTypedCharacters = 1;
            }
        }
        public static void AutocompletePhongKham(string madoituongkcb, AutoCompleteTextbox txtAuto)
        {
            DataTable m_PhongKham = THU_VIEN_CHUNG.Get_PHONGKHAM(madoituongkcb);
            try
            {
                if (m_PhongKham == null) return;
                if (!m_PhongKham.Columns.Contains("ShortCut"))
                    m_PhongKham.Columns.Add(new DataColumn("ShortCut", typeof(string)));
                foreach (DataRow dr in m_PhongKham.Rows)
                {
                    string shortcut = "";
                    string realName = dr[DmucKhoaphong.Columns.TenKhoaphong].ToString().Trim() + " " +
                                      Utility.Bodau(dr[DmucKhoaphong.Columns.TenKhoaphong].ToString().Trim());
                    shortcut = dr[DmucKhoaphong.Columns.MaKhoaphong].ToString().Trim();
                    string[] arrWords = realName.ToLower().Split(' ');
                    string _space = "";
                    string _Nospace = "";
                    foreach (string word in arrWords)
                    {
                        if (word.Trim() != "")
                        {
                            _space += word + " ";
                            //_Nospace += word;
                        }
                    }
                    shortcut += _space; // +_Nospace;
                    foreach (string word in arrWords)
                    {
                        if (word.Trim() != "")
                            shortcut += word.Substring(0, 1);
                    }
                    dr["ShortCut"] = shortcut;
                }
            }
            catch
            {
            }
            finally
            {
                var source = new List<string>();
                var query = from p in m_PhongKham.AsEnumerable()
                            select p.Field<Int16>(DmucKhoaphong.Columns.IdKhoaphong).ToString() + "#" + p.Field<string>(DmucKhoaphong.Columns.MaKhoaphong).ToString() + "@" + p.Field<string>(DmucKhoaphong.Columns.TenKhoaphong).ToString() + "@" + p.Field<string>("shortcut").ToString();
                source = query.ToList();
                txtAuto.AutoCompleteList = source;
                txtAuto.TextAlign = HorizontalAlignment.Center;
                txtAuto.CaseSensitive = false;
                txtAuto.MinTypedCharacters = 1;

            }
        }