AbetoDesign_FactuGES2/Source/Modulos/Remesas de cliente/Controller/uRemesasClienteReportController.pas

114 lines
2.8 KiB
ObjectPascal
Raw Permalink Normal View History

unit uRemesasClienteReportController;
interface
uses
Classes, SysUtils, uDADataTable, uControllerBase, uIDataModuleRemesasClienteReport,
uBizRemesasCliente, uIntegerListUtils;
type
IRemesasClienteReportController = interface
['{EA6EAD10-E07B-45A9-9B5E-0D560E2B92DF}']
procedure Preview(const ListaID : TIntegerList);
function Print(const ListaID : TIntegerList): Boolean;
end;
TRemesasClienteReportController = class(TInterfacedObject, IRemesasClienteReportController)
private
FDataModule : IDataModuleRemesasClienteReport;
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
public
constructor Create;
destructor Destroy; override;
procedure Preview(const ListaID : TIntegerList);
function Print(const ListaID : TIntegerList): Boolean;
end;
implementation
uses
uROTypes, uEditorRegistryUtils, uIEditorRemesasClientePreview,
uEditorPreview, uDataModuleRemesasCliente, uEditorBase, cxControls, schRemesasClienteClient_Intf;
{ TRemesasClienteReportController }
constructor TRemesasClienteReportController.Create;
begin
FDataModule := TDataModuleRemesasCliente.Create(Nil);
end;
function TRemesasClienteReportController.CreateEditor(const AName: String;
const IID: TGUID; out Intf): Boolean;
begin
Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf);
end;
destructor TRemesasClienteReportController.Destroy;
begin
FDataModule := NIL;
inherited;
end;
procedure TRemesasClienteReportController.Preview(const ListaID : TIntegerList);
var
AStream: Binary;
AEditor : IEditorRemesasClientePreview;
begin
AEditor := NIL;
ShowHourglassCursor;
try
AStream := FDataModule.GetReport(ListaID);
try
CreateEditor('EditorRemesasClientePreview', IEditorRemesasClientePreview, AEditor);
if Assigned(AEditor) then
try
AEditor.LoadFromStream(AStream);
AEditor.Preview;
finally
AEditor.Release;
end;
finally
FreeAndNil(AStream);
AEditor := Nil;
end;
finally
HideHourglassCursor;
end;
end;
function TRemesasClienteReportController.Print(const ListaID : TIntegerList): Boolean;
var
AStream: Binary;
AEditor : IEditorRemesasClientePreview;
begin
Result := False;
AEditor := NIL;
ShowHourglassCursor;
try
AStream := FDataModule.GetReport(ListaID);
try
CreateEditor('EditorRemesasClientePreview', IEditorRemesasClientePreview, AEditor);
if Assigned(AEditor) then
try
AEditor.LoadFromStream(AStream);
AEditor.Print;
Result := True;
finally
AEditor.Release;
end;
finally
FreeAndNil(AStream);
AEditor := Nil;
end;
finally
HideHourglassCursor;
end;
end;
end.