(************************************************************************
*    This File is Part of the AHM Triton Tools                          *
*    for Borland Delphi and C++ Builder.                                *
*************************************************************************
* Copyright © 1995-1999 Alexander H. Mehlhorn (AHM) and Tritontools.com *
* All Rights reserved.                                                  *
*                                                                       *
*    For more Information contact us at                                 *
*    E-Mail : support@tritontools.com                                   *
*    URL : http://www.tritontools.com                                   *
*                                                                       *
*    AHM is copyright by Alexander H. Mehlhorn                          *
*    All Parts of this Collection were developed,                       *
*    designed and implemented by AHM                                    *
*                                                                       *
*    Under no Circumstances may you distribute this file                *
*    in this or any other format. This File is supplied                 *
*    as Evaluation of Source only. No Delphi Components may be developed*
*    using extracts or subsets of this code without expressed permission*
*    by AHM.                                                            *
*                                                                       *
*************************************************************************)

unit AHMTQueryAccess;

interface

uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls,
  Forms, Dialogs,AHMDialogClass;
type
  TAHMQueryAccess = class(TAHMDialogComponent)
  private
    FAccessCode : string;
    FCaption : String;
    FOnWrongCode : TNotifyEvent;
    FOnRightCode : TNotifyEvent;
    fquery : String;
  protected
  public
     Function Execute : Boolean; override;
     constructor Create(AOwner : TComponent); override;
  published
    Property AccessCode : String read FAccessCode write FAccessCode;
    Property OnWrongCode : TNotifyEvent read FOnWrongCode write FOnWrongCode;
    Property OnRightCode : TNotifyEvent read FOnRightCode write FOnRightCode;
    Property Query : String read fquery write fquery;
    Property Caption : String read FCaption write FCaption;
  end;

implementation
uses AHMDialogConst;

constructor TAHMQueryAccess.Create(AOwner : TComponent);
begin
  inherited create(AOwner);
  FCaption :=ahmrcdlgaccesscodereq;
  fquery:=ahmrcdlgenteraccesscode;
end;

Function TAHMQueryAccess.Execute : Boolean;
var ReturnS : string;
begin
  inherited Execute;
  Inputquery(FCaption,fquery,ReturnS);
  if uppercase(ReturnS)=uppercase(FAccessCode) then
  begin
    result:=true;
    if Assigned(FOnRightCode) then FOnRightCode(Self);
  end
  else
  begin
    result:=false;
    if Assigned(FOnWrongCode) then FOnWrongCode(Self);
  end;
end;

end.
