2007-10-03 16:03:28 +00:00
|
|
|
|
unit uLoginForm;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, StdCtrls, ExtCtrls, ComCtrls, cxGraphics, cxControls,
|
|
|
|
|
|
cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit,
|
|
|
|
|
|
cxImageComboBox, ImgList, PngImageList, pngimage, ToolWin, JvExControls,
|
|
|
|
|
|
JvComponent, JvGradient, JvGIF, JvComponentBase, JvFormPlacement,
|
|
|
|
|
|
JvAppStorage, JvAppRegistryStorage;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
TfLoginForm = class(TForm)
|
|
|
|
|
|
Panel1: TPanel;
|
|
|
|
|
|
Label3: TLabel;
|
|
|
|
|
|
Label4: TLabel;
|
|
|
|
|
|
edtPassword: TEdit;
|
|
|
|
|
|
bAceptar: TButton;
|
|
|
|
|
|
bCancelar: TButton;
|
|
|
|
|
|
Label1: TLabel;
|
|
|
|
|
|
edtUser: TEdit;
|
|
|
|
|
|
JvGradient1: TJvGradient;
|
|
|
|
|
|
Button1: TButton;
|
|
|
|
|
|
Timer1: TTimer;
|
|
|
|
|
|
JvAppRegistryStorage1: TJvAppRegistryStorage;
|
|
|
|
|
|
JvFormStorage1: TJvFormStorage;
|
|
|
|
|
|
Image1: TImage;
|
|
|
|
|
|
procedure bAceptarClick(Sender: TObject);
|
|
|
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
|
|
procedure ToolButton4Click(Sender: TObject);
|
|
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
|
|
procedure Timer1Timer(Sender: TObject);
|
|
|
|
|
|
private
|
|
|
|
|
|
FIntentos: Integer;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
|
fLoginForm: TfLoginForm;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
2007-10-08 07:58:40 +00:00
|
|
|
|
uFactuGES_App, uDataModuleConexion;
|
|
|
|
|
|
{uDataModuleUsuarios, uDataModuleBase}
|
2007-10-03 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
********************************* TfLoginForm **********************************
|
|
|
|
|
|
}
|
|
|
|
|
|
procedure TfLoginForm.bAceptarClick(Sender: TObject);
|
2007-10-08 07:58:40 +00:00
|
|
|
|
//var
|
|
|
|
|
|
// bOk : Boolean;
|
2007-10-03 16:03:28 +00:00
|
|
|
|
begin
|
|
|
|
|
|
{ ShowHourglassCursor;
|
|
|
|
|
|
try
|
|
|
|
|
|
bOK := dmUsuarios.Login(edtUser.Text, edtPassword.Text);
|
|
|
|
|
|
finally
|
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
if bOk then
|
|
|
|
|
|
ModalResult := mrOK
|
|
|
|
|
|
else begin
|
|
|
|
|
|
Application.MessageBox('Usuario no v<>lido. Compruebe si ha escrito correctamente'
|
|
|
|
|
|
+ #13 + #10 + 'el usuario y la contrase<73>a.', 'Atenci<63>n', MB_OK);
|
|
|
|
|
|
Dec(FIntentos);
|
|
|
|
|
|
if (FIntentos <= 0) then
|
|
|
|
|
|
ModalResult := mrCancel;
|
|
|
|
|
|
end;}
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfLoginForm.FormCreate(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FIntentos := 3;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfLoginForm.ToolButton4Click(Sender: TObject);
|
2007-10-08 07:58:40 +00:00
|
|
|
|
var
|
|
|
|
|
|
ATimer : Boolean;
|
2007-10-03 16:03:28 +00:00
|
|
|
|
begin
|
2007-10-08 07:58:40 +00:00
|
|
|
|
if Timer1.Enabled then
|
|
|
|
|
|
begin
|
|
|
|
|
|
ATimer := True;
|
|
|
|
|
|
Timer1.Enabled := False;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-03 16:03:28 +00:00
|
|
|
|
dmConexion.ConfigurarConexion;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
|
|
|
|
|
if ATimer then
|
|
|
|
|
|
Timer1.Enabled := True;
|
2007-10-03 16:03:28 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfLoginForm.FormShow(Sender: TObject);
|
|
|
|
|
|
begin
|
2007-10-08 07:58:40 +00:00
|
|
|
|
Self.Caption := Self.Caption + ' - ' + AppFactuGES.AppVersion;
|
2007-10-03 16:03:28 +00:00
|
|
|
|
JvFormStorage1.RestoreFormPlacement;
|
|
|
|
|
|
// Hacer login autom<6F>tica si hay usuario/password y no hay m<>s de una base
|
|
|
|
|
|
// de datos como opci<63>n para conectarse.
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
2007-10-03 16:03:28 +00:00
|
|
|
|
if ((Length(edtUser.Text) > 0) and (Length(edtPassword.Text) > 0)) then
|
|
|
|
|
|
Timer1.Enabled := True;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfLoginForm.Timer1Timer(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
Timer1.Enabled := False;
|
|
|
|
|
|
bAceptar.Click;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|