Exemplo n.º 1
0
        public void GetCountries()
        {
            List<Country> list = new List<Country>();

            WebClient client = new WebClient();
            string content = client.DownloadString(AppConst.SERVER_ADDRESS + "/get_country");

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(content);
            XmlNodeList nodeList = xmlDoc.GetElementsByTagName("country");
            foreach (XmlNode node in nodeList)
            {
                Country item = new Country();
                item.id = int.Parse(node.Attributes["id"].Value);

                item.name = Utility.URLDecode(node.Attributes["name"].Value);
                list.Add(item);
            }

            callback.FinishedLoadCountry(list);
        }
Exemplo n.º 2
0
        public void FinishedLoadCountry(List<Country> list)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new DeCallbackCountryList(FinishedLoadCountry), list);
                return;
            }

            //add All to search in all countries
            Country all = new Country();
            all.id = 0;
            all.name = "All";
            list.Insert(0, all);

            comboBoxCountry.Items.Clear();
            countries.Clear();
            foreach (Country i in list)
            {
                countries.Add(i);
                comboBoxCountry.Items.Add(i.name);
            }
            comboBoxCountry.SelectedIndex = 0;
            is_get_country = true;
            EnableSearch();
        }