157 lines
4.2 KiB
ObjectPascal
157 lines
4.2 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);
|
||
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,
|
||
// 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;
|
||
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;
|
||
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
|
||
AppFactuGES.ShowCapado;
|
||
{
|
||
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;
|
||
|
||
constructor TfEditorCuentas.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
ViewGrid := frViewCuentas1; //CreateView(TfrViewCuentas) as IViewCuentas;
|
||
end;
|
||
|
||
end.
|
||
|
||
|