procedure TData.FillICSTree();
function FindParent(inParent : integer) : TTreenode;
var
searchNode : TTreenode;
begin
result :=
nil;
if main.icstree.Items.Count = 0
then Exit;
searchNode := main.icstree.Items[0];
while searchNode <>
nil do
begin
if integer(searchNode.Data) = inParent
then
begin
result := searchNode;
Break;
end;
searchNode := searchNode.GetNext;
end;
end;
var
tmpNode,node: TTreeNode;
pid: Integer;
begin
main.icstree.Items.Clear;
with searchQuery
do
begin
SQL.Clear;
SQL.Text := '
SELECT * FROM icstree ORDER BY level ASC;';
Open;
while not eof
do
begin
tmpNode := FindParent(searchQuery.FieldByName('
parent').AsInteger);
if tmpNode =
nil then
main.icstree.Items.AddObject(
nil,FieldByName('
name').AsString,Pointer(FieldByName('
id').AsInteger))
else
main.icstree.Items.AddChildObject(tmpNode,FieldByName('
name').AsString,Pointer(FieldByName('
id').AsInteger));
next;
end;
end;
end;