procedure SetMenuVisib(Menus: TMainMenu
PMenuItemList: TPMenuItemList);
var
i, j: Integer;
begin
//菜单权限处理
for i := 0 to Menus.Items.Count - 1 do
begin
Menus.Items.Visible := MenuItenIsUsing(Menus.Items.Name,
PMenuItemList);
if Menus.Items.Visible then
for j := 0 to Menus.Items.Count - 1 do
Menus.Items.Items[j].Visible :=
MenuItenIsUsing(Menus.Items.Items[j].Name, PMenuItemList);
end;
end;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
function MenuItenIsUsing(MenuItemCode: string;
PMenuItemList: TPMenuItemList): Boolean;
var
i: Integer;
begin
Result := false;
for i := 0 to High(PMenuItemList^) do
if PMenuItemList^.Code = MenuItemCode then
begin
// if MenuItemCode='voucher' then ShowMessage('');
Result := True;
Exit;
end;
end;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
function Get_MenuItemList(UserID: string): TMenuItemList;
begin
Setlength(Result, 0);
with TQuery.Create(nil) do
try
try
DatabaseName := Session.Databases[0].DatabaseName;
SQL.Text := 'SELECT A.CODE,A.NAME,B.POSTID FROM MENU A,POSTMENU B ' +
' WHERE B.MID = A.MID AND ' +
' B.POSTID IN (SELECT POSTID FROM USERPOST ' +
' WHERE USERID = ''' + UserID + ''' )' +
' ORDER BY POSTID ';
Open;
if not IsEmpty then
while not EOF do
begin
Setlength(Result, Length(Result) + 1);
Result[High(Result)].MenuItemName := Fields[1].AsString;
Result[High(Result)].Code := Fields[0].AsString;
Result[High(Result)].Post := Fields[2].AsString;
Next;
end;
except
;
end;
finally
Free;
end;
end;