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

157 lines
4.2 KiB
ObjectPascal
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
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 este almacén?', '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.