private SupplierGroupNodeInfo GetNode(string id, DataTable dt) { SupplierGroupInfo info = this.FindByID(id); SupplierGroupNodeInfo nodeInfo = new SupplierGroupNodeInfo(info); DataRow[] dChildRows = dt.Select(string.Format(" PID='{0}'", id)); for (int i = 0; i < dChildRows.Length; i++) { string childId = dChildRows[i]["ID"].ToString(); SupplierGroupNodeInfo childNodeInfo = GetNode(childId, dt); nodeInfo.Children.Add(childNodeInfo); } return(nodeInfo); }
/// <summary> /// 根据用户,获取树形结构的供应商分组列表 /// </summary> public List <SupplierGroupNodeInfo> GetTree(string creator, string condition) { string where = !string.IsNullOrEmpty(creator) ? string.Format("AND Creator='{0}'", creator) : ""; if (!string.IsNullOrEmpty(condition)) { where += " AND " + condition; } List <SupplierGroupNodeInfo> nodeList = new List <SupplierGroupNodeInfo>(); 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(); SupplierGroupNodeInfo nodeInfo = GetNode(id, dt); nodeList.Add(nodeInfo); } return(nodeList); }