//这个语句没有用 button.visible := false;
procedure TFrm_RoleSet.Button4Click(Sender: TObject);
var
i,iLevel:Integer;
sCode,sName:string;
isown:Boolean;
MyNode:array[0..4]of TTreeNode;//保存各级节点
vstr : string;
begin
// vstr := 'select ofac_no,sec_no,sec_nm,parent_sec_no,'+
// '(case len(sec_no) WHEN 2 then 2 when 4 then 3 when 6 then 4 when 8 then 5 ELSE 1 end) as level '+
// ' from rzs_sec where left(sec_no,1)=''9''';
vstr := 'select ofac_no,sec_no,sec_nm,parent_sec_no,'+
'(case len(sec_no) when 2 then 1 when 4 then 2 when 6 then 3 when 8 then 4 when 5 then 5 end) as level '+
' from rzs_sec where left(sec_no,1)=''9'' and (ofac_no=''A'')';
RzCheckTree1.Items.Clear;
with qryDuoQuanXian do
begin
Connection:=conn1;
Close;
SQL.Clear;
SQL.Text:= vstr;
Open;
First;
i:=0;
while not Eof do
begin
sCode:=Trim(FieldByName('sec_no').AsString);
sName:=Trim(FieldByName('sec_nm').AsString);
iLevel:=FieldByName('level').AsInteger;
isown:= False;
if iLevel=1 then
MyNode[iLevel]:=RzCheckTree1.Items.AddChild(nil,sName)
else
MyNode[iLevel]:=RzCheckTree1.Items.AddChild(MyNode[iLevel-1],sCode+'-'+sName);
if isown then
RzCheckTree1.ItemState[i] := csChecked
else
RzCheckTree1.ItemState[i] := csUnchecked;
i:=i+1;
// MoveBy(179) ; //向前移179步
Next;
end;
end;
RzCheckTree1.AlphaSort(False);
end;