185 lines
5.2 KiB
ObjectPascal
185 lines
5.2 KiB
ObjectPascal
unit uEditorEmpresa;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, uEditorDBItem, ToolWin, ComCtrls, JvExControls, JvComponent,
|
||
uBizEmpresas, 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,
|
||
uViewEmpresa, uIEditorEmpresa, uEmpresasController, dxLayoutLookAndFeels,
|
||
JvExComCtrls, JvStatusBar, uViewDetallesGenerico, uViewDatosBancarios,
|
||
uDAInterfaces;
|
||
|
||
type
|
||
TfEditorEmpresa = class(TfEditorDBItem, IEditorEmpresa)
|
||
frViewEmpresa1: TfrViewEmpresa;
|
||
dxLayoutLookAndFeelList1: TdxLayoutLookAndFeelList;
|
||
dxLayoutOfficeLookAndFeel1: TdxLayoutOfficeLookAndFeel;
|
||
TabSheet1: TTabSheet;
|
||
frViewDatosBancarios1: TfrViewDatosBancarios;
|
||
procedure FormShow(Sender: TObject);
|
||
procedure actRefrescarUpdate(Sender: TObject);
|
||
procedure dsDataTableDataChange(Sender: TObject; Field: TField);
|
||
private
|
||
FController : IEmpresasController;
|
||
FEmpresa: IBizEmpresa;
|
||
FViewEmpresa : IViewEmpresa;
|
||
protected
|
||
function GetEmpresa: IBizEmpresa; virtual;
|
||
procedure SetEmpresa(const Value: IBizEmpresa); virtual;
|
||
|
||
function GetViewEmpresa: IViewEmpresa;
|
||
procedure SetViewEmpresa(const Value: IViewEmpresa);
|
||
procedure GuardarInterno; override;
|
||
procedure EliminarInterno; override;
|
||
property ViewEmpresa: IViewEmpresa read GetViewEmpresa write
|
||
SetViewEmpresa;
|
||
function GetController : IEmpresasController; virtual;
|
||
procedure SetController (const Value : IEmpresasController); virtual;
|
||
|
||
public
|
||
constructor Create(AOwner: TComponent); override;
|
||
procedure PonerTitulos(const ATitulo: string = ''); override;
|
||
property Controller : IEmpresasController read GetController
|
||
write SetController;
|
||
property Empresa: IBizEmpresa read GetEmpresa write SetEmpresa;
|
||
destructor Destroy; override;
|
||
end;
|
||
|
||
implementation
|
||
|
||
{$R *.dfm}
|
||
|
||
uses
|
||
uCustomEditor, uDataModuleEmpresas, uDataModuleBase;
|
||
|
||
{
|
||
******************************* TfEditorEmpresa *******************************
|
||
}
|
||
function TfEditorEmpresa.GetEmpresa: IBizEmpresa;
|
||
begin
|
||
Result := FEmpresa;
|
||
end;
|
||
|
||
function TfEditorEmpresa.GetController: IEmpresasController;
|
||
begin
|
||
Result := FController;
|
||
end;
|
||
|
||
function TfEditorEmpresa.GetViewEmpresa: IViewEmpresa;
|
||
begin
|
||
Result := FViewEmpresa;
|
||
end;
|
||
|
||
procedure TfEditorEmpresa.GuardarInterno;
|
||
begin
|
||
inherited;
|
||
FController.Guardar(FEmpresa);
|
||
Modified := False;
|
||
end;
|
||
|
||
procedure TfEditorEmpresa.PonerTitulos(const ATitulo: string);
|
||
var
|
||
FTitulo : String;
|
||
begin
|
||
if (ATitulo = '') and Assigned(FEmpresa) then
|
||
begin
|
||
if Length(FEmpresa.Nombre) = 0 then
|
||
FTitulo := 'Nueva empresa'
|
||
else
|
||
FTitulo := 'Empresa' + ' - ' + FEmpresa.Nombre
|
||
end;
|
||
|
||
inherited PonerTitulos(FTitulo);
|
||
end;
|
||
|
||
procedure TfEditorEmpresa.SetEmpresa(const Value: IBizEmpresa);
|
||
begin
|
||
FEmpresa := Value;
|
||
dsDataTable.DataTable := FEmpresa.DataTable;
|
||
|
||
if Assigned(FViewEmpresa) and Assigned(Empresa) then
|
||
begin
|
||
FViewEmpresa.Empresa := FEmpresa;
|
||
frViewDatosBancarios1.dsDetalles.DataTable := FEmpresa.DatosBancarios.DataTable
|
||
end
|
||
else begin
|
||
FViewEmpresa.Empresa := NIL;
|
||
frViewDatosBancarios1.dsDetalles.DataTable := NIL;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorEmpresa.SetController(const Value: IEmpresasController);
|
||
begin
|
||
FController := Value;
|
||
end;
|
||
|
||
procedure TfEditorEmpresa.SetViewEmpresa(const Value: IViewEmpresa);
|
||
begin
|
||
FViewEmpresa := Value;
|
||
|
||
if Assigned(FViewEmpresa) and Assigned(Empresa) then
|
||
FViewEmpresa.Empresa := Empresa;
|
||
end;
|
||
|
||
procedure TfEditorEmpresa.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
if not Assigned(FViewEmpresa) then
|
||
raise Exception.Create('No hay ninguna vista asignada');
|
||
|
||
if not Assigned(Empresa) then
|
||
raise Exception.Create('No hay ning<6E>n Empresa asignado');
|
||
|
||
Empresa.DataTable.Active := True;
|
||
// FViewEmpresa.ShowEmbedded(pagGeneral);
|
||
FViewEmpresa.SetFocus;
|
||
end;
|
||
|
||
procedure TfEditorEmpresa.actRefrescarUpdate(Sender: TObject);
|
||
begin
|
||
if Assigned(dsDataTable.DataTable) then
|
||
(Sender as TAction).Enabled := (not dsDataTable.DataTable.Fetching) or
|
||
(not dsDataTable.DataTable.Opening) or
|
||
(not dsDataTable.DataTable.Closing) or
|
||
(not FEmpresa.EsNuevo)
|
||
else
|
||
(Sender as TAction).Enabled := False;
|
||
end;
|
||
|
||
constructor TfEditorEmpresa.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
FViewEmpresa := frViewEmpresa1;
|
||
end;
|
||
|
||
destructor TfEditorEmpresa.Destroy;
|
||
begin
|
||
FViewEmpresa := NIL;
|
||
FEmpresa := NIL;
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfEditorEmpresa.dsDataTableDataChange(Sender: TObject; Field: TField);
|
||
begin
|
||
inherited;
|
||
if Assigned(FEmpresa) and (not (FEmpresa.DataTable.Fetching) or
|
||
not (FEmpresa.DataTable.Opening) or not (FEmpresa.DataTable.Closing)) then
|
||
PonerTitulos;
|
||
end;
|
||
|
||
procedure TfEditorEmpresa.EliminarInterno;
|
||
begin
|
||
inherited;
|
||
FController.Eliminar(FEmpresa);
|
||
end;
|
||
|
||
end.
|
||
|