git-svn-id: https://192.168.0.254/svn/Proyectos.AlonsoYSal_FactuGES2/trunk@6 40301925-124e-1c4e-b97d-170ad7a8785b
178 lines
5.2 KiB
ObjectPascal
178 lines
5.2 KiB
ObjectPascal
unit uEditorSubCuentas;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, uEditorBase, ToolWin, ComCtrls, JvExControls, JvComponent,
|
|
JvNavigationPane, uViewSubCuentas, uBizSubCuentas, ActnList, DBActns, uViewGrid,
|
|
Menus, uDataModuleBase, ImgList, PngImageList, TB2Dock, TB2Toolbar, TBX,
|
|
TB2Item, StdActns, TB2ExtItems, TBXExtItems, TB2MRU, DB, uDADataTable,
|
|
JvFormAutoSize, uDAScriptingProvider, uDACDSDataTable, JvAppStorage,
|
|
JvAppRegistryStorage, JvFormPlacement, ExtCtrls, uCustomView, uViewBase,
|
|
uViewBarraSeleccion, pngimage, uIEditorSubCuentas, uEditorGridBase,
|
|
JvComponentBase, uViewGridBase, uSubCuentasController, JvExComCtrls,
|
|
JvStatusBar, uDAInterfaces, uViewEpigrafes, dxGDIPlusClasses;
|
|
|
|
type
|
|
TfEditorSubCuentas = class(TfEditorGridBase, IEditorSubCuentas)
|
|
frViewSubCuentas1: TfrViewSubCuentas;
|
|
procedure FormShow(Sender: TObject);
|
|
procedure actEliminarUpdate(Sender: TObject);
|
|
procedure actNuevoUpdate(Sender: TObject);
|
|
procedure actModificarUpdate(Sender: TObject);
|
|
private
|
|
FSubCuentas: IBizSubCuenta;
|
|
FController : ISubCuentasController;
|
|
protected
|
|
function GetSubCuentas: IBizSubCuenta;
|
|
procedure SetSubCuentas(const Value: IBizSubCuenta);
|
|
function GetController : ISubCuentasController; virtual;
|
|
procedure SetController (const Value : ISubCuentasController); virtual;
|
|
|
|
procedure NuevoInterno; override;
|
|
procedure EliminarInterno; override;
|
|
procedure ModificarInterno; override;
|
|
procedure DuplicarInterno; override;
|
|
|
|
public
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|
property SubCuentas: IBizSubCuenta read GetSubCuentas write SetSubCuentas;
|
|
property Controller : ISubCuentasController read GetController write SetController;
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
uCustomEditor, uDataModuleUsuarios, uBizEjercicios,
|
|
// uEditorEpigrafe,
|
|
uEditorDBBase, uFactuGES_App,
|
|
cxGrid, cxGridCustomTableView; //, uListaSubCuentas;
|
|
|
|
{$R *.dfm}
|
|
|
|
{
|
|
****************************** TfEditorSubCuentas *******************************
|
|
}
|
|
procedure TfEditorSubCuentas.FormShow(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
|
|
if not Assigned(ViewGrid) then
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|
|
|
if not Assigned(SubCuentas) then
|
|
raise Exception.Create('No hay ningún Epigrafe asignado');
|
|
|
|
SubCuentas.DataTable.Active := True;
|
|
ViewGrid.GotoFirst;
|
|
end;
|
|
|
|
function TfEditorSubCuentas.GetSubCuentas: IBizSubCuenta;
|
|
begin
|
|
Result := FSubCuentas;
|
|
end;
|
|
|
|
function TfEditorSubCuentas.GetController: ISubCuentasController;
|
|
begin
|
|
Result := FController;
|
|
end;
|
|
|
|
procedure TfEditorSubCuentas.ModificarInterno;
|
|
begin
|
|
inherited;
|
|
FController.Ver(SubCuentas);
|
|
end;
|
|
|
|
procedure TfEditorSubCuentas.NuevoInterno;
|
|
begin
|
|
inherited;
|
|
FController.Anadir(SubCuentas);
|
|
FController.Ver(SubCuentas);
|
|
end;
|
|
|
|
procedure TfEditorSubCuentas.PonerTitulos(const ATitulo: string);
|
|
var
|
|
FTitulo : String;
|
|
begin
|
|
FTitulo := 'Lista de SubCuentas - ' + AppFactuGES.EmpresaActiva.NOMBRE + ' - ' + AppFactuGES.EjercicioActivo.NOMBRE + ' (' + AppFactuGES.EjercicioActivo.ESTADO + ')';
|
|
inherited PonerTitulos(FTitulo);
|
|
end;
|
|
|
|
procedure TfEditorSubCuentas.SetSubCuentas(const Value: IBizSubCuenta);
|
|
begin
|
|
FSubCuentas := Value;
|
|
dsDataTable.DataTable := FSubCuentas.DataTable;
|
|
if Assigned(ViewGrid) then
|
|
(ViewGrid as IViewSubCuentas).SubCuentas := SubCuentas;
|
|
end;
|
|
|
|
procedure TfEditorSubCuentas.SetController(const Value: ISubCuentasController);
|
|
begin
|
|
FController := Value;
|
|
end;
|
|
|
|
destructor TfEditorSubCuentas.Destroy;
|
|
begin
|
|
FSubCuentas := NIL;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfEditorSubCuentas.DuplicarInterno;
|
|
var
|
|
ASubcuenta : IBizSubCuenta;
|
|
begin
|
|
inherited;
|
|
ASubcuenta := FController.Duplicar(SubCuentas);
|
|
try
|
|
FController.Ver(ASubcuenta);
|
|
finally
|
|
actRefrescar.Execute;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorSubCuentas.EliminarInterno;
|
|
begin
|
|
|
|
if (Application.MessageBox('¿Desea borrar esta subcuenta?', 'Atención', MB_YESNO) = IDYES) then
|
|
begin
|
|
inherited;
|
|
//Para que en el caso de no poderse realizar la operación se refresquen
|
|
//los datos y no nos permita eliminar un registro a la segunda
|
|
if not FController.Eliminar(SubCuentas) then
|
|
actRefrescar.Execute;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorSubCuentas.actEliminarUpdate(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
if (Sender as TAction).Enabled then
|
|
(Sender as TAction).Enabled := (SubCuentas.ESTADO = CTE_ABIERTO);
|
|
end;
|
|
|
|
procedure TfEditorSubCuentas.actModificarUpdate(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
if (Sender as TAction).Enabled then
|
|
(Sender as TAction).Enabled := (SubCuentas.ESTADO = CTE_ABIERTO);
|
|
end;
|
|
|
|
procedure TfEditorSubCuentas.actNuevoUpdate(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
if (Sender as TAction).Enabled then
|
|
(Sender as TAction).Enabled := (AppFactuGES.EjercicioActivo.ESTADO = CTE_ABIERTO);
|
|
end;
|
|
|
|
constructor TfEditorSubCuentas.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
ViewGrid := frViewSubCuentas1; //CreateView(TfrViewSubCuentas) as IViewSubCuentas;
|
|
end;
|
|
|
|
end.
|
|
|
|
|