fastscripT实现权限控制
fastscripT权限控制
此处以FASTSCRIPT实现功能权限为例,用脚本实现数据权限也是很方便的。
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, fs_ipascal, fs_iinterpreter, Vcl.Menus, Vcl.StdCtrls, Vcl.ComCtrls, Vcl.ToolWin;
type
TForm1 = class(TForm)
script: TfsScript;
fsPascal1: TfsPascal;
Button1: TButton;
MainMenu1: TMainMenu;
btnappend: TMenuItem;
btnsave: TMenuItem;
btndelete: TMenuItem;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses fs_iformsrtti, fs_imenusrtti;
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
comp: TComponent;
sScript: string;
begin
sScript := 'begin form1.btnsave.enabled:=false;form1.btndelete.enabled:=false;end.';
script.Clear;
script.Parent := fsGlobalUnit;
script.AddComponent(Form1);
for i := 0 to Self.ComponentCount - 1 do
begin
comp := self.Components[i];
if comp is TMenuItem then
script.AddComponent(comp);
end;
script.Lines.Text := sScript;
if not Script.Run then
ShowMessage('script error: ' + Script.ErrorMsg);
end;
end.
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/6386399.html