procedure
TfmMain
.
LoadStructure;
var
CurElement, CurParentID:
integer
;
begin
CurElement :=
0
;
with
tvStructure, dmStaff
do
begin
Items[
0
].DeleteChildren;
repeat
if
CurElement =
0
then
CurParentID :=
0
else
begin
sidsDeps
.
Locate(
'DeptFullName'
,
Items[CurElement].Text, []);
CurParentID := sidsDeps
.
FieldByName(
'DeptID'
).AsInteger;
end
;
with
sqlqChildDeptsList
do
begin
Close;
ParamByName(
'pDeptID'
).AsInteger:= CurParentID;
Open;
while
not
EOF
do
begin
Items
.
AddChild(Items[CurElement],
FieldByName (
'rDeptFullName'
).AsString);
Next;
end
;
end
;
inc(CurElement);
until
CurElement = (Items
.
Count -
1
);
Items
.
Item[
0
].Expand(
True
);
end
;
end
;