git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES2/trunk@97 f4e31baf-9722-1c47-927c-6f952f962d4b
158 lines
4.2 KiB
ObjectPascal
158 lines
4.2 KiB
ObjectPascal
unit uTiendasEmpresaController;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Forms, Classes, Controls, Contnrs, SysUtils, uDADataTable,
|
|
uIntegerListUtils, uBizEmpresasTiendas, uIDataModuleEmpresas;
|
|
|
|
type
|
|
ITiendasEmpresaController = interface
|
|
['{9B6CB172-F32C-414F-A0E2-99920CAF88FB}']
|
|
// procedure CopiarDireccionFiscal(AContacto: IBizContacto; ADireccion: IBizTiendasEmpresa; AAnadir : Boolean = True);
|
|
procedure Ver(ATienda : IBizEmpresasTiendas);
|
|
// function Localizar(ADirecciones: IBizTiendasEmpresa; const ID : Integer): Boolean;
|
|
function DarListaTiendas: TStringList;
|
|
function DarListaIDTiendas: TIntegerList;
|
|
end;
|
|
|
|
TTiendasEmpresaController = class(TInterfacedObject, ITiendasEmpresaController)
|
|
private
|
|
FDataModule : IDataModuleEmpresas;
|
|
public
|
|
// procedure CopiarDireccionFiscal(AContacto: IBizContacto; ADireccion: IBizTiendasEmpresa; AAnadir : Boolean = True);
|
|
procedure Ver(ATienda : IBizEmpresasTiendas);
|
|
function DarListaTiendas: TStringList;
|
|
function DarListaIDTiendas: TIntegerList;
|
|
// function Localizar(ADirecciones: IBizTiendasEmpresa; const ID : Integer): Boolean;
|
|
constructor Create; virtual;
|
|
destructor Destroy; override;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{ TTiendasEmpresaController }
|
|
|
|
uses
|
|
uDataModuleEmpresas, schEmpresasClient_Intf, uIEditorTiendaEmpresa,
|
|
uEditorRegistryUtils, cxControls, uFactuGES_App;
|
|
|
|
{
|
|
procedure TTiendasEmpresaController.CopiarDireccionFiscal(
|
|
AContacto: IBizContacto; ADireccion: IBizTiendasEmpresa;
|
|
AAnadir: Boolean);
|
|
begin
|
|
if not Assigned(AContacto) then
|
|
raise Exception.Create ('Contacto no asignado (CopiarDireccionFiscal)');
|
|
|
|
if not Assigned(ADireccion) then
|
|
raise Exception.Create ('Dirección no asignada (CopiarDireccionFiscal)');
|
|
|
|
if AAnadir then
|
|
ADireccion.DataTable.Insert
|
|
else
|
|
ADireccion.DataTable.Edit;
|
|
try
|
|
with ADireccion do
|
|
begin
|
|
NOMBRE := 'Dirección de entrega';
|
|
CALLE := AContacto.CALLE;
|
|
POBLACION := AContacto.POBLACION;
|
|
PROVINCIA := AContacto.PROVINCIA;
|
|
CODIGO_POSTAL := AContacto.CODIGO_POSTAL;
|
|
TELEFONO := AContacto.TELEFONO_1;
|
|
EMAIL := AContacto.EMAIL_1;
|
|
end;
|
|
finally
|
|
ADireccion.DataTable.Post;
|
|
end;
|
|
end;
|
|
}
|
|
|
|
constructor TTiendasEmpresaController.Create;
|
|
begin
|
|
inherited;
|
|
FDataModule := TDataModuleEmpresas.Create(Nil);
|
|
end;
|
|
|
|
function TTiendasEmpresaController.DarListaIDTiendas: TIntegerList;
|
|
begin
|
|
Result := TIntegerList.Create;
|
|
with Result do
|
|
begin
|
|
Add(CTE_ID_TODAS); //Todas las tiendas
|
|
AppFactuGES.EmpresaActiva.Tiendas.DataTable.First;
|
|
while not AppFactuGES.EmpresaActiva.Tiendas.DataTable.EOF do
|
|
begin
|
|
Add(AppFactuGES.EmpresaActiva.Tiendas.ID);
|
|
AppFactuGES.EmpresaActiva.Tiendas.DataTable.Next;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
function TTiendasEmpresaController.DarListaTiendas: TStringList;
|
|
begin
|
|
Result := TStringList.Create;
|
|
with Result do
|
|
begin
|
|
Append(CTE_TODAS); //Todas las tiendas
|
|
AppFactuGES.EmpresaActiva.Tiendas.DataTable.First;
|
|
while not AppFactuGES.EmpresaActiva.Tiendas.DataTable.EOF do
|
|
begin
|
|
Append(AppFactuGES.EmpresaActiva.Tiendas.NOMBRE);
|
|
AppFactuGES.EmpresaActiva.Tiendas.DataTable.Next;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
destructor TTiendasEmpresaController.Destroy;
|
|
begin
|
|
FDataModule := Nil;
|
|
inherited;
|
|
end;
|
|
|
|
{
|
|
function TTiendasEmpresaController.Localizar(
|
|
ADirecciones: IBizTiendasEmpresa; const ID: Integer): Boolean;
|
|
begin
|
|
Result := True;
|
|
ShowHourglassCursor;
|
|
try
|
|
with ADirecciones.DataTable do
|
|
begin
|
|
DisableControls;
|
|
First;
|
|
if not Locate(fld_TiendasEmpresaID, ID, []) then
|
|
Result := False;
|
|
EnableControls;
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
}
|
|
|
|
procedure TTiendasEmpresaController.Ver(ATienda: IBizEmpresasTiendas);
|
|
var
|
|
AEditor : IEditorTiendaEmpresa;
|
|
begin
|
|
AEditor := NIL;
|
|
ShowHourglassCursor;
|
|
try
|
|
CreateEditor('EditorTiendaEmpresa', IEditorTiendaEmpresa, AEditor);
|
|
if Assigned(AEditor) then
|
|
with AEditor do
|
|
begin
|
|
Tienda := ATienda;
|
|
Controller := Self;
|
|
ShowModal;
|
|
Release;
|
|
end;
|
|
finally
|
|
AEditor := NIL;
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
end.
|