예제 #1
0
        public ActionResult GetAll()
        {
            try
            {
                var list      = DbContext.VEGETABLESPARENTTYPE.Where(m => m.ISDELETED != 1).OrderBy(o => o.SEQUENCE).ToList();
                var childList = DbContext.VEGETABLESTYPE.Where(m => m.ISDELETED != 1).OrderBy(o => o.SEQUENCE).ToList();

                List <ZtreeData> z_list = new List <ZtreeData>();
                foreach (VEGETABLESPARENTTYPE item in list)
                {
                    var z = new ZtreeData();
                    z.id       = item.GUID.ToString();
                    z.isParent = true;
                    var c_list = childList.Where(m => m.PARENTTYPEID.HasValue && m.PARENTTYPEID.Value == item.GUID).ToList();
                    z.name  = item.VEGETABLESNAME + "  (" + c_list.Count + ")";
                    z.name2 = item.VEGETABLESNAME;
                    foreach (var j in c_list)
                    {
                        var c = new ZtreeData();
                        c.id   = j.GUID.ToString();
                        c.name = j.VEGETABLESNAME;
                        z.addChild(c);
                    }
                    z_list.Add(z);
                }

                return(new JsonM().ToJson(true, "", z_list));
            }
            catch (Exception ex)
            {
                return(new JsonM().ToJson(false, ex.Message));
            }
        }
예제 #2
0
        public ActionResult GetAll()
        {
            try
            {
                var list = DbContext.SYS_DATADICLIST.ToList();

                List <ZtreeData> z_list = new List <ZtreeData>();
                foreach (SYS_DATADICLIST item in list)
                {
                    var z = new ZtreeData();
                    z.id       = item.UNIQUEFLAG;
                    z.name     = item.DATANAME;
                    z.isParent = true;
                    var c_list = this.FindByUniqueflag(z.id);
                    foreach (var j in c_list)
                    {
                        var c = new ZtreeData();
                        c.id   = j.GUID.ToString();
                        c.name = j.DICNAME;
                        z.addChild(c);
                    }
                    z_list.Add(z);
                }

                return(new JsonM().ToJson(true, "", z_list));
            }
            catch (Exception ex)
            {
                return(new JsonM().ToJson(false, ex.Message));
            }
        }