Jump to content

Formlogin - How to avoid onshow event mainform if login fails


herculanojs

Recommended Posts

FormLogin - How to avoid onshow event mainform if login fails
 
I have the following problem.
In onshow the mainform have some events.
What happens is that if the login fails, this running these events.
 
What I see is that even before validating the result of FormLogin the mainshow is already running.
Is that so?

 

procedure TfrLogin.btnOKClick(Sender: TObject);
begin
        ModalResult := mrNone;
 
     if not DataModel.link.Util.ValidaSenha(edtsenha.Text,qryUsuario.FieldByname('senha').AsString) then
     begin
          inc(Tentativas);
          DataModel.link.Mensagem.Alerta('Acesso inválido, verifique a senha digitada.');
          edtSenha.text := '';
          edtSenha.SetFocus;
          exit;
     end;
 
     UniMainModule.Usuario.Codigo := qryUsuario.FieldByName('codigo').AsInteger;
     UniMainModule.Usuario.Nome := qryUsuario.FieldByName('nome').AsString;
 
     UniMainModule.Empresa.Codigo := qryEmpresa.FieldByName('codigo').AsInteger;
     UniMainModule.Empresa.Nome := qryEmpresa.FieldByName('nome').AsString;
     UniMainModule.Empresa.Fantasia := qryEmpresa.FieldByName('nomefantasia').AsString;
 
     ModalResult := mrOK;
end;
 
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...