Tecsitel_FactuGES2/Source/Modulos/Contactos/Controller/uFichasEmpleadoReportController.pas
2007-09-04 17:44:53 +00:00

103 lines
2.5 KiB
ObjectPascal

unit uFichasEmpleadoReportController;
interface
uses
Classes, SysUtils, uDADataTable, uControllerBase, uIDataModuleFichasEmpleadoReport,
uEmpleadosController;
type
IFichasEmpleadoReportController = interface
['{8E43F55F-7D5A-4778-8523-7C105EAEB1AB}']
procedure Preview(const AFichaID : String);
procedure Print(const AFichaID : String);
end;
TFichasEmpleadoReportController = class(TInterfacedObject, IFichasEmpleadoReportController)
private
FDataModule : IDataModuleFichasEmpleadoReport;
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
public
constructor Create;
destructor Destroy; override;
procedure Preview(const AFichaID : String);
procedure Print(const AFichaID : String);
end;
implementation
uses
uROTypes, uEditorRegistryUtils, uIEditorFichasEmpleadoPreview,
uEditorPreview, uDataModuleEmpleados, uEditorBase, cxControls;
{ TFichasEmpleadoReportController }
constructor TFichasEmpleadoReportController.Create;
begin
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 AFichaID : String);
var
AStream: Binary;
AEditor : IEditorFichasEmpleadoPreview;
begin
AEditor := NIL;
ShowHourglassCursor;
try
AStream := FDataModule.GetReport(AFichaID);
try
CreateEditor('EditorFichasEmpleadoPreview', IEditorFichasEmpleadoPreview, AEditor);
AEditor.LoadFromStream(AStream);
finally
AStream.Free;
end;
finally
HideHourglassCursor;
end;
if Assigned(AEditor) then
AEditor.Preview;
end;
procedure TFichasEmpleadoReportController.Print(const AFichaID : String);
var
AStream: Binary;
AEditor : IEditorFichasEmpleadoPreview;
begin
AEditor := NIL;
ShowHourglassCursor;
try
AStream := FDataModule.GetReport(AFichaID);
try
CreateEditor('EditorFichasEmpleadoPreview', IEditorFichasEmpleadoPreview, AEditor);
AEditor.LoadFromStream(AStream);
finally
AStream.Free;
end;
finally
HideHourglassCursor;
end;
if Assigned(AEditor) then
AEditor.Print
end;
end.