请教用ActionList实现用户权限的设置
1个回答
展开全部
用户,组,权限是针对组设定的。
var
qry:TQuery;
lstRouting:TStrings;
strGroupName:string;
i:Integer;
begin
lstRouting := TStringlist.Create;
qry := TQuery.Create(Nil);
with qry do
try
databasename := cbde_dbalias;
SessionName := cSessionName;
sql.add('select groupname from users');
sql.add('where username=''' + username + '''');
Open;
if Not IsEmpty then
begin
strGroupName := Fieldbyname('Groupname').asString;
close;
sql.clear;
sql.add('select Routingid from Authority where groupname=''' +
strGroupName + ''' and isexecute=0');
open;
while not eof do
begin
lstRouting.Add(inttostr(Fieldbyname('RoutingID').asInteger));
Next;
end;
Close;
end;
close;
for i:=0 to ActionList.ActionCount -1 do
begin
if comparetext(username,'voidname')=0 then
TAction(ActionList.Actions[i]).Enabled := False
else
if lstRouting.indexof(inttostr(Actionlist.Actions[i].Tag)) <> -1 then
TAction(ActionList.Actions[i]).Enabled := False
else
TAction(ActionList.Actions[i]).Enabled := True;
end;
finally
free;
end;
lstRouting.Free;
var
qry:TQuery;
lstRouting:TStrings;
strGroupName:string;
i:Integer;
begin
lstRouting := TStringlist.Create;
qry := TQuery.Create(Nil);
with qry do
try
databasename := cbde_dbalias;
SessionName := cSessionName;
sql.add('select groupname from users');
sql.add('where username=''' + username + '''');
Open;
if Not IsEmpty then
begin
strGroupName := Fieldbyname('Groupname').asString;
close;
sql.clear;
sql.add('select Routingid from Authority where groupname=''' +
strGroupName + ''' and isexecute=0');
open;
while not eof do
begin
lstRouting.Add(inttostr(Fieldbyname('RoutingID').asInteger));
Next;
end;
Close;
end;
close;
for i:=0 to ActionList.ActionCount -1 do
begin
if comparetext(username,'voidname')=0 then
TAction(ActionList.Actions[i]).Enabled := False
else
if lstRouting.indexof(inttostr(Actionlist.Actions[i].Tag)) <> -1 then
TAction(ActionList.Actions[i]).Enabled := False
else
TAction(ActionList.Actions[i]).Enabled := True;
end;
finally
free;
end;
lstRouting.Free;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询