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
public
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.