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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...