Ejemplo n.º 1
0
 public JsonResult GetPhuongXa()
 {
     try
     {
         List <SubSelectBoxString> listTree = new List <SubSelectBoxString>();
         SubSelectBoxString        sc;
         var    listData  = DVHC_PhuongXa_SelectAll();
         var    listData0 = DVHC_QuanHuyen_SelectAll();
         string tag       = "";
         foreach (var item in listData0)
         {
             sc      = new SubSelectBoxString();
             sc.Code = item.MaQuanHuyen;
             sc.Name = item.TenQuanHuyen;
             listTree.Add(sc);
             BuildSubTree(listTree, item.MaQuanHuyen, listData, tag);
         }
         var jsonResults = new { listTree, state = true };
         return(Json(jsonResults, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { state = false, message = ex }, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 2
0
 public void BuildSubTree(List <SubSelectBoxString> listTree, string ParentCode, List <CSF_HCXa> listData, string tag)
 {
     try
     {
         SubSelectBoxString sc;
         var listChild = listData.Where(x => x.MaQuanHuyen == ParentCode);
         if (listChild != null && listChild.Count() > 0)
         {
             tag += "--- ";
             foreach (var item in listChild)
             {
                 sc      = new SubSelectBoxString();
                 sc.Code = item.MaPhuongXa;
                 sc.Name = tag + item.TenPhuongXa;
                 listTree.Add(sc);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }