Last active
January 27, 2016 14:05
-
-
Save antunesleo/07559e90cd9f444c8831 to your computer and use it in GitHub Desktop.
O código verifica a existência do usuário informado na tela de login, depois verifica se a senha informada está correta. Se tudo correr bem, a tela inicial do sistema será aberta.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
procedure TFrmLogin.BTN_EnterClick(Sender: TObject); | |
var verif: boolean; | |
begin | |
//DM é o nome do form e ADOQueryUs é o nome da query(busca) responsável pela tabela users | |
DM.ADOQueryUs.close; | |
DM.ADOQueryUs.SQL.Clear; | |
// os comandos a cima fecham e limpam a query | |
DM.ADOQueryUs.SQL.add('Select * from "users" where "id" = :id'); | |
DM.ADOQueryUs.Parameters.ParamByName('id').Value := edt_id.Text; | |
{Um comando SQL é atribuido a query, selecionando a tebela usuario onde o campo ID seja | |
igual ao texto que o usuario ira inserir no edt_id} | |
DM.ADOQueryUs.Open; | |
try | |
if (Not DM.ADOQueryUs.isEmpty) and (edt_pass.Text = DM.ADOQueryUs.FieldByName('pass').AsString) then | |
{Se o resultado retornado pela query nao for vazio (Ou seja, aquele usuario existe) | |
e o valor do campo edit senha for igual a busca da cary no campo senha do mesmo registro} | |
begin | |
Modalresult := mrok; | |
verif := true; | |
end | |
else | |
begin | |
application.MessageBox('Senha ou usuário incorretos!','Atenção',MB_OK+MB_ICONINFORMATION); | |
edt_pass.Clear; | |
edt_pass.SetFocus; | |
verif := false; | |
end; | |
finally | |
DM.ADOQueryUs.Close; | |
end; | |
if (verif = true) then | |
begin | |
FreeAndNil(FrmLogin); //Libera o form de Login da memória | |
Application.CreateForm(TFrmHome, FrmHome); //Cria a janela main | |
Application.Run; //Roda a aplicação | |
end; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment