git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES/trunk@2 c93665c3-c93d-084d-9b98-7d5f4a9c3376
143 lines
3.5 KiB
ObjectPascal
143 lines
3.5 KiB
ObjectPascal
unit uPluginEmpresas;
|
|
|
|
interface
|
|
|
|
uses
|
|
uModuleController, uInterfaces, uHostManager, Menus, Classes, ActnList,
|
|
ImgList, Controls, PngImageList, uBizEmpresas,
|
|
uEmpresasController;
|
|
|
|
type
|
|
IEmpresasPlugin = interface(IInterface)
|
|
['{4E732376-FFD0-4E72-846A-224A6E27FA85}']
|
|
function Empresas : TStringList;
|
|
function Controller : IEmpresasController;
|
|
end;
|
|
|
|
TPluginEmpresas = class(TModuleController, IEmpresasPlugin)
|
|
ExtraImages: TPngImageList;
|
|
LargeImages: TPngImageList;
|
|
MainMenu: TMainMenu;
|
|
ModuleActionList: TActionList;
|
|
SmallImages: TPngImageList;
|
|
Empresas1: TMenuItem;
|
|
Preferencias1: TMenuItem;
|
|
N1: TMenuItem;
|
|
Gestindeempresas1: TMenuItem;
|
|
Datosde1: TMenuItem;
|
|
actDatosDe: TAction;
|
|
actPreferencias: TAction;
|
|
actGestionEmpresas: TAction;
|
|
N2: TMenuItem;
|
|
actSucursales: TAction;
|
|
Sucursales1: TMenuItem;
|
|
N3: TMenuItem;
|
|
actNuevaEmpresa: TAction;
|
|
procedure actDatosDeUpdate(Sender: TObject);
|
|
procedure actDatosDeExecute(Sender: TObject);
|
|
procedure actNuevaEmpresaExecute(Sender: TObject);
|
|
protected
|
|
function Empresas : TStringList;
|
|
function Controller : IEmpresasController;
|
|
public
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses
|
|
Forms, Dialogs, uGUIBase, uCustomEditor, SysUtils,
|
|
uDataModuleUsuarios, uEmpresasViewRegister;
|
|
|
|
function GetModule : TModuleController;
|
|
begin
|
|
Result := TPluginEmpresas.Create(NIL);
|
|
end;
|
|
|
|
exports
|
|
GetModule name GET_MODULE_FUNC;
|
|
|
|
{
|
|
******************************* TModuleEmpresas *******************************
|
|
}
|
|
procedure TPluginEmpresas.actDatosDeExecute(Sender: TObject);
|
|
var
|
|
AController : IEmpresasController;
|
|
begin
|
|
AController := TEmpresasController.Create;
|
|
AController.Ver(dmUsuarios.EmpresaActual);
|
|
end;
|
|
|
|
procedure TPluginEmpresas.actDatosDeUpdate(Sender: TObject);
|
|
begin
|
|
with (Sender as TAction) do
|
|
begin
|
|
if Assigned(dmUsuarios.EmpresaActual) then
|
|
begin
|
|
Enabled := True;
|
|
Caption := 'Datos de ' + dmUsuarios.EmpresaActual.NOMBRE
|
|
end
|
|
else begin
|
|
Enabled := False;
|
|
Caption := 'Datos de la empresa';
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TPluginEmpresas.actNuevaEmpresaExecute(Sender: TObject);
|
|
var
|
|
AEmpresasController : IEmpresasController;
|
|
AEmpresa : IBizEmpresa;
|
|
begin
|
|
AEmpresasController := TEmpresasController.Create;
|
|
AEmpresa := AEmpresasController.Nuevo;
|
|
try
|
|
AEmpresasController.Ver(AEmpresa);
|
|
finally
|
|
AEmpresa := NIL;
|
|
end;
|
|
end;
|
|
|
|
function TPluginEmpresas.Controller: IEmpresasController;
|
|
begin
|
|
Result := TEmpresasController.Create;
|
|
end;
|
|
|
|
function TPluginEmpresas.Empresas: TStringList;
|
|
var
|
|
AEmpresasController : IEmpresasController;
|
|
AEmpresas : IBizEmpresa;
|
|
begin
|
|
AEmpresasController := TEmpresasController.Create;
|
|
AEmpresas := AEmpresasController.BuscarTodos;
|
|
try
|
|
Result := AEmpresasController.ToStringList(AEmpresas);
|
|
finally
|
|
AEmpresasController := NIL;
|
|
end;
|
|
end;
|
|
|
|
constructor TPluginEmpresas.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
uEmpresasViewRegister.RegisterViews;
|
|
end;
|
|
|
|
destructor TPluginEmpresas.Destroy;
|
|
begin
|
|
uEmpresasViewRegister.UnregisterViews;
|
|
inherited;
|
|
end;
|
|
|
|
|
|
initialization
|
|
uHostManager.RegisterModuleClass(TPluginEmpresas);
|
|
|
|
finalization
|
|
uHostManager.UnRegisterModuleClass(TPluginEmpresas);
|
|
|
|
end.
|