unit uFichasEmpleadoReportController; interface uses Classes, SysUtils, uDADataTable, uControllerBase, uIDataModuleFichasEmpleadoReport, uEmpleadosController, uIntegerListUtils; type IFichasEmpleadoReportController = interface(IControllerBase) ['{8E43F55F-7D5A-4778-8523-7C105EAEB1AB}'] procedure Preview(const ListaID : TIntegerList); procedure Print(const ListaID : TIntegerList); end; TFichasEmpleadoReportController = class(TControllerBase, IFichasEmpleadoReportController) private FDataModule : IDataModuleFichasEmpleadoReport; function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean; public constructor Create; override; destructor Destroy; override; procedure Preview(const ListaID : TIntegerList); procedure Print(const ListaID : TIntegerList); end; implementation uses uROTypes, uEditorRegistryUtils, uIEditorFichasEmpleadoPreview, uEditorPreview, uDataModuleEmpleados, uEditorBase, cxControls; { TFichasEmpleadoReportController } constructor TFichasEmpleadoReportController.Create; begin inherited; FDataModule := TDataModuleEmpleados.Create(Nil); end; function TFichasEmpleadoReportController.CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean; begin Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf); end; destructor TFichasEmpleadoReportController.Destroy; begin FDataModule := NIL; inherited; end; procedure TFichasEmpleadoReportController.Preview(const ListaID : TIntegerList); var AStream: Binary; AEditor : IEditorFichasEmpleadoPreview; begin AEditor := NIL; ShowHourglassCursor; try AStream := FDataModule.GetReport(ListaID); try CreateEditor('EditorFichasEmpleadoPreview', IEditorFichasEmpleadoPreview, AEditor); if Assigned(AEditor) then begin try AEditor.Controller := Self; AEditor.ListaID := ListaID; AEditor.LoadFromStream(AStream); AEditor.Preview; finally AEditor.Release; end; end; finally FreeAndNil(AStream); AEditor := Nil; end; finally HideHourglassCursor; end; end; procedure TFichasEmpleadoReportController.Print(const ListaID : TIntegerList); var AStream: Binary; AEditor : IEditorFichasEmpleadoPreview; begin AEditor := NIL; ShowHourglassCursor; try AStream := FDataModule.GetReport(ListaID); try CreateEditor('EditorFichasEmpleadoPreview', IEditorFichasEmpleadoPreview, AEditor); if Assigned(AEditor) then begin try AEditor.Controller := Self; AEditor.ListaID := ListaID; AEditor.LoadFromStream(AStream); AEditor.Print; finally AEditor.Release; end; end; finally FreeAndNil(AStream); AEditor := Nil; end; finally HideHourglassCursor; end; end; end.