Exemplo n.º 1
0
        private CustomerGroupNodeInfo GetNode(string id, DataTable dt)
        {
            CustomerGroupInfo     info     = this.FindByID(id);
            CustomerGroupNodeInfo nodeInfo = new CustomerGroupNodeInfo(info);

            DataRow[] dChildRows = dt.Select(string.Format(" PID='{0}'", id));
            for (int i = 0; i < dChildRows.Length; i++)
            {
                string childId = dChildRows[i]["ID"].ToString();
                CustomerGroupNodeInfo childNodeInfo = GetNode(childId, dt);
                nodeInfo.Children.Add(childNodeInfo);
            }
            return(nodeInfo);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据用户,获取树形结构的客户分组列表
        /// </summary>
        public List <CustomerGroupNodeInfo> GetTree(string creator, string condition)
        {
            string where = !string.IsNullOrEmpty(creator) ? string.Format("AND Creator='{0}'", creator) : "";
            if (!string.IsNullOrEmpty(condition))
            {
                where += " AND " + condition;
            }
            List <CustomerGroupNodeInfo> nodeList = new List <CustomerGroupNodeInfo>();
            string sql = string.Format("Select * From {0} Where 1=1 {1} Order By PID, HandNo ", tableName, where);

            DataTable dt = base.SqlTable(sql);

            DataRow[] dataRows = dt.Select(string.Format(" PID = '{0}' ", -1));
            for (int i = 0; i < dataRows.Length; i++)
            {
                string id = dataRows[i]["ID"].ToString();
                CustomerGroupNodeInfo nodeInfo = GetNode(id, dt);
                nodeList.Add(nodeInfo);
            }

            return(nodeList);
        }