unit usenha;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DB, DBTables, Grids, DBGrids, ActnList, ExtCtrls;

type
  Tfsenha = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    tbsenha: TTable;
    DataSource1: TDataSource;
    ActionList1: TActionList;
    permissao: TAction;
    Bevel1: TBevel;
    Bevel2: TBevel;
    procedure Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit1Exit(Sender: TObject);
    procedure Edit2KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit2Enter(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure permissaoExecute(Sender: TObject);
  private
    { Private declarations }
  public
  i:integer;
  st:string;
    { Public declarations }
  end;

var
  fsenha: Tfsenha;

implementation

uses UnitInicial, unitmenu;

{$R *.dfm}

procedure Tfsenha.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
        if key = 13 then
         edit2.setfocus;
end;

procedure Tfsenha.Edit1Exit(Sender: TObject);
begin


        tbsenha.Open;

        if not tbsenha.Locate('nome',edit1.text,[]) then begin
         showmessage('Este usuário não está cadastrado!!!');
          edit1.SetFocus;

        i := i + 1;
        if i = 3 then
        finicial.close;

      end;
       tbsenha.close;

end;

procedure Tfsenha.Edit2KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin


      IF key = 13 then begin
        tbsenha.Open;

        if not tbsenha.Locate('senha',edit2.text,[]) then begin
         showmessage('Senha inválida!!!');
          edit2.SetFocus;

        i := i + 1;
        if i = 3 then
        fmenu.close;

        tbsenha.close;

      end else begin

      permissaoexecute(self);

      end;
       END;


end;

procedure Tfsenha.Edit2Enter(Sender: TObject);
begin
        i:= 0;
end;

procedure Tfsenha.FormClose(Sender: TObject; var Action: TCloseAction);
begin
        if st <>'OK' then
         fmenu.Close;
end;

procedure Tfsenha.permissaoExecute(Sender: TObject);
begin
   st := 'OK';
   fmenu.permissao := tbsenha['permissao'];
    fsenha.Close;

end;

end.
