CASEMIRO HOLA, CLARO ESTA TAL CUAL ME AYUDO ESTOS CODIGOS.
CODIGO EN DATAMODULE2
Código Delphi
[-]unit DataModule02;
interface
uses
SysUtils, Classes, DB, IBCustomDataSet, IBDatabase, IBQuery, IBTable,
IBStoredProc;
type
TDataModule2 = class(TDataModule)
IBTransaction1: TIBTransaction;
Procedimientos: TIBStoredProc;
IBTEmpresas: TIBTable;
IBQEmpresas1: TIBQuery;
DSEmpresas: TDataSource;
DSEmpresas1: TDataSource;
IBTAgencia: TIBTable;
IBQAgencia1: TIBQuery;
DSAgencia: TDataSource;
DSAgencia1: TDataSource;
IBTUsuarios: TIBTable;
DSUsuarios: TDataSource;
IBQUsuarios1: TIBQuery;
DSUsuarios1: TDataSource;
IBDatabase1: TIBDatabase;
IBTDNI: TIBTable;
IBTDNIDES_DOC_IDE: TIBStringField;
IBTDNICOD_DOC_IDE: TIBStringField;
DSDNI: TDataSource;
IBQDNI: TIBQuery;
DTDNI1: TDataSource;
IBTTipodePersona: TIBTable;
IBQTipodePersona: TIBQuery;
DSTipodePersona: TDataSource;
DSTipodePersona1: TDataSource;
IBTEstadoCivil: TIBTable;
IBQEstadoCivil: TIBQuery;
DSEstadoCivil: TDataSource;
DSEstadoCivil1: TDataSource;
IBTZona: TIBTable;
IBQZona: TIBQuery;
DSZona: TDataSource;
DSZona1: TDataSource;
IBTPassword: TIBTable;
DSPassword: TDataSource;
IBQPassword: TIBQuery;
DSPassword1: TDataSource;
private
public
function LoginAccepted(const nam, pwd: string): Boolean;
end;
var
DataModule2: TDataModule2;
implementation {$R *.dfm}
function TDataModule2.LoginAccepted(const nam, pwd: string): Boolean;
var
qy: TIBQuery;
begin
qy := TIBQuery.Create(nil);
try
qy.Database := IBDataBase1;
qy.Transaction := IBTransaction1;
qy.Close;
qy.SQL.Clear;
qy.SQL.Add('SELECT * FROM SIS_USUARIOS');
qy.SQL.Add('WHERE DES_USUARIO = :NOMBRE');
qy.ParamByName('NOMBRE').AsString := nam;
qy.Open;
Result := not qy.IsEmpty and (qy.FieldByName('PWD_USUARIO').AsString = pwd);
qy.Close;
finally
qy.Free;
end;
end;
begin
end;
end.
CODIGO EN EL LOGIN CON EL NOMBRE(AccesoAlSistema)
Código Delphi
[-]unit AccesoAlSistema;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, DBCtrls;
type
TAccesoSistema = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
edtPassword: TEdit;
Empresa: TLabel;
Agencia: TLabel;
Usuarios: TLabel;
Label6: TLabel;
Aceptar: TBitBtn;
Cancelar: TBitBtn;
edtEmpresa: TDBLookupComboBox;
edtAgencia: TDBLookupComboBox;
edtUsuarios: TDBLookupComboBox;
procedure CancelarClick(Sender: TObject);
procedure AceptarClick(Sender: TObject);
private
public
end;
var
AccesoSistema: TAccesoSistema;
implementation
uses DataModule02, SistemaIntegradoWincab;
{$R *.dfm}
procedure TAccesoSistema.CancelarClick(Sender: TObject);
begin
close;
end;
procedure TAccesoSistema.AceptarClick(Sender: TObject);
begin
SistemaPrincipal.Enabled:=True;
if not DataModule2.LoginAccepted(edtUsuarios.Text, edtPassword.Text) then
raise Exception.Create('El usuario o la contraseña son inválidos.');
ShowMessage('INGRESA...'); end;
end.