Tecsitel_FactuGES2/Source/Modulos/Facturas de proveedor/Controller/uFacturasProveedorReportController.pas

112 lines
2.8 KiB
ObjectPascal

unit uFacturasProveedorReportController;
interface
uses
Classes, SysUtils, uDADataTable, uControllerBase, uIDataModuleFacturasProveedorReport,
uClientesController, uDetallesFacturaProveedorController, uBizFacturasProveedor;
type
IFacturasProveedorReportController = interface(IControllerBase)
['{551F82DC-B8DC-482E-A20D-15003E845078}']
procedure Preview(const AFacturaID : String);
procedure Print(const AFacturaID : String);
end;
TFacturasProveedorReportController = class(TControllerBase, IFacturasProveedorReportController)
private
FDataModule : IDataModuleFacturasProveedorReport;
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
public
constructor Create; override;
destructor Destroy; override;
procedure Preview(const AFacturaID : String);
procedure Print(const AFacturaID : String);
end;
implementation
uses
uROTypes, uEditorRegistryUtils, uIEditorFacturasProveedorPreview,
uEditorPreview, uDataModuleFacturasProveedor, uEditorBase, cxControls;
{ TFacturasProveedorReportController }
constructor TFacturasProveedorReportController.Create;
begin
inherited;
FDataModule := TDataModuleFacturasProveedor.Create(Nil);
end;
function TFacturasProveedorReportController.CreateEditor(const AName: String;
const IID: TGUID; out Intf): Boolean;
begin
Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf);
end;
destructor TFacturasProveedorReportController.Destroy;
begin
FDataModule := NIL;
inherited;
end;
procedure TFacturasProveedorReportController.Preview(const AFacturaID : String);
var
AStream: Binary;
AEditor : IEditorFacturasProveedorPreview;
begin
AEditor := NIL;
ShowHourglassCursor;
try
AStream := FDataModule.GetReport(AFacturaID);
try
CreateEditor('EditorFacturasProveedorPreview', IEditorFacturasProveedorPreview, AEditor);
if Assigned(AEditor) then
with AEditor do
begin
LoadFromStream(AStream);
Preview;
Release;
end;
finally
FreeAndNil(AStream);
AEditor := Nil;
end;
finally
HideHourglassCursor;
end;
end;
procedure TFacturasProveedorReportController.Print(const AFacturaID : String);
var
AStream: Binary;
AEditor : IEditorFacturasProveedorPreview;
begin
AEditor := NIL;
ShowHourglassCursor;
try
AStream := FDataModule.GetReport(AFacturaID);
try
CreateEditor('EditorFacturasProveedorPreview', IEditorFacturasProveedorPreview, AEditor);
if Assigned(AEditor) then
with AEditor do
begin
LoadFromStream(AStream);
Print;
Release;
end;
finally
FreeAndNil(AStream);
AEditor := Nil;
end;
finally
HideHourglassCursor;
end;
end;
end.