182 lines
5.2 KiB
ObjectPascal
182 lines
5.2 KiB
ObjectPascal
unit uEditorContacto;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, uEditorDBItem, ToolWin, ComCtrls, JvExControls, JvComponent,
|
||
uViewContacto, uBizContactos, JvNavigationPane, ActnList,
|
||
uEditorBase, StdActns, TB2Dock, TB2Toolbar, TBX, ImgList, PngImageList,
|
||
TB2Item, uEditorItem, DB, uDADataTable, uEditorDBBase, JvFormAutoSize,
|
||
uDAScriptingProvider, uDACDSDataTable, StdCtrls, pngimage, ExtCtrls,
|
||
TBXDkPanels, JvButton, AppEvnts, uCustomView, uViewBase,
|
||
JvAppStorage, JvAppRegistryStorage, JvFormPlacement, JvComponentBase,
|
||
|
||
uIEditorContacto, uContactosController, TBXStatusBars, JvExComCtrls,
|
||
JvStatusBar, uViewContactoDatosBancarios, dxLayoutLookAndFeels, JvLabel,
|
||
uDAInterfaces;
|
||
|
||
type
|
||
TfEditorContacto = class(TfEditorDBItem, IEditorContacto)
|
||
pagDatosBancarios: TTabSheet;
|
||
frViewClienteDatosBancarios: TfrViewClienteDatosBancarios;
|
||
dxLayoutLookAndFeel: TdxLayoutLookAndFeelList;
|
||
dxLayoutOfficeLookAndFeel: TdxLayoutOfficeLookAndFeel;
|
||
procedure FormShow(Sender: TObject);
|
||
procedure dsDataTableDataChange(Sender: TObject; Field: TField);
|
||
protected
|
||
FController : IContactosController;
|
||
FContacto: IBizContacto;
|
||
FViewContacto : IViewContacto;
|
||
function GetContacto: IBizContacto; virtual;
|
||
procedure SetContacto(const Value: IBizContacto); virtual;
|
||
|
||
function GetViewContacto: IViewContacto;
|
||
procedure SetViewContacto(const Value: IViewContacto);
|
||
procedure GuardarInterno; override;
|
||
procedure EliminarInterno; override;
|
||
property ViewContacto: IViewContacto read GetViewContacto write
|
||
SetViewContacto;
|
||
function GetController : IContactosController; virtual;
|
||
procedure SetController (const Value : IContactosController); virtual;
|
||
public
|
||
procedure PonerTitulos(const ATitulo: string = ''); override;
|
||
constructor Create(AOwner: TComponent); override;
|
||
property Controller : IContactosController read GetController
|
||
write SetController;
|
||
property Contacto: IBizContacto read GetContacto write SetContacto;
|
||
destructor Destroy; override;
|
||
end;
|
||
|
||
implementation
|
||
|
||
{$R *.dfm}
|
||
|
||
uses
|
||
uCustomEditor, uDataModuleContactos, uDataModuleBase, uDataModuleUsuarios;
|
||
|
||
{
|
||
******************************* TfEditorContacto *******************************
|
||
}
|
||
function TfEditorContacto.GetContacto: IBizContacto;
|
||
begin
|
||
Result := FContacto;
|
||
end;
|
||
|
||
function TfEditorContacto.GetController: IContactosController;
|
||
begin
|
||
Result := FController;
|
||
end;
|
||
|
||
function TfEditorContacto.GetViewContacto: IViewContacto;
|
||
begin
|
||
Result := FViewContacto;
|
||
end;
|
||
|
||
procedure TfEditorContacto.GuardarInterno;
|
||
begin
|
||
inherited;
|
||
FController.Guardar(FContacto);
|
||
Modified := False;
|
||
end;
|
||
|
||
procedure TfEditorContacto.PonerTitulos(const ATitulo: string);
|
||
var
|
||
FTitulo : String;
|
||
begin
|
||
FTitulo := ATitulo;
|
||
|
||
if Assigned(Contacto) then
|
||
begin
|
||
if (FTitulo = '') then
|
||
begin
|
||
if Contacto.EsNuevo then
|
||
FTitulo := 'Nuevo contacto'
|
||
else
|
||
FTitulo := 'Contacto';
|
||
end;
|
||
|
||
if Length(Contacto.NOMBRE) > 0 then
|
||
FTitulo := FTitulo + ' - ' + Contacto.NOMBRE;
|
||
end;
|
||
|
||
inherited PonerTitulos(FTitulo);
|
||
|
||
// OJOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
|
||
// Self.Caption := FTitulo + ' (' + dmUsuarios.EmpresaActual.NOMBRE + ')';
|
||
end;
|
||
|
||
procedure TfEditorContacto.SetContacto(const Value: IBizContacto);
|
||
begin
|
||
FContacto := Value;
|
||
dsDataTable.DataTable := FContacto.DataTable;
|
||
|
||
if Assigned(FViewContacto) and Assigned(Contacto) then
|
||
begin
|
||
FViewContacto.Contacto := Contacto;
|
||
frViewClienteDatosBancarios.dsDatosBancarios.DataTable := FContacto.DatosBancarios.DataTable;
|
||
end
|
||
else
|
||
frViewClienteDatosBancarios.dsDatosBancarios.DataTable := NIL;
|
||
end;
|
||
|
||
procedure TfEditorContacto.SetController(const Value: IContactosController);
|
||
begin
|
||
FController := Value;
|
||
end;
|
||
|
||
procedure TfEditorContacto.SetViewContacto(const Value: IViewContacto);
|
||
begin
|
||
FViewContacto := Value;
|
||
|
||
if Assigned(FViewContacto) and Assigned(Contacto) then
|
||
FViewContacto.Contacto := Contacto;
|
||
end;
|
||
|
||
procedure TfEditorContacto.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
if not Assigned(FViewContacto) then
|
||
raise Exception.Create('No hay ninguna vista asignada');
|
||
|
||
if not Assigned(Contacto) then
|
||
raise Exception.Create('No hay ning<6E>n contacto asignado');
|
||
|
||
Contacto.DataTable.Active := True;
|
||
// FViewContacto.ShowEmbedded(pagGeneral);
|
||
// FViewContacto.SetFocus;
|
||
end;
|
||
|
||
constructor TfEditorContacto.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
pgPaginas.ActivePageIndex := 0;
|
||
end;
|
||
|
||
destructor TfEditorContacto.Destroy;
|
||
begin
|
||
FViewContacto := NIL;
|
||
FContacto := NIL;
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfEditorContacto.dsDataTableDataChange(Sender: TObject;
|
||
Field: TField);
|
||
begin
|
||
inherited;
|
||
if Assigned(Contacto) and (not (Contacto.DataTable.Fetching) or
|
||
not (Contacto.DataTable.Opening) or not (Contacto.DataTable.Closing)) then
|
||
PonerTitulos;
|
||
end;
|
||
|
||
procedure TfEditorContacto.EliminarInterno;
|
||
begin
|
||
inherited;
|
||
if not FController.Eliminar(FContacto) then
|
||
actRefrescar.Execute;
|
||
end;
|
||
|
||
end.
|
||
|