git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@3 0c75b7a4-871f-7646-8a2f-f78d34cc349f
175 lines
4.6 KiB
ObjectPascal
175 lines
4.6 KiB
ObjectPascal
unit uProveedoresController;
|
|
|
|
interface
|
|
|
|
uses
|
|
uCustomEditor,
|
|
uContactosController, uBizContactos, uBizDireccionesContacto, uDireccionesContactoController,
|
|
uIEditorProveedores, uIEditorProveedor, uIDataModuleContactos, uIDataModuleProveedores;
|
|
|
|
type
|
|
IProveedoresController = interface(IContactosController)
|
|
['{50F10D01-5120-470D-A61D-99FE8A76DF93}']
|
|
function BuscarTodosTiendaWeb: IBizProveedor;
|
|
function ElegirDireccionEntrega(ADirecciones: IBizDireccionesContacto; AMensaje: String): IBizDireccionesContacto;
|
|
end;
|
|
|
|
TProveedoresController = class(TContactosController, IProveedoresController)
|
|
protected
|
|
FDireccionesController : IDireccionesContactoController;
|
|
|
|
public
|
|
constructor Create; override;
|
|
destructor Destroy; override;
|
|
|
|
function Buscar(const ID: Integer): IBizContacto; override;
|
|
function BuscarTodos: IBizContacto; override;
|
|
function BuscarTodosTiendaWeb: IBizProveedor;
|
|
function Nuevo : IBizContacto; override;
|
|
procedure Ver(AContacto : IBizContacto); override;
|
|
procedure VerTodos(AContactos: IBizContacto); override;
|
|
function ElegirContacto(AContactos : IBizContacto;
|
|
AMensaje: String; AMultiSelect: Boolean): IBizContacto; override;
|
|
function ElegirDireccionEntrega(ADirecciones: IBizDireccionesContacto;
|
|
AMensaje: String): IBizDireccionesContacto;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
SysUtils, cxControls, Dialogs, uDataModuleProveedores, uEditorRegistryUtils,
|
|
uDataTableUtils, uDADataTable, DB, schContactosClient_Intf,
|
|
uIEditorElegirProveedores, Controls, uIEditorElegirDireccionEntrega;
|
|
|
|
{ TProveedoresController }
|
|
|
|
function TProveedoresController.Buscar(const ID: Integer): IBizContacto;
|
|
begin
|
|
Result := (FDataModule as IDataModuleProveedores).GetItem(ID);
|
|
FiltrarEmpresa(Result);
|
|
end;
|
|
|
|
function TProveedoresController.BuscarTodos: IBizContacto;
|
|
begin
|
|
Result := (FDataModule as IDataModuleProveedores).GetItems;
|
|
FiltrarEmpresa(Result);
|
|
end;
|
|
|
|
function TProveedoresController.BuscarTodosTiendaWeb: IBizProveedor;
|
|
begin
|
|
Result := (FDataModule as IDataModuleProveedores).GetItemsTiendaWeb;
|
|
FiltrarEmpresa(Result);
|
|
end;
|
|
|
|
constructor TProveedoresController.Create;
|
|
begin
|
|
inherited;
|
|
FDataModule := TDataModuleProveedores.Create(Nil);
|
|
FDireccionesController := TDireccionesContactoController.Create;
|
|
end;
|
|
|
|
destructor TProveedoresController.Destroy;
|
|
begin
|
|
FDireccionesController := NIL;
|
|
inherited;
|
|
end;
|
|
|
|
function TProveedoresController.ElegirContacto(AContactos: IBizContacto;
|
|
AMensaje: String; AMultiSelect: Boolean): IBizContacto;
|
|
var
|
|
AEditor : IEditorElegirProveedores;
|
|
begin
|
|
Result := NIL;
|
|
|
|
CreateEditor('EditorElegirProveedores', IEditorElegirProveedores, AEditor);
|
|
try
|
|
with AEditor do
|
|
begin
|
|
Contactos := AContactos;
|
|
Controller := Self;
|
|
MultiSelect := AMultiSelect;
|
|
Mensaje := AMensaje;
|
|
if IsPositiveResult(ShowModal) then
|
|
Result := ContactosSeleccionados;
|
|
Release;
|
|
end;
|
|
finally
|
|
AEditor := NIL;
|
|
end;
|
|
end;
|
|
|
|
function TProveedoresController.ElegirDireccionEntrega(
|
|
ADirecciones: IBizDireccionesContacto;
|
|
AMensaje: String): IBizDireccionesContacto;
|
|
var
|
|
AEditor : IEditorElegirDireccionEntrega;
|
|
begin
|
|
Result := NIL;
|
|
|
|
CreateEditor('EditorElegirDireccionEntrega', IEditorElegirDireccionEntrega, AEditor);
|
|
try
|
|
with AEditor do
|
|
begin
|
|
Direccion := ADirecciones;
|
|
Mensaje := AMensaje;
|
|
if IsPositiveResult(ShowModal) then
|
|
Result := DireccionSeleccionada;
|
|
Release;
|
|
end;
|
|
finally
|
|
AEditor := NIL;
|
|
end;
|
|
end;
|
|
|
|
function TProveedoresController.Nuevo: IBizContacto;
|
|
var
|
|
AContacto : IBizProveedor;
|
|
begin
|
|
AContacto := (FDataModule as IDataModuleProveedores).NewItem;
|
|
FiltrarEmpresa(AContacto);
|
|
AContacto.DataTable.Active := True;
|
|
AContacto.Insert;
|
|
Result := AContacto;
|
|
end;
|
|
|
|
procedure TProveedoresController.Ver(AContacto: IBizContacto);
|
|
var
|
|
AEditor : IEditorProveedor;
|
|
begin
|
|
AEditor := NIL;
|
|
ShowHourglassCursor;
|
|
try
|
|
CreateEditor('EditorProveedor', IEditorProveedor, AEditor);
|
|
with AEditor do
|
|
begin
|
|
Contacto := AContacto;
|
|
Controller := Self;
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
|
|
if Assigned(AEditor) then
|
|
try
|
|
AEditor.ShowModal;
|
|
AEditor.Release;
|
|
finally
|
|
AEditor := NIL;
|
|
end;
|
|
end;
|
|
|
|
procedure TProveedoresController.VerTodos(AContactos: IBizContacto);
|
|
var
|
|
AEditor : IEditorProveedores;
|
|
begin
|
|
CreateEditor('EditorProveedores', IEditorProveedores, AEditor);
|
|
with AEditor do
|
|
begin
|
|
Contactos := AContactos;
|
|
Controller := Self;
|
|
ShowEmbedded;
|
|
end;
|
|
end;
|
|
|
|
end.
|