procedure TFrm_MenuSet.LoadAllMenu(AWorker: string);
var
tmpADOQuery: TADOQuery;
tmpSQLStr: string;
tmpLastNode: TTreeNode;
tmpLastSysNo: string;
i: Integer;
function GetNo: string;
begin
Result := tmpADOQuery.Fields[0].AsString;
end;
function GetPosNo: string;
begin
Result := tmpADOQuery.Fields[2].AsString + tmpADOQuery.Fields[0].AsString;;
end;
function GetName: string;
begin
Result := tmpADOQuery.Fields[1].AsString;
end;
function GetSysNo: string;
begin
Result := tmpADOQuery.Fields[2].AsString;
end;
procedure AddNextNode(AParentNode: TTreeNode; ASystemNo: string; ALastNo: string);
var
tmpLastNode: TTreeNode;
tmpLastSystemNo: string;
tmplastNo: string;
tmpObject: TDataObject;
begin
//如果是当前级的下一级。
while not tmpADOQuery.Eof do
begin
if (Copy(GetPosNo, 1, Length(ALastNo)) = ALastNo)
and (Length(GetPosNo) = Length(ALastNo) + 2) then
begin
tmpObject := TDataObject.Create;
tmpObject.dSystemNo := GetSysNo;
tmpObject.dMenu := tmpADOQuery.Fields[5].AsString;
tmpObject.DNo := GetNo;
tmpObject.dHasRight := tmpADOQuery.Fields[4].AsString;
tmpLastNode := Ckt_Menu.Items.AddChildObject(AParentNode, GetName, tmpObject);
tmpLastSystemNo := GetSysNo;
tmplastNo := GetPosNo;
tmpADOQuery.Next;
if not tmpADoQuery.Eof then
AddNextNode(tmplastNode, tmpLastSystemNo, tmpLastNo);
end
else
begin
Exit;
end;
end;
end;
begin
tmpSQLStr := SQLGetField('select top 1 1 from f_worker where dcansetup =1' +
' and dworker =' + QuotedStr(AWorker));
if tmpSQLStr = '1' then
Chk_EnableGrid.Checked := True
else
Chk_EnableGrid.Checked := False;
Ckt_Menu.Items.Clear;
tmpLastNode := nil;
{ tmpSQLStr := ' select a.dposition, a.dmenu_caption, a.dsystem, b.dSystem_Name from s_popedom_system a, s_system b '
+ ' where a.dsystem = b.dsystem_no '
+ ' and b.difused = 1 and b.dlevel < 7 '
+ ' order by dsystem, dposition';
}
tmpSQLStr := ' select a.dposition, a.dmenu_caption, a.dsystem, a.dSystem_Name, isnull(b.dmenu, ''xx'') sele, a.dmenu from '
+ ' (select a.dmenu, a.dposition, a.dmenu_caption, a.dsystem, b.dSystem_Name '
+ ' from s_popedom_system a, s_system b'
+ ' where a.dsystem = b.dsystem_no and b.difused = 1 and b.dlevel < 7 '
+ ' ) a left join (select distinct * from s_popedom_worker '
+ ' where dworker = ' + QuotedStr(AWorker) + ') b '
+ ' on (a.dsystem + a.dmenu = b.dsystem+ b.dmenu) '
+ ' order by a.dsystem, a.dposition ';
tmpADOQuery := GetCommQuery();
tmpADOQuery.SQL.Text := tmpSQLStr;
tmpADOQuery.Open;
tmpLastSysNo := '';
while not tmpADOQuery.Eof do
begin
if tmpLastSysNo <> GetSysNo then
begin
tmpLastSysNo := GetSysNo;
tmpLastNode := Ckt_Menu.Items.AddChildObject(nil, tmpADOQuery.Fields[3].AsString, nil);
end;
AddNextNode(tmpLastNode, '', GetSysNo);
//tmpADOQuery.Next;
end;
for I := 0 to Ckt_Menu.Items.Count - 1 do
begin
if Ckt_Menu.Items.Item[i].Data <> nil then
if TDataObject(Ckt_Menu.Items.Item[i].Data).dHasRight <> 'xx' then
Ckt_Menu.ItemState[I] := csChecked;
end;
浙公网安备 33010602011771号