2007-10-08 07:58:40 +00:00
|
|
|
|
unit uFactuGES_App;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
SysUtils, Classes, Forms, uUsuarios, uBizEmpresas,
|
|
|
|
|
|
uEmpresasController, JclFileUtils, uUsuariosController;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
TAppFactuGES = class(TObject)
|
|
|
|
|
|
private
|
|
|
|
|
|
FAppInfo : TJclFileVersionInfo;
|
|
|
|
|
|
FEmpresasController : IEmpresasController;
|
|
|
|
|
|
FUsuariosController: IUsuariosController;
|
|
|
|
|
|
FEmpresaActiva: IBizEmpresa;
|
|
|
|
|
|
function GetAppForm: TCustomForm;
|
|
|
|
|
|
function GetEmpresasController: IEmpresasController;
|
|
|
|
|
|
function GetUsuariosController: IUsuariosController;
|
|
|
|
|
|
function GetAppName: String;
|
|
|
|
|
|
function GetAppVersion: String;
|
2007-10-09 07:47:51 +00:00
|
|
|
|
function GetUsuarioActivo: TUsuario;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
protected
|
|
|
|
|
|
procedure InitializeInstance; virtual;
|
|
|
|
|
|
procedure DestroyInstance; virtual;
|
|
|
|
|
|
public
|
|
|
|
|
|
class function NewInstance: TObject; override;
|
|
|
|
|
|
procedure FreeInstance; override;
|
|
|
|
|
|
class function RefCount: Integer;
|
2007-10-09 07:47:51 +00:00
|
|
|
|
procedure CambarEmpresa(const AIDEmpresa : Integer);
|
2007-10-08 07:58:40 +00:00
|
|
|
|
property AppVersion : String read GetAppVersion;
|
|
|
|
|
|
property AppName : String read GetAppName;
|
|
|
|
|
|
property AppForm : TCustomForm read GetAppForm;
|
2007-10-09 07:47:51 +00:00
|
|
|
|
property EmpresaActiva : IBizEmpresa read FEmpresaActiva;
|
|
|
|
|
|
property UsuarioActivo : TUsuario read GetUsuarioActivo;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
property EmpresasController : IEmpresasController read GetEmpresasController;
|
|
|
|
|
|
property UsuariosController : IUsuariosController read GetUsuariosController;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
|
AppFactuGES : TAppFactuGES = nil;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
2007-10-09 07:47:51 +00:00
|
|
|
|
uDataModuleBase, uUsuariosViewRegister, uEmpresasViewRegister;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
|
Ref_Count : Integer = 0;
|
|
|
|
|
|
|
2007-10-09 07:47:51 +00:00
|
|
|
|
procedure TAppFactuGES.CambarEmpresa(const AIDEmpresa: Integer);
|
|
|
|
|
|
var
|
|
|
|
|
|
Aux : IBizEmpresa;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
begin
|
2007-10-09 07:47:51 +00:00
|
|
|
|
Aux := EmpresasController.Buscar(AIDEmpresa);
|
|
|
|
|
|
if Assigned(Aux) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
Aux.DataTable.Active := True;
|
|
|
|
|
|
if not Aux.IsEmpty then
|
|
|
|
|
|
FEmpresaActiva := Aux;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
2007-10-09 07:47:51 +00:00
|
|
|
|
procedure TAppFactuGES.DestroyInstance;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FreeAndNIL(FAppInfo);
|
2007-10-08 07:58:40 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TAppFactuGES.FreeInstance;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Dec(Ref_Count);
|
|
|
|
|
|
if (Ref_Count = 0) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
AppFactuGES := NIL;
|
|
|
|
|
|
|
2007-10-09 07:47:51 +00:00
|
|
|
|
// Destroy private variables here
|
|
|
|
|
|
DestroyInstance;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
|
|
|
|
|
inherited FreeInstance;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TAppFactuGES.GetAppForm: TCustomForm;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := Application.MainForm;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TAppFactuGES.GetAppName: String;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FAppInfo.ProductName;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TAppFactuGES.GetAppVersion: String;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FAppInfo.ProductVersion;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TAppFactuGES.GetEmpresasController: IEmpresasController;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FEmpresasController;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-09 07:47:51 +00:00
|
|
|
|
function TAppFactuGES.GetUsuarioActivo: TUsuario;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FUsuariosController.CurrentUser;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-08 07:58:40 +00:00
|
|
|
|
function TAppFactuGES.GetUsuariosController: IUsuariosController;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FUsuariosController;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TAppFactuGES.InitializeInstance;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FEmpresaActiva := NIL;
|
|
|
|
|
|
FAppInfo := TJclFileVersionInfo.Create(Application.ExeName);
|
|
|
|
|
|
FUsuariosController := TUsuariosController.Create;
|
|
|
|
|
|
FEmpresasController := TEmpresasController.Create;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
class function TAppFactuGES.NewInstance: TObject;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (not Assigned(AppFactuGES)) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
AppFactuGES := TAppFactuGES(inherited NewInstance);
|
|
|
|
|
|
// Initialize private variables here
|
|
|
|
|
|
AppFactuGES.InitializeInstance;
|
|
|
|
|
|
end;
|
|
|
|
|
|
Result := AppFactuGES;
|
|
|
|
|
|
Inc(Ref_Count);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
class function TAppFactuGES.RefCount: Integer;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := Ref_Count;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initialization
|
|
|
|
|
|
AppFactuGES := TAppFactuGES.Create;
|
|
|
|
|
|
|
|
|
|
|
|
// Pongo esto aqu<71> por ahora
|
|
|
|
|
|
uUsuariosViewRegister.RegisterViews;
|
2007-10-09 07:47:51 +00:00
|
|
|
|
uEmpresasViewRegister.RegisterViews;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
|
|
|
|
|
finalization
|
|
|
|
|
|
FreeAndNIL(AppFactuGES);
|
|
|
|
|
|
|
|
|
|
|
|
// Pongo esto aqu<71> por ahora
|
|
|
|
|
|
uUsuariosViewRegister.UnregisterViews;
|
2007-10-09 07:47:51 +00:00
|
|
|
|
uEmpresasViewRegister.UnregisterViews;
|
|
|
|
|
|
|
2007-10-08 07:58:40 +00:00
|
|
|
|
end.
|