2007-11-16 20:58:56 +00:00
|
|
|
unit uFacturasProveedorReportController;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
Classes, SysUtils, uDADataTable, uControllerBase, uIDataModuleFacturasProveedorReport,
|
|
|
|
|
uClientesController, uDetallesFacturaProveedorController, uBizFacturasProveedor;
|
|
|
|
|
|
|
|
|
|
type
|
2008-11-10 19:38:27 +00:00
|
|
|
IFacturasProveedorReportController = interface(IControllerBase)
|
2007-11-16 20:58:56 +00:00
|
|
|
['{551F82DC-B8DC-482E-A20D-15003E845078}']
|
|
|
|
|
procedure Preview(const AFacturaID : String);
|
|
|
|
|
procedure Print(const AFacturaID : String);
|
|
|
|
|
end;
|
|
|
|
|
|
2008-11-10 19:38:27 +00:00
|
|
|
TFacturasProveedorReportController = class(TControllerBase, IFacturasProveedorReportController)
|
2007-11-16 20:58:56 +00:00
|
|
|
private
|
|
|
|
|
FDataModule : IDataModuleFacturasProveedorReport;
|
|
|
|
|
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
|
|
|
|
|
public
|
2008-11-10 19:38:27 +00:00
|
|
|
constructor Create; override;
|
2007-11-16 20:58:56 +00:00
|
|
|
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
|
2008-11-10 19:38:27 +00:00
|
|
|
inherited;
|
2007-11-16 20:58:56 +00:00
|
|
|
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;
|
2008-11-11 16:22:18 +00:00
|
|
|
|
2009-06-02 11:06:34 +00:00
|
|
|
ShowHourglassCursor;
|
2007-11-16 20:58:56 +00:00
|
|
|
try
|
2009-06-02 11:06:34 +00:00
|
|
|
AStream := FDataModule.GetReport(AFacturaID);
|
|
|
|
|
try
|
|
|
|
|
CreateEditor('EditorFacturasProveedorPreview', IEditorFacturasProveedorPreview, AEditor);
|
|
|
|
|
if Assigned(AEditor) then
|
|
|
|
|
try
|
|
|
|
|
AEditor.LoadFromStream(AStream);
|
|
|
|
|
AEditor.Preview;
|
|
|
|
|
finally
|
|
|
|
|
AEditor.Release;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
AEditor := Nil;
|
|
|
|
|
end;
|
2007-11-16 20:58:56 +00:00
|
|
|
finally
|
2009-06-02 11:06:34 +00:00
|
|
|
HideHourglassCursor;
|
2007-11-16 20:58:56 +00:00
|
|
|
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);
|
2007-11-18 20:08:55 +00:00
|
|
|
if Assigned(AEditor) then
|
2008-11-13 13:10:32 +00:00
|
|
|
try
|
|
|
|
|
AEditor.LoadFromStream(AStream);
|
|
|
|
|
AEditor.Print;
|
|
|
|
|
finally
|
|
|
|
|
AEditor.Release;
|
|
|
|
|
end;
|
2007-11-16 20:58:56 +00:00
|
|
|
finally
|
2007-11-18 20:08:55 +00:00
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
AEditor := Nil;
|
2007-11-16 20:58:56 +00:00
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|