215 lines
5.9 KiB
ObjectPascal
215 lines
5.9 KiB
ObjectPascal
|
|
unit uEditorCuenta;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, uEditorDBItem, ToolWin, ComCtrls, JvExControls, JvComponent,
|
|||
|
|
uViewCuenta, uBizCuentas, 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,
|
|||
|
|
|
|||
|
|
uViewCuentas, uIEditorCuenta, uCuentasController, JvExComCtrls,
|
|||
|
|
JvStatusBar, dxLayoutLookAndFeels, uDAInterfaces, dxGDIPlusClasses;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfEditorCuenta = class(TfEditorDBItem, IEditorCuenta)
|
|||
|
|
dxLayoutLookAndFeelList1: TdxLayoutLookAndFeelList;
|
|||
|
|
dxLayoutOfficeLookAndFeel1: TdxLayoutOfficeLookAndFeel;
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure dsDataTableDataChange(Sender: TObject; Field: TField);
|
|||
|
|
procedure CustomEditorClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
procedure actEliminarUpdate(Sender: TObject);
|
|||
|
|
protected
|
|||
|
|
FController : ICuentasController;
|
|||
|
|
FCuenta: IBizCuenta;
|
|||
|
|
FViewCuenta : IViewCuenta;
|
|||
|
|
|
|||
|
|
function GetController : ICuentasController;
|
|||
|
|
procedure SetController (const Value : ICuentasController); virtual;
|
|||
|
|
function GetCuenta: IBizCuenta; virtual;
|
|||
|
|
procedure SetCuenta(const Value: IBizCuenta); virtual;
|
|||
|
|
function GetViewCuenta: IViewCuenta;
|
|||
|
|
procedure SetViewCuenta(const Value: IViewCuenta);
|
|||
|
|
property ViewCuenta: IViewCuenta read GetViewCuenta write SetViewCuenta;
|
|||
|
|
|
|||
|
|
procedure GuardarInterno; override;
|
|||
|
|
procedure EliminarInterno; override;
|
|||
|
|
|
|||
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|||
|
|
|
|||
|
|
//Si queremos crear otra vista para el editor heredado solo tendriamos que
|
|||
|
|
//sobreescribir este metodo
|
|||
|
|
procedure AsignarVista; virtual;
|
|||
|
|
|
|||
|
|
public
|
|||
|
|
property Cuenta: IBizCuenta read GetCuenta write SetCuenta;
|
|||
|
|
constructor Create(AOwner: TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uCustomEditor, uDataModuleBase, uFactuGES_App, uBizEjercicios;
|
|||
|
|
|
|||
|
|
function ShowEditorCuenta (ABizObject : TDADataTableRules): TModalResult;
|
|||
|
|
var
|
|||
|
|
AEditor: TfEditorCuenta;
|
|||
|
|
begin
|
|||
|
|
AEditor := TfEditorCuenta.Create(Application);
|
|||
|
|
try
|
|||
|
|
AEditor.Cuenta := (ABizObject as IBizCuenta);
|
|||
|
|
Result := AEditor.ShowModal;
|
|||
|
|
finally
|
|||
|
|
AEditor.Release;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
******************************* TfEditorCuenta *******************************
|
|||
|
|
}
|
|||
|
|
function TfEditorCuenta.GetCuenta: IBizCuenta;
|
|||
|
|
begin
|
|||
|
|
Result := FCuenta;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfEditorCuenta.GetController: ICuentasController;
|
|||
|
|
begin
|
|||
|
|
Result := FController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfEditorCuenta.GetViewCuenta: IViewCuenta;
|
|||
|
|
begin
|
|||
|
|
Result := FViewCuenta;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCuenta.GuardarInterno;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FController.Guardar(FCuenta);
|
|||
|
|
Modified := False;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCuenta.PonerTitulos(const ATitulo: string);
|
|||
|
|
var
|
|||
|
|
FTitulo : String;
|
|||
|
|
begin
|
|||
|
|
if Assigned(Cuenta) then
|
|||
|
|
begin
|
|||
|
|
if Cuenta.EsNuevo then
|
|||
|
|
FTitulo := 'Nueva cuenta - ' + AppFactuGES.EjercicioActivo.NOMBRE + ' (' + AppFactuGES.EjercicioActivo.ESTADO + ')'
|
|||
|
|
else
|
|||
|
|
FTitulo := 'Cuenta' + ' - ' + AppFactuGES.EjercicioActivo.NOMBRE + ' (' + AppFactuGES.EjercicioActivo.ESTADO + ')' + ' - ' + Cuenta.DESCRIPCION;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
inherited PonerTitulos(FTitulo);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCuenta.SetCuenta(const Value: IBizCuenta);
|
|||
|
|
begin
|
|||
|
|
FCuenta := Value;
|
|||
|
|
dsDataTable.DataTable := FCuenta.DataTable;
|
|||
|
|
|
|||
|
|
if Assigned(FViewCuenta) and Assigned(Cuenta) then
|
|||
|
|
FViewCuenta.Cuenta := Cuenta;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCuenta.SetController(const Value: ICuentasController);
|
|||
|
|
begin
|
|||
|
|
FController := Value;
|
|||
|
|
if Assigned(ViewCuenta) then
|
|||
|
|
ViewCuenta.Controller := FController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCuenta.SetViewCuenta(const Value: IViewCuenta);
|
|||
|
|
begin
|
|||
|
|
FViewCuenta := Value;
|
|||
|
|
|
|||
|
|
if Assigned(FViewCuenta) and Assigned(Cuenta) then
|
|||
|
|
FViewCuenta.Cuenta := Cuenta;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCuenta.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
if not Assigned(FViewCuenta) then
|
|||
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|||
|
|
|
|||
|
|
if not Assigned(Cuenta) then
|
|||
|
|
raise Exception.Create('No hay ning<6E>n almac<61>n asignado');
|
|||
|
|
|
|||
|
|
Cuenta.DataTable.Active := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfEditorCuenta.Destroy;
|
|||
|
|
begin
|
|||
|
|
// Utilizar mejor OnClose;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCuenta.actEliminarUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if (Sender as TAction).Enabled then
|
|||
|
|
(Sender as TAction).Enabled := (Cuenta.ESTADO = CTE_ABIERTO);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCuenta.AsignarVista;
|
|||
|
|
var
|
|||
|
|
AViewCuenta: TfrViewCuenta;
|
|||
|
|
begin
|
|||
|
|
AViewCuenta := TfrViewCuenta.create(Self);
|
|||
|
|
with AViewCuenta do
|
|||
|
|
begin
|
|||
|
|
Parent := pagGeneral;
|
|||
|
|
Align := alClient;
|
|||
|
|
// dxLayoutControlCuenta.LookAndFeel := dxLayoutOfficeLookAndFeel1;
|
|||
|
|
end;
|
|||
|
|
ViewCuenta := AViewCuenta;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
constructor TfEditorCuenta.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
pgPaginas.ActivePageIndex := 0;
|
|||
|
|
AsignarVista;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCuenta.CustomEditorClose(Sender: TObject;
|
|||
|
|
var Action: TCloseAction);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
dsDataTable.DataTable := NIL;
|
|||
|
|
FViewCuenta := NIL;
|
|||
|
|
FCuenta := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCuenta.dsDataTableDataChange(Sender: TObject;
|
|||
|
|
Field: TField);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if Assigned(FCuenta) and (not (FCuenta.DataTable.Fetching) or
|
|||
|
|
not (FCuenta.DataTable.Opening) or not (FCuenta.DataTable.Closing)) then
|
|||
|
|
PonerTitulos;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCuenta.EliminarInterno;
|
|||
|
|
begin
|
|||
|
|
if (Application.MessageBox('<27>Desea borrar esta Cuenta?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if not FController.Eliminar(FCuenta) then
|
|||
|
|
actRefrescar.Execute;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|
|||
|
|
|