2007-10-08 07:58:40 +00:00
|
|
|
|
unit uFactuGES_App;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
2008-01-13 21:37:20 +00:00
|
|
|
|
SysUtils, Classes, Forms, uBizUsuarios, uBizEmpresas, uControllerBase,
|
2008-11-10 11:29:57 +00:00
|
|
|
|
uEmpresasController, uUsuariosController, uHostManager, uModuleController;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
|
|
|
|
|
type
|
2009-03-05 12:14:37 +00:00
|
|
|
|
TAppFactuGES_Event = procedure;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
|
|
|
|
|
|
IAppSplashForm = interface
|
|
|
|
|
|
['{9905DF57-4476-42E6-A7CD-B1479A84E220}']
|
|
|
|
|
|
procedure Show;
|
|
|
|
|
|
procedure Hide;
|
|
|
|
|
|
procedure Update;
|
|
|
|
|
|
function GetMensaje: String;
|
|
|
|
|
|
procedure SetMensaje(const AMensaje : String);
|
|
|
|
|
|
property Mensaje : String read GetMensaje write SetMensaje;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
IAppFactuGES = interface
|
|
|
|
|
|
['{FB6A0F3C-C1D1-462D-AFD4-2A368F85E920}']
|
|
|
|
|
|
function GetMainForm: TCustomForm;
|
|
|
|
|
|
function GetEmpresasController: IEmpresasController;
|
|
|
|
|
|
function GetUsuariosController: IUsuariosController;
|
|
|
|
|
|
function GetAppName: String;
|
|
|
|
|
|
function GetAppVersion: String;
|
2008-02-28 19:35:19 +00:00
|
|
|
|
function GetAppFullName: String;
|
2008-01-15 18:26:46 +00:00
|
|
|
|
function GetUsuarioActivo: IBizUsuario;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
function GetEmpresaActiva: IBizEmpresa;
|
|
|
|
|
|
function GetModuleManager : THostManager;
|
|
|
|
|
|
function GetTerminated: Boolean;
|
|
|
|
|
|
|
2009-03-05 12:14:37 +00:00
|
|
|
|
function GetLoadModulesEvent : TAppFactuGES_Event;
|
|
|
|
|
|
procedure SetLoadModulesEvent (ALoadModulesEvent : TAppFactuGES_Event);
|
2007-10-22 07:39:39 +00:00
|
|
|
|
|
2009-03-05 12:14:37 +00:00
|
|
|
|
function GetDoMainFormEvent : TAppFactuGES_Event;
|
|
|
|
|
|
procedure SetDoMainFormEvent (AMainFormEvent : TAppFactuGES_Event);
|
|
|
|
|
|
|
|
|
|
|
|
function GetDoRefreshMainFormEvent : TAppFactuGES_Event;
|
|
|
|
|
|
procedure SetDoRefreshMainFormEvent (ARefreshMainFormEvent : TAppFactuGES_Event);
|
2007-10-22 07:39:39 +00:00
|
|
|
|
|
|
|
|
|
|
function GetAppSplashForm : IAppSplashForm;
|
|
|
|
|
|
procedure SetAppSplashForm (AAppSplashForm : IAppSplashForm);
|
|
|
|
|
|
|
2008-12-19 17:04:38 +00:00
|
|
|
|
procedure SeleccionarEmpresa;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
procedure CambiarEmpresa(const AIDEmpresa : Integer);
|
|
|
|
|
|
|
|
|
|
|
|
procedure ShowSplashForm;
|
|
|
|
|
|
procedure HideSplashForm;
|
|
|
|
|
|
|
|
|
|
|
|
procedure Run;
|
|
|
|
|
|
procedure Terminate;
|
|
|
|
|
|
|
2008-11-10 11:29:57 +00:00
|
|
|
|
function GetModule(AModuleName: String): TModuleController;
|
|
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
property AppVersion : String read GetAppVersion;
|
|
|
|
|
|
property AppName : String read GetAppName;
|
2008-02-28 19:35:19 +00:00
|
|
|
|
property AppFullName : String read GetAppFullName;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
property MainForm : TCustomForm read GetMainForm;
|
|
|
|
|
|
property EmpresaActiva : IBizEmpresa read GetEmpresaActiva;
|
2008-01-15 18:26:46 +00:00
|
|
|
|
property UsuarioActivo : IBizUsuario read GetUsuarioActivo;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
property EmpresasController : IEmpresasController read GetEmpresasController;
|
2008-03-27 17:01:26 +00:00
|
|
|
|
property UsuariosController : IUsuariosController read GetUsuariosController;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
property AppSplashForm : IAppSplashForm read GetAppSplashForm write SetAppSplashForm;
|
|
|
|
|
|
property ModuleManager : THostManager read GetModuleManager;
|
2009-03-05 12:14:37 +00:00
|
|
|
|
property DoMainFormEvent : TAppFactuGES_Event read GetDoMainFormEvent write SetDoMainFormEvent;
|
|
|
|
|
|
property DoLoadModulesEvent : TAppFactuGES_Event read GetLoadModulesEvent write SetLoadModulesEvent;
|
|
|
|
|
|
property DoRefreshMainFormEvent : TAppFactuGES_Event read GetDoRefreshMainFormEvent write SetDoRefreshMainFormEvent;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
property Terminated : Boolean read GetTerminated;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TAppFactuGES = class(TInterfacedObject, IAppFactuGES)
|
2007-10-08 07:58:40 +00:00
|
|
|
|
private
|
|
|
|
|
|
FEmpresasController : IEmpresasController;
|
|
|
|
|
|
FUsuariosController: IUsuariosController;
|
|
|
|
|
|
FEmpresaActiva: IBizEmpresa;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
FAppSplashForm : IAppSplashForm;
|
|
|
|
|
|
FHostManager : THostManager;
|
|
|
|
|
|
FTerminated : Boolean;
|
2007-11-19 19:13:37 +00:00
|
|
|
|
|
2009-03-05 12:14:37 +00:00
|
|
|
|
FDoMainFormEvent: TAppFactuGES_Event;
|
|
|
|
|
|
FDoLoadModulesEvent: TAppFactuGES_Event;
|
|
|
|
|
|
FDoRefreshMainFormEvent: TAppFactuGES_Event;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
|
|
|
|
|
|
function GetMainForm: TCustomForm;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
function GetEmpresasController: IEmpresasController;
|
|
|
|
|
|
function GetUsuariosController: IUsuariosController;
|
|
|
|
|
|
function GetAppName: String;
|
|
|
|
|
|
function GetAppVersion: String;
|
2008-02-28 19:35:19 +00:00
|
|
|
|
function GetAppFullName: String;
|
2008-01-15 18:26:46 +00:00
|
|
|
|
function GetUsuarioActivo: IBizUsuario;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
function GetEmpresaActiva: IBizEmpresa;
|
|
|
|
|
|
function GetModuleManager : THostManager;
|
|
|
|
|
|
function GetTerminated: Boolean;
|
|
|
|
|
|
|
2009-03-05 12:14:37 +00:00
|
|
|
|
function GetLoadModulesEvent : TAppFactuGES_Event;
|
|
|
|
|
|
procedure SetLoadModulesEvent (ALoadModulesEvent : TAppFactuGES_Event);
|
|
|
|
|
|
|
|
|
|
|
|
function GetDoMainFormEvent : TAppFactuGES_Event;
|
|
|
|
|
|
procedure SetDoMainFormEvent (AMainFormEvent : TAppFactuGES_Event);
|
2007-10-22 07:39:39 +00:00
|
|
|
|
|
2009-03-05 12:14:37 +00:00
|
|
|
|
function GetDoRefreshMainFormEvent : TAppFactuGES_Event;
|
|
|
|
|
|
procedure SetDoRefreshMainFormEvent (ARefreshMainFormEvent : TAppFactuGES_Event);
|
2007-10-22 07:39:39 +00:00
|
|
|
|
|
|
|
|
|
|
function GetAppSplashForm : IAppSplashForm;
|
|
|
|
|
|
procedure SetAppSplashForm (AAppSplashForm : IAppSplashForm);
|
|
|
|
|
|
|
|
|
|
|
|
procedure AfterLoadModule(Sender: TObject; AModuleInfo: TModuleInfo);
|
|
|
|
|
|
procedure RegisterModule(AModuleInfo : TModuleInfo);
|
2007-10-08 07:58:40 +00:00
|
|
|
|
protected
|
2007-10-22 07:39:39 +00:00
|
|
|
|
procedure DoMainForm;
|
2009-03-05 12:14:37 +00:00
|
|
|
|
procedure DoRefreshMainForm;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
|
|
|
|
|
|
procedure CargarModulos;
|
|
|
|
|
|
procedure ShowSplashForm;
|
|
|
|
|
|
procedure HideSplashForm;
|
|
|
|
|
|
procedure UpdateSplashForm;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
public
|
2007-10-22 07:39:39 +00:00
|
|
|
|
constructor Create; virtual;
|
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
|
|
|
|
|
|
procedure Run;
|
|
|
|
|
|
procedure Terminate;
|
|
|
|
|
|
|
2008-12-19 17:04:38 +00:00
|
|
|
|
procedure SeleccionarEmpresa;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
procedure CambiarEmpresa(const AIDEmpresa : Integer);
|
|
|
|
|
|
|
2008-11-10 11:29:57 +00:00
|
|
|
|
function GetModule(AModuleName: String): TModuleController;
|
|
|
|
|
|
|
2007-10-08 07:58:40 +00:00
|
|
|
|
property AppVersion : String read GetAppVersion;
|
|
|
|
|
|
property AppName : String read GetAppName;
|
2008-02-28 19:35:19 +00:00
|
|
|
|
property AppFullName : String read GetAppFullName;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
property MainForm : TCustomForm read GetMainForm;
|
|
|
|
|
|
property EmpresaActiva : IBizEmpresa read GetEmpresaActiva;
|
|
|
|
|
|
property AppSplashForm : IAppSplashForm read GetAppSplashForm write SetAppSplashForm;
|
2008-01-15 18:26:46 +00:00
|
|
|
|
property UsuarioActivo : IBizUsuario read GetUsuarioActivo;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
property EmpresasController : IEmpresasController read GetEmpresasController;
|
|
|
|
|
|
property UsuariosController : IUsuariosController read GetUsuariosController;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
property ModuleManager : THostManager read GetModuleManager;
|
2009-03-05 12:14:37 +00:00
|
|
|
|
property DoMainFormEvent : TAppFactuGES_Event read GetDoMainFormEvent write SetDoMainFormEvent;
|
|
|
|
|
|
property DoLoadModulesEvent : TAppFactuGES_Event read GetLoadModulesEvent write SetLoadModulesEvent;
|
|
|
|
|
|
property DoRefreshMainFormEvent : TAppFactuGES_Event read GetDoRefreshMainFormEvent write SetDoRefreshMainFormEvent;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
property Terminated : Boolean read GetTerminated;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
var
|
2007-10-22 07:39:39 +00:00
|
|
|
|
AppFactuGES : IAppFactuGES = nil;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
|
|
|
|
|
implementation
|
2009-12-17 16:08:35 +00:00
|
|
|
|
{$INCLUDE ..\FactuGES.inc}
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
|
|
|
|
|
uses
|
2008-12-19 17:04:38 +00:00
|
|
|
|
Windows, Dialogs, JSDialog, JSDialogs, uDialogUtils, cxControls, uUsuariosViewRegister,
|
2008-06-02 18:09:15 +00:00
|
|
|
|
uEmpresasViewRegister, uAppInfoUtils, uDMBase;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
procedure TAppFactuGES.CambiarEmpresa(const AIDEmpresa: Integer);
|
2007-10-09 07:47:51 +00:00
|
|
|
|
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;
|
2008-06-02 18:09:15 +00:00
|
|
|
|
|
|
|
|
|
|
if Assigned(FEmpresaActiva) then
|
|
|
|
|
|
dmBase.dxPrintStyleManager1Style1.PrinterPage.PageFooter.LeftTitle.Add(FEmpresaActiva.NOMBRE);
|
2007-10-09 07:47:51 +00:00
|
|
|
|
end;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
procedure TAppFactuGES.CargarModulos;
|
2007-10-09 07:47:51 +00:00
|
|
|
|
begin
|
2008-12-09 16:39:48 +00:00
|
|
|
|
UpdateSplashForm;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
if not Assigned(FDoLoadModulesEvent) then
|
|
|
|
|
|
raise Exception.Create('Evento para la carga de los m<>dulos de la aplicaci<63>n no asignado (CargarModulos)');
|
|
|
|
|
|
|
|
|
|
|
|
FDoLoadModulesEvent();
|
2008-12-09 16:39:48 +00:00
|
|
|
|
UpdateSplashForm;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
constructor TAppFactuGES.Create;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
begin
|
2007-10-22 07:39:39 +00:00
|
|
|
|
FTerminated := False;
|
|
|
|
|
|
FDoMainFormEvent := NIL;
|
|
|
|
|
|
FDoLoadModulesEvent := NIL;
|
|
|
|
|
|
FAppSplashForm := NIL;
|
|
|
|
|
|
FEmpresaActiva := NIL;
|
|
|
|
|
|
FUsuariosController := NIL; // Se crea la primera vez que se usa
|
2008-01-13 21:37:20 +00:00
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
FEmpresasController := NIL; // Se crea la primera vez que se usa
|
|
|
|
|
|
|
|
|
|
|
|
FHostManager := THostManager.Create(NIL);
|
|
|
|
|
|
with FHostManager do
|
2007-10-08 07:58:40 +00:00
|
|
|
|
begin
|
2007-10-22 07:39:39 +00:00
|
|
|
|
OnAfterLoad := AfterLoadModule;
|
|
|
|
|
|
// Ruta por defecto de los m<>dulos
|
2008-03-27 17:01:26 +00:00
|
|
|
|
BPLPath := ExtractFilePath(Application.ExeName) + PathDelim;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
end;
|
|
|
|
|
|
end;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
destructor TAppFactuGES.Destroy;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FAppSplashForm := NIL;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
FHostManager.UnloadModules;
|
|
|
|
|
|
FreeAndNIL(FHostManager);
|
|
|
|
|
|
|
|
|
|
|
|
FEmpresaActiva := NIL;
|
|
|
|
|
|
FUsuariosController := NIL;
|
|
|
|
|
|
FEmpresasController := NIL;
|
|
|
|
|
|
|
|
|
|
|
|
inherited;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
procedure TAppFactuGES.DoMainForm;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if not Assigned(FDoMainFormEvent) then
|
|
|
|
|
|
raise Exception.Create('Evento para la creaci<63>n del formulario principal no asignado (DoMainForm)');
|
|
|
|
|
|
|
|
|
|
|
|
FDoMainFormEvent();
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TAppFactuGES.GetMainForm: TCustomForm;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
begin
|
|
|
|
|
|
Result := Application.MainForm;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2009-03-05 12:14:37 +00:00
|
|
|
|
function TAppFactuGES.GetDoMainFormEvent: TAppFactuGES_Event;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
begin
|
|
|
|
|
|
Result := FDoMainFormEvent;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2009-03-05 12:14:37 +00:00
|
|
|
|
function TAppFactuGES.GetDoRefreshMainFormEvent: TAppFactuGES_Event;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FDoRefreshMainFormEvent;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-02-28 19:35:19 +00:00
|
|
|
|
function TAppFactuGES.GetAppFullName: String;
|
|
|
|
|
|
begin
|
2008-03-27 17:01:26 +00:00
|
|
|
|
Result := uAppInfoUtils.GetAppFullName;
|
2008-02-28 19:35:19 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-08 07:58:40 +00:00
|
|
|
|
function TAppFactuGES.GetAppName: String;
|
|
|
|
|
|
begin
|
2008-03-27 17:01:26 +00:00
|
|
|
|
Result := uAppInfoUtils.GetAppName;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
function TAppFactuGES.GetAppSplashForm: IAppSplashForm;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FAppSplashForm;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-08 07:58:40 +00:00
|
|
|
|
function TAppFactuGES.GetAppVersion: String;
|
|
|
|
|
|
begin
|
2008-03-27 17:01:26 +00:00
|
|
|
|
Result := uAppInfoUtils.GetAppVersion;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
function TAppFactuGES.GetEmpresaActiva: IBizEmpresa;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FEmpresaActiva;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-08 07:58:40 +00:00
|
|
|
|
function TAppFactuGES.GetEmpresasController: IEmpresasController;
|
|
|
|
|
|
begin
|
2007-10-22 07:39:39 +00:00
|
|
|
|
if not Assigned(FEmpresasController) then
|
|
|
|
|
|
FEmpresasController := TEmpresasController.Create;
|
|
|
|
|
|
|
2007-10-08 07:58:40 +00:00
|
|
|
|
Result := FEmpresasController;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2009-03-05 12:14:37 +00:00
|
|
|
|
function TAppFactuGES.GetLoadModulesEvent: TAppFactuGES_Event;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
begin
|
|
|
|
|
|
Result := FDoLoadModulesEvent;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-10 11:29:57 +00:00
|
|
|
|
function TAppFactuGES.GetModule(AModuleName: String): TModuleController;
|
|
|
|
|
|
var
|
|
|
|
|
|
i : integer;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := NIL;
|
|
|
|
|
|
for i := 0 to ModuleManager.ModulesCount - 1 do
|
|
|
|
|
|
if ModuleManager.Modules[i].Module.ModuleName = AModuleName then
|
|
|
|
|
|
Result := ModuleManager.Modules[i].Module
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
function TAppFactuGES.GetModuleManager: THostManager;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FHostManager;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TAppFactuGES.GetTerminated: Boolean;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FTerminated;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-01-15 18:26:46 +00:00
|
|
|
|
function TAppFactuGES.GetUsuarioActivo: IBizUsuario;
|
2007-10-09 07:47:51 +00:00
|
|
|
|
begin
|
2007-10-22 07:39:39 +00:00
|
|
|
|
Result := UsuariosController.CurrentUser;
|
2007-10-09 07:47:51 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-08 07:58:40 +00:00
|
|
|
|
function TAppFactuGES.GetUsuariosController: IUsuariosController;
|
|
|
|
|
|
begin
|
2007-10-22 07:39:39 +00:00
|
|
|
|
if not Assigned(FUsuariosController) then
|
|
|
|
|
|
FUsuariosController := TUsuariosController.Create;
|
|
|
|
|
|
|
2007-10-08 07:58:40 +00:00
|
|
|
|
Result := FUsuariosController;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
procedure TAppFactuGES.HideSplashForm;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
begin
|
2007-10-22 07:39:39 +00:00
|
|
|
|
if not Assigned(FAppSplashForm) then
|
|
|
|
|
|
raise Exception.Create('AppSplashForm no asignado (HideSplashForm)');
|
|
|
|
|
|
|
|
|
|
|
|
FAppSplashForm.Hide;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
procedure TAppFactuGES.AfterLoadModule(Sender: TObject;
|
|
|
|
|
|
AModuleInfo: TModuleInfo);
|
2007-10-08 07:58:40 +00:00
|
|
|
|
begin
|
2007-10-22 07:39:39 +00:00
|
|
|
|
RegisterModule(AModuleInfo);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2009-03-05 12:14:37 +00:00
|
|
|
|
procedure TAppFactuGES.DoRefreshMainForm;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if not Assigned(FDoRefreshMainFormEvent) then
|
|
|
|
|
|
raise Exception.Create('Evento para el refresco del formulario principal no asignado (DoRefreshMainForm)');
|
|
|
|
|
|
|
|
|
|
|
|
FDoRefreshMainFormEvent();
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
procedure TAppFactuGES.RegisterModule(AModuleInfo: TModuleInfo);
|
|
|
|
|
|
begin
|
|
|
|
|
|
AppSplashForm.Mensaje := 'Cargando ''' + AModuleInfo.Module.ModuleName + '''...';
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TAppFactuGES.Run;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if UsuariosController.StartLogin then
|
2007-10-08 07:58:40 +00:00
|
|
|
|
begin
|
2007-10-22 07:39:39 +00:00
|
|
|
|
ShowHourglassCursor;
|
2008-12-09 16:39:48 +00:00
|
|
|
|
ShowSplashForm;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
try
|
|
|
|
|
|
CargarModulos;
|
|
|
|
|
|
DoMainForm;
|
2009-03-05 12:14:37 +00:00
|
|
|
|
SeleccionarEmpresa;
|
|
|
|
|
|
DoRefreshMainForm;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
finally
|
|
|
|
|
|
HideSplashForm;
|
2008-12-09 16:39:48 +00:00
|
|
|
|
HideHourglassCursor;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
end;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
end;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
Application.Run;
|
|
|
|
|
|
Terminate;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
procedure TAppFactuGES.SetDoMainFormEvent(
|
2009-03-05 12:14:37 +00:00
|
|
|
|
AMainFormEvent: TAppFactuGES_Event);
|
2007-10-08 07:58:40 +00:00
|
|
|
|
begin
|
2007-10-22 07:39:39 +00:00
|
|
|
|
FDoMainFormEvent := AMainFormEvent;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
2009-03-05 12:14:37 +00:00
|
|
|
|
procedure TAppFactuGES.SetDoRefreshMainFormEvent(
|
|
|
|
|
|
ARefreshMainFormEvent: TAppFactuGES_Event);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FDoRefreshMainFormEvent := ARefreshMainFormEvent;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-12-19 17:04:38 +00:00
|
|
|
|
procedure TAppFactuGES.SeleccionarEmpresa;
|
|
|
|
|
|
var
|
|
|
|
|
|
JsDialog: TJSDialog;
|
|
|
|
|
|
AEmpresas: IBizEmpresa;
|
|
|
|
|
|
AEmpresasController: IEmpresasController;
|
|
|
|
|
|
begin
|
|
|
|
|
|
JsDialog := TJSDialog.Create(nil);
|
|
|
|
|
|
try
|
|
|
|
|
|
JsDialog.Content.Add('Selecci<63>n de empresa');
|
|
|
|
|
|
JsDialog.Instruction.Text := 'Elija la empresa con la que desea trabajar.';
|
|
|
|
|
|
JsDialog.DialogOptions := [doCommandLinks, doModal];
|
2008-12-22 10:38:38 +00:00
|
|
|
|
JsDialog.ButtonBar.Buttons := [cbCancel];
|
2008-12-19 17:04:38 +00:00
|
|
|
|
JsDialog.Width := 600;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//A<>adimos las diferentes empresas que existan
|
|
|
|
|
|
AEmpresasController := TEmpresasController.Create;
|
|
|
|
|
|
AEmpresas := AEmpresasController.BuscarTodos;
|
|
|
|
|
|
AEmpresas.DataTable.Active := True;
|
|
|
|
|
|
|
|
|
|
|
|
AEmpresas.Datatable.First;
|
|
|
|
|
|
while not AEmpresas.Datatable.eof do
|
|
|
|
|
|
begin
|
|
|
|
|
|
with JsDialog.CustomButtons.Add do
|
|
|
|
|
|
begin
|
|
|
|
|
|
Caption := AEmpresas.NIF_CIF + ' - ' + AEmpresas.NOMBRE;
|
|
|
|
|
|
Value := AEmpresas.ID;
|
|
|
|
|
|
end;
|
|
|
|
|
|
AEmpresas.DataTable.Next;
|
|
|
|
|
|
end;
|
|
|
|
|
|
AEmpresas.DataTable.First;
|
|
|
|
|
|
|
2009-12-17 16:08:35 +00:00
|
|
|
|
{$IFDEF MULTIEMPRESA}
|
2008-12-19 17:04:38 +00:00
|
|
|
|
if JsDialog.Execute <> IDCANCEL then
|
|
|
|
|
|
if JsDialog.CustomButtonResult > 0 then
|
|
|
|
|
|
CambiarEmpresa(JsDialog.CustomButtonResult);
|
2009-12-17 16:08:35 +00:00
|
|
|
|
{$ELSE}
|
|
|
|
|
|
CambiarEmpresa(AEmpresas.ID);
|
|
|
|
|
|
{$ENDIF}
|
2008-12-19 17:04:38 +00:00
|
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
|
FreeAndNIL(JsDialog);
|
|
|
|
|
|
AEmpresasController:= NIL;
|
|
|
|
|
|
AEmpresas := NIL;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
procedure TAppFactuGES.SetAppSplashForm(AAppSplashForm: IAppSplashForm);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FAppSplashForm := AAppSplashForm;
|
|
|
|
|
|
end;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
procedure TAppFactuGES.SetLoadModulesEvent(
|
2009-03-05 12:14:37 +00:00
|
|
|
|
ALoadModulesEvent: TAppFactuGES_Event);
|
2007-10-22 07:39:39 +00:00
|
|
|
|
begin
|
|
|
|
|
|
FDoLoadModulesEvent := ALoadModulesEvent;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TAppFactuGES.ShowSplashForm;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if not Assigned(FAppSplashForm) then
|
|
|
|
|
|
raise Exception.Create('AppSplashForm no asignado (ShowSplashForm)');
|
|
|
|
|
|
|
|
|
|
|
|
FAppSplashForm.Show;
|
|
|
|
|
|
FAppSplashForm.Update;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TAppFactuGES.Terminate;
|
|
|
|
|
|
begin
|
2011-04-13 19:18:01 +00:00
|
|
|
|
if Assigned(UsuarioActivo) then
|
|
|
|
|
|
UsuariosController.Logoff;
|
|
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
ModuleManager.UnloadModules;
|
|
|
|
|
|
FTerminated := True;
|
|
|
|
|
|
end;
|
2007-10-08 07:58:40 +00:00
|
|
|
|
|
2007-10-22 07:39:39 +00:00
|
|
|
|
procedure TAppFactuGES.UpdateSplashForm;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FAppSplashForm.Update;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
initialization
|
2007-10-08 07:58:40 +00:00
|
|
|
|
// 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
|
|
|
|
|
|
// Pongo esto aqu<71> por ahora
|
2007-10-24 18:54:18 +00:00
|
|
|
|
AppFactuGES := NIL;
|
|
|
|
|
|
|
2007-10-08 07:58:40 +00:00
|
|
|
|
uUsuariosViewRegister.UnregisterViews;
|
2007-10-09 07:47:51 +00:00
|
|
|
|
uEmpresasViewRegister.UnregisterViews;
|
2007-10-22 07:39:39 +00:00
|
|
|
|
|
2007-10-08 07:58:40 +00:00
|
|
|
|
end.
|