AbetoDesign_FactuGES2/Source/Modulos/Contabilidad/Views/uEditorCuentas.pas

182 lines
5.1 KiB
ObjectPascal

unit uEditorCuentas;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uEditorBase, ToolWin, ComCtrls, JvExControls, JvComponent,
JvNavigationPane, uViewCuentas, uBizCuentas, 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, uIEditorCuentas, uEditorGridBase,
JvComponentBase, uViewGridBase, uCuentasController, JvExComCtrls,
JvStatusBar, uDAInterfaces, dxGDIPlusClasses;
type
TfEditorCuentas = class(TfEditorGridBase, IEditorCuentas)
frViewCuentas1: TfrViewCuentas;
procedure FormShow(Sender: TObject);
procedure actEliminarUpdate(Sender: TObject);
procedure actNuevoUpdate(Sender: TObject);
procedure actModificarUpdate(Sender: TObject);
private
FCuentas: IBizCuenta;
FController : ICuentasController;
protected
function GetCuentas: IBizCuenta;
procedure SetCuentas(const Value: IBizCuenta);
function GetController : ICuentasController; virtual;
procedure SetController (const Value : ICuentasController); virtual;
procedure NuevoInterno; override;
procedure EliminarInterno; override;
procedure ModificarInterno; override;
procedure DuplicarInterno; override;
public
procedure PonerTitulos(const ATitulo: string = ''); override;
property Cuentas: IBizCuenta read GetCuentas write SetCuentas;
property Controller : ICuentasController read GetController write SetController;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
implementation
uses
uCustomEditor, uDataModuleUsuarios, uBizEjercicios,
// uEditorCuenta,
uEditorDBBase, uFactuGES_App,
cxGrid, cxGridCustomTableView; //, uListaCuentas;
{$R *.dfm}
{
****************************** TfEditorCuentas *******************************
}
procedure TfEditorCuentas.FormShow(Sender: TObject);
begin
inherited;
if not Assigned(ViewGrid) then
raise Exception.Create('No hay ninguna vista asignada');
if not Assigned(Cuentas) then
raise Exception.Create('No hay ningún Cuenta asignado');
Cuentas.DataTable.Active := True;
ViewGrid.GotoFirst;
//Para que coja el ancho automático
actAnchoAuto.Execute;
end;
function TfEditorCuentas.GetCuentas: IBizCuenta;
begin
Result := FCuentas;
end;
function TfEditorCuentas.GetController: ICuentasController;
begin
Result := FController;
end;
procedure TfEditorCuentas.ModificarInterno;
begin
inherited;
FController.Ver(Cuentas);
end;
procedure TfEditorCuentas.NuevoInterno;
begin
inherited;
FController.Anadir(Cuentas);
FController.Ver(Cuentas);
end;
procedure TfEditorCuentas.PonerTitulos(const ATitulo: string);
var
FTitulo : String;
begin
FTitulo := 'Lista de Cuentas - ' + AppFactuGES.EmpresaActiva.NOMBRE + ' - ' + AppFactuGES.EjercicioActivo.NOMBRE + ' (' + AppFactuGES.EjercicioActivo.ESTADO + ')';
inherited PonerTitulos(FTitulo);
end;
procedure TfEditorCuentas.SetCuentas(const Value: IBizCuenta);
begin
FCuentas := Value;
dsDataTable.DataTable := FCuentas.DataTable;
if Assigned(ViewGrid) then
(ViewGrid as IViewCuentas).Cuentas := Cuentas;
end;
procedure TfEditorCuentas.SetController(const Value: ICuentasController);
begin
FController := Value;
end;
destructor TfEditorCuentas.Destroy;
begin
FCuentas := NIL;
inherited;
end;
procedure TfEditorCuentas.DuplicarInterno;
{var
ACuenta : IBizCuenta;}
begin
{
inherited;
ACuenta := FController.Duplicar(Cuentas);
try
FController.Ver(ACuenta);
finally
actRefrescar.Execute;
end;
}
end;
procedure TfEditorCuentas.EliminarInterno;
begin
if (Application.MessageBox('¿Desea borrar esta cuenta?', '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(Cuentas) then
actRefrescar.Execute;
end;
end;
procedure TfEditorCuentas.actEliminarUpdate(Sender: TObject);
begin
inherited;
if (Sender as TAction).Enabled then
(Sender as TAction).Enabled := (Cuentas.ESTADO = CTE_ABIERTO);
end;
procedure TfEditorCuentas.actModificarUpdate(Sender: TObject);
begin
inherited;
if (Sender as TAction).Enabled then
(Sender as TAction).Enabled := (Cuentas.ESTADO = CTE_ABIERTO);
end;
procedure TfEditorCuentas.actNuevoUpdate(Sender: TObject);
begin
inherited;
if (Sender as TAction).Enabled then
(Sender as TAction).Enabled := (AppFactuGES.EjercicioActivo.ESTADO = CTE_ABIERTO);
end;
constructor TfEditorCuentas.Create(AOwner: TComponent);
begin
inherited;
ViewGrid := frViewCuentas1; //CreateView(TfrViewCuentas) as IViewCuentas;
end;
end.