Código
DM.CDS_USUARIO.Open;
if (edtusuario.Text = '') then
begin
IF Application.MessageBox('O CAMPO USUÁRIO DEVE SER PREENCHIDO!','AVISO',MB_OK+MB_ICONINFORMATION)=IDOK THEN
IF edtusuario.CanFocus THEN
edtusuario.SetFocus;
EXIT;
END;
if (edtsenha.Text = '') then
begin
IF Application.MessageBox('O CAMPO SENHA DEVE SER PREENCHIDO!','AVISO',MB_OK+MB_ICONINFORMATION)=IDOK THEN
IF edtsenha.CanFocus THEN
edtsenha.SetFocus;
EXIT;
END;
if (DM.CDS_USUARIO.Locate ('LOGIN',edtusuario.Text,[])) AND
(DM.CDS_USUARIO.FieldByName('SENHA').AsString = edtsenha.Text) THEN
begin
autentica.Visible:=false;
Application.CreateForm(tprincipal,principal);
principal.ShowModal;
end else
inc (tenta);
IF tenta = 1 THEN
begin
MessageDlg(Format('Tentativa 1 de 3', [tenta]), mtError, [mbOk], 0);
if edtSenha.CanFocus then
edtUsuario.SetFocus;
end;
if tenta= 2 then
begin
MessageDlg(Format('Tentativa 2 de 3', [tenta]), mtError, [mbOk], 0);
if edtSenha.CanFocus then
edtUsuario.SetFocus;
end;
if tenta= 3 then
begin
MessageDlg(Format('O LOGIN E SENHA ESTÃO INCORRETOS! A APLICAÇÃO SERÁ FECHADA!',
[tenta]) + #13 + 'VERIFIQUE OS DADOS CORRETOS E TENTE NOVAMENTE!', mtError, [mbOk], 0);
Application.Terminate;
end;
end;
end.
Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009