Advertisement
WPDeveloper

Login

Jul 24th, 2015
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.79 KB | None | 0 0
  1. ///Ativacao da do formulario
  2. procedure Tfrm_Principal.FormActivate(Sender: TObject);
  3. //OBS: que as variaveis numTentativas e acerto, são da unit o login
  4. begin
  5. abaIndex := 0;
  6. Self.sSkinManager1.SkinName:= Layouts[1];
  7.         try
  8.         frm_Login := Tfrm_Login.Create(nil);
  9.         frm_Login.DBGrid1.Visible := False;
  10.         //ShowMessage(db_Alunos.ConnectionString);
  11.         numTentativas := 0;
  12.         acerto := False;
  13.         frm_Login.ShowModal;
  14.                 //Esse while diz: enquanto numero de tentativas(erros) for>=0 ou < 3 e acerto ainda for falso
  15.                 //A unit do login vai ser aberta em showModal
  16.                 while (numTentativas >= 0) and (numTentativas <3) and (acerto = False) do
  17.                 begin
  18.                 frm_Login.lb_tentativas.Caption := 'Você já tentou.. '+IntToStr(numTentativas)+' vez/vezes..';
  19.                 frm_Login.ShowModal;
  20.                 end;
  21.                 //Se o numero de erros(numTentativas) chegar ao valor de 3
  22.                 //a aplicação é encerrada
  23.                 if numTentativas = 3 then
  24.                 begin
  25.                 Application.Terminate;
  26.                 end
  27.                     //Caso contrário se ouver um (acerto)
  28.                     //a tela de login se esconde no  inicio da aplicação
  29.                     else if acerto = True then
  30.                          begin
  31.                          frm_Login.Hide;
  32.                          frm_Login.Close;
  33.                          end;
  34.         //ao ser finalizada a tela de login libera a memória ocupada no CPU
  35.         finally
  36.         frm_Login.Free;
  37.         frm_Login := nil;
  38.         tbsheet_alunos.TabVisible := false;
  39.         tbsheet_classes.TabVisible := false;
  40.         tbsheet_horarios.TabVisible := false;
  41.         end;
  42. end;
  43. ///=================//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement