Tema: Login-Delphi
Ver Mensaje Individual
  #31  
Antiguo 20-08-2007
Avatar de enecumene
[enecumene] enecumene is offline
Miembro de Oro
 
Registrado: may 2006
Ubicación: Santo Domingo, Rep. Dom.
Posts: 3.040
Reputación: 21
enecumene Va por buen camino
Aqui esta el codigo Caral:

Código Delphi [-]
unit Login;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, DB, ADODB;

type
  TFLogin = class(TForm)
    Label1: TLabel;
    EUsuario: TEdit;
    Label2: TLabel;
    EClave: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    ADLogin: TADOQuery;
    ADLoginusername: TWideStringField;
    ADLoginpass: TWideStringField;
    ADLoginnom_user: TWideStringField;
    procedure FormCreate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FLogin: TFLogin;
  Cuenta : integer;
  Usuario, Nombre : String;
  LoginOK : boolean;

implementation

uses Datos, inicio;

{$R *.dfm}

procedure TFLogin.FormCreate(Sender: TObject);
begin
   Cuenta := 0;
   Usuario := '';
   Nombre := '';
end;

procedure TFLogin.BitBtn1Click(Sender: TObject);
begin
 LoginOK := False;
   ADLogin.Parameters.ParamByName('cod').Value:= EUsuario.Text;
   ADLogin.Active:= True;
   EUsuario.Text:= ADLogin.Fields[1].AsString;
   If ADLogin.RecordCount < 1 then
    Begin
       Cuenta := Cuenta + 1;
       MessageDlg('Usuario no encontrado',mtError, [mbOK], 0);
       EUsuario.Text := '';
       EClave.Text := '';
       ADLogin.Active := False;
       If Cuenta = 3 then Close;
    end
   else
       If ADLoginpass.AsString = EClave.Text then
        Begin
           LoginOk := True;
           Nombre := ADLoginnom_user.AsString;
           ADLogin.Active := False;
           incio:=Tincio.Create(self);
           try
           FLogin.Visible:= False;
           incio.ShowModal;
           finally
           incio.Free;
           end;
           Close;
        end
     else
         Begin
           Cuenta := Cuenta + 1;
           MessageDlg('Clave Inválida',mtError, [mbOK], 0);
           EClave.Text := '';
           ADLogin.Active := False;
           If Cuenta = 3 then Close;
         end;
end;

end.
__________________

Mi BLOG - ¡Joder, leanse la guia de estilo!
Las Palabras son enanas, los ejemplos gigantes.

Última edición por enecumene fecha: 20-08-2007 a las 18:52:49.
Responder Con Cita