FactuGES2/Source/Modulos/Contabilidad/Views/uEditorAsientos.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 uEditorAsientos;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uEditorBase, ToolWin, ComCtrls, JvExControls, JvComponent,
JvNavigationPane, uViewAsientos, uBizAsientos, 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, uIEditorAsientos, uEditorGridBase,
JvComponentBase, uViewGridBase, uAsientosController, JvExComCtrls,
JvStatusBar, uDAInterfaces, uViewEpigrafes;
type
TfEditorAsientos = class(TfEditorGridBase, IEditorAsientos)
frViewAsientos1: TfrViewAsientos;
procedure FormShow(Sender: TObject);
private
FAsientos: IBizAsiento;
FController : IAsientosController;
protected
function GetAsientos: IBizAsiento;
procedure SetAsientos(const Value: IBizAsiento);
function GetController : IAsientosController; virtual;
procedure SetController (const Value : IAsientosController); virtual;
procedure NuevoInterno; override;
procedure EliminarInterno; override;
procedure ModificarInterno; override;
procedure DuplicarInterno; override;
public
procedure PonerTitulos(const ATitulo: string = ''); override;
property Asientos: IBizAsiento read GetAsientos write SetAsientos;
property Controller : IAsientosController read GetController write SetController;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
implementation
uses
uCustomEditor, uDataModuleUsuarios,
// uEditorEpigrafe,
uEditorDBBase, uFactuGES_App,
cxGrid, cxGridCustomTableView; //, uListaAsientos;
{$R *.dfm}
{
****************************** TfEditorAsientos *******************************
}
procedure TfEditorAsientos.FormShow(Sender: TObject);
begin
inherited;
if not Assigned(ViewGrid) then
raise Exception.Create('No hay ninguna vista asignada');
if not Assigned(Asientos) then
raise Exception.Create('No hay ningún Epigrafe asignado');
Asientos.DataTable.Active := True;
ViewGrid.GotoFirst;
end;
function TfEditorAsientos.GetAsientos: IBizAsiento;
begin
Result := FAsientos;
end;
function TfEditorAsientos.GetController: IAsientosController;
begin
Result := FController;
end;
procedure TfEditorAsientos.ModificarInterno;
begin
inherited;
FController.Ver(Asientos);
end;
procedure TfEditorAsientos.NuevoInterno;
begin
inherited;
FController.Anadir(Asientos);
FController.Ver(Asientos);
end;
procedure TfEditorAsientos.PonerTitulos(const ATitulo: string);
var
FTitulo : String;
begin
FTitulo := 'Lista de Asientos - ' + AppFactuGES.EmpresaActiva.NOMBRE;
inherited PonerTitulos(FTitulo);
end;
procedure TfEditorAsientos.SetAsientos(const Value: IBizAsiento);
begin
FAsientos := Value;
dsDataTable.DataTable := FAsientos.DataTable;
if Assigned(ViewGrid) then
(ViewGrid as IViewAsientos).Asientos := Asientos;
end;
procedure TfEditorAsientos.SetController(const Value: IAsientosController);
begin
FController := Value;
end;
destructor TfEditorAsientos.Destroy;
begin
FAsientos := NIL;
inherited;
end;
procedure TfEditorAsientos.DuplicarInterno;
var
AEpigrafe : IBizAsiento;
begin
AppFactuGES.ShowCapado;
{
inherited;
AEpigrafe := FController.Duplicar(Asientos);
try
FController.Ver(AEpigrafe);
finally
actRefrescar.Execute;
end;
}
end;
procedure TfEditorAsientos.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(Asientos) then
actRefrescar.Execute;
end;
end;
constructor TfEditorAsientos.Create(AOwner: TComponent);
begin
inherited;
ViewGrid := frViewAsientos1; //CreateView(TfrViewAsientos) as IViewAsientos;
end;
end.