예제 #1
0
파일: Form1.cs 프로젝트: gss0053/TourApp
        private void cbxArea_SelectedIndexChanged(object sender, EventArgs e)
        {
            cbxMuni.Text = "소분류";
            cbxMuni.Items.Clear();
            muniList.Clear();
            // 세종 JSON 구조 달라서 if문 걸어줌
            jsonObj = GetJson(GetPath(languages[cbx_language.SelectedIndex].EngName, "areaCode", "50"));

            if (cbxArea.SelectedIndex != 7)
            {
                var itemsArr = JArray.Parse(jsonObj["response"]["body"]["items"]["item"].ToString());
                GetObject(itemsArr, muniList, cbxMuni);
            }
            else
            {
                var item = JObject.Parse(jsonObj["response"]["body"]["items"]["item"].ToString());
                source = new JsonSource
                {
                    Code = item.GetValue("code").ToString(),
                    Name = item.GetValue("name").ToString(),
                    Rnum = int.Parse(item.GetValue("rnum").ToString())
                };
                muniList.Add(source);
                cbxMuni.Items.Add(item.Property("name").Value.ToString());
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: gss0053/TourApp
        // 대분류가 바뀔때 중분류
        private void cbxService1_SelectedIndexChanged(object sender, EventArgs e)
        {
            cbxService2.Items.Clear();
            cbxService2.Text = "중분류";
            cat2List.Clear();
            cbxService3.Items.Clear();
            cbxService3.Text = "소분류";
            cat3List.Clear();


            GetPath(languages[cbx_language.SelectedIndex].EngName, "categoryCode", "10");

            jsonCat1 = GetJson(path);

            if (cbx_language.SelectedIndex == 0)
            {
                if (cbxService1.SelectedIndex != 3 && cbxService1.SelectedIndex != 4 && cbxService1.SelectedIndex != 5)
                {
                    var itemsArr1 = JArray.Parse(jsonCat1["response"]["body"]["items"]["item"].ToString());
                    GetObject(itemsArr1, cat2List, cbxService2);
                }
                else
                {
                    var item = JObject.Parse(jsonCat1["response"]["body"]["items"]["item"].ToString());
                    source = new JsonSource
                    {
                        Code = item.GetValue("code").ToString(),
                        Name = item.GetValue("name").ToString(),
                        Rnum = int.Parse(item.GetValue("rnum").ToString())
                    };
                    cat2List.Add(source);

                    cbxService2.Items.Add(item.Property("name").Value.ToString());
                }
            }
            else
            {
                if (cbxService1.SelectedIndex != 3 && cbxService1.SelectedIndex != 4 && cbxService1.SelectedIndex != 5 && cbxService1.SelectedIndex != 6)
                {
                    var itemsArr1 = JArray.Parse(jsonCat1["response"]["body"]["items"]["item"].ToString());
                    GetObject(itemsArr1, cat2List, cbxService2);
                }
                else
                {
                    var item = JObject.Parse(jsonCat1["response"]["body"]["items"]["item"].ToString());
                    source = new JsonSource
                    {
                        Code = item.GetValue("code").ToString(),
                        Name = item.GetValue("name").ToString(),
                        Rnum = int.Parse(item.GetValue("rnum").ToString())
                    };
                    cat2List.Add(source);

                    cbxService2.Items.Add(item.Property("name").Value.ToString());
                }
            }
        }
예제 #3
0
파일: Form1.cs 프로젝트: gss0053/TourApp
 private void GetObject(JArray itemsArr, List <JsonSource> lst, ComboBox cbx)
 {
     foreach (JObject item in itemsArr)
     {
         source = new JsonSource
         {
             Code = item.GetValue("code").ToString(),
             Name = item.GetValue("name").ToString(),
             Rnum = int.Parse(item.GetValue("rnum").ToString())
         };
         lst.Add(source);
         cbx.Items.Add(source.Name);
     }
 }