unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, ToolWin, ComCtrls, Menus;
type
TMain_Form = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
ToolBar1: TToolBar;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Main_Form: TMain_Form;
username:String;
x1,x2,x3:Boolean;
implementation
{$R *.dfm}
procedure TMain_Form.FormActivate(Sender: TObject);
begin //用户检测初始化
username:='';
password:='';
x1:=false;
x2:=false;
x3:=false;
checkuserform.ShowModal(); //启动用户检测模块
if username<>'' then //用户登陆,根据读取的用户权限,相应设置对应的菜单允许或屏蔽
begin
if x1=ture then //管理员权限
begin
n4.Enabled:=true;
n6.Enabled:=true;
speedbutton1.Enabled:=true;
speedbutton3.Enabled:=true;
end
else
begin
n4.Enabled:=false;
n6.Enabled:=false;
speedbutton1.Enabled:=false;
speedbutton3.Enabled:=false;
end
if x2=ture then //操作员权限
begin
n2.Enabled:=true;
speedbutton4.Enabled:=true;
end
else
begin
n2.Enabled:=false;
speedbutton4.Enabled:=false;
end;
end;
if x3=ture then //查询权限
begin
n3.Enabled:=true;
speedbutton3.Enabled:=true;
end
else
begin
n3.Enabled:=false;
speedbutton5.Enabled:=false;
end;
end
else
close; //当用户输入用户名或密码错误时,或取消登陆时,退出系统
end;
end.
急,请高手们指点