コード例 #1
0
        private string LoadDepartJson()
        {
            BaseDao   baseDao = new BaseDao();
            XtmDepart modelT  = new XtmDepart();

            modelT.UserId = int.Parse(Request.QueryString["id"]);
            IList <XtmDepart> list     = baseDao.ListUdf("XtmDepartLoad", modelT);
            ArrayList         jsonList = new System.Collections.ArrayList();
            string            result   = "[";

            for (int i = 0; i < list.Count; i++)
            {
                XtmDepart menuT = list[i];
                NodeData  mt    = new NodeData();
                mt.id   = menuT.Did.ToString();
                mt.code = menuT.DepartCode;
                mt.pid  = menuT.ParentId.ToString();
                mt.name = menuT.DepartName;
                mt.open = true;
                if (menuT.Pri == "y")
                {
                    mt.@checked = true;
                }
                else
                {
                    mt.@checked = false;
                }
                if (i == list.Count - 1)
                {
                    result += JsonHelper.JsonSerializer <NodeData>(mt);
                }
                else
                {
                    result += JsonHelper.JsonSerializer <NodeData>(mt) + ",";
                }
            }
            result += "]";
            return(result);
        }