unit uPresupuestosClienteReportController; interface uses Classes, SysUtils, uDADataTable, uControllerBase, uIDataModulePresupuestosClienteReport, uClientesController, uPresupuestosClienteController, uDetallesPresupuestoClienteController, uBizPresupuestosCliente; type IPresupuestosClienteReportController = interface ['{D0686358-251C-43C4-9927-6112F2F4D3B8}'] procedure Preview(const AID : String); procedure Print(const AID : String); end; TPresupuestosClienteReportController = class(TInterfacedObject, IPresupuestosClienteReportController) private FDataModule : IDataModulePresupuestosClienteReport; function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean; public constructor Create; destructor Destroy; override; procedure Preview(const AID : String); procedure Print(const AID : String); end; implementation uses uROTypes, uEditorRegistryUtils, uIEditorPresupuestosClientePreview, uEditorPreview, uDataModulePresupuestosCliente, uEditorBase, cxControls; { TPresupuestosClienteReportController } constructor TPresupuestosClienteReportController.Create; begin FDataModule := TDataModulePresupuestosCliente.Create(Nil); end; function TPresupuestosClienteReportController.CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean; begin Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf); end; destructor TPresupuestosClienteReportController.Destroy; begin FDataModule := NIL; inherited; end; procedure TPresupuestosClienteReportController.Preview(const AID : String); var AStream: Binary; AEditor : IEditorPresupuestosClientePreview; begin AEditor := NIL; ShowHourglassCursor; try AStream := FDataModule.GetReport(AID); try CreateEditor('EditorPresupuestosClientePreview', IEditorPresupuestosClientePreview, AEditor); if Assigned(AEditor) then with AEditor do begin AEditor.LoadFromStream(AStream); AEditor.Preview; AEditor.Release; end; finally FreeAndNil(AStream); AEditor := Nil; end; finally HideHourglassCursor; end; end; procedure TPresupuestosClienteReportController.Print(const AID : String); var AStream: Binary; AEditor : IEditorPresupuestosClientePreview; begin AEditor := NIL; ShowHourglassCursor; try AStream := FDataModule.GetReport(AID); try CreateEditor('EditorPresupuestosClientePreview', IEditorPresupuestosClientePreview, AEditor); if Assigned(AEditor) then with AEditor do begin AEditor.LoadFromStream(AStream); AEditor.Print; AEditor.Release; end; finally FreeAndNil(AStream); AEditor := Nil; end; finally HideHourglassCursor; end; if Assigned(AEditor) then end; end.