我做的这个程序是用禁止菜单的方式实现对模块的控制(三层),可以参考
procedure TFirstForm.Edit2Exit(Sender: TObject);
var
sPASSWD, vCompNa, vCompIP, vUSERNAME,
vUseSystem, vLoginTime: string;
begin
Caption := '正在验证用户和密码...';
// Prepare := IPre_AppServer.CreateInstance(InstanceName);
if (Trim(Edit2.Text) <> '') and (Trim(Edit1.Text) <> '') then begin
vSYSNO := 'SYS41';
vUSERNO := UpperCase(TRIM(Edit1.Text));
if Trim(vUSERNO) <> '' then begin
MainForm.SmsCDS.Close;
MainForm.SmsCDS.Params[0].AsString := vSYSNO;
MainForm.SmsCDS.Params[1].AsString := vUSERNO;
MainForm.SmsCDS.Open;
if MainForm.SmsCDS.RecordCount > 0 then begin
sPasswd := MainForm.SmsCds.FieldByName('PASSWORD').AsString;
MainForm.SmsCDS.Close;
//ShowMessage(PW2BIN(sPASSWD,TRUE));
if UPPERCASE(Edit2.Text) = PW2BIN(sPASSWD, TRUE) then
vINFO := 'OK'
else
vINFO := 'ERROR';
end
else
vINFO := 'ERROR';
end
else
vINFO := 'NOT FOUND';
if vINFO = 'NOT FOUND' then
ShowMessage('用户找不到')
else if vINFO = 'ERROR' then
ShowMessage('口令错误!')
else if vINFO = 'OK' then begin
Edit2.Text := '';
vCOMPNA := ComputerName;
vCOMPIP := ComputerIP;
mainform.Socket_C.AppServer.Login(vUserno, vCompNa, vCompIP, 'SYS41', TimeToStr(TIME));
EnableMenu;
FirstForm.WindowState := wsMinimized;
mainform.StatusBar.Panels[0].Text := UserStr + UPPERCASE(Edit1.Text);
end
else
ShowMessage('不能辨别的错误!');
end;
Caption := '登入窗口';
end;