2010-08-11 10:53:06 +00:00
|
|
|
unit uRecibosClienteReportController;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
Classes, SysUtils, uDADataTable, uControllerBase, uIDataModuleRecibosClienteReport,
|
|
|
|
|
uBizRecibosCliente, uIntegerListUtils;
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
IRecibosClienteReportController = interface(IControllerBase)
|
|
|
|
|
['{3837DFA3-0A38-4BB2-B0DB-D0615249EA49}']
|
|
|
|
|
procedure Preview(const ListaID : TIntegerList);
|
2010-08-26 17:10:53 +00:00
|
|
|
function Print(const ListaID : TIntegerList): Boolean;
|
2010-09-22 11:07:18 +00:00
|
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
2010-08-11 10:53:06 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
TRecibosClienteReportController = class(TControllerBase, IRecibosClienteReportController)
|
|
|
|
|
private
|
|
|
|
|
FDataModule : IDataModuleRecibosClienteReport;
|
|
|
|
|
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
|
|
|
|
|
public
|
|
|
|
|
constructor Create; override;
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
|
|
|
|
procedure Preview(const ListaID : TIntegerList);
|
2010-08-26 17:10:53 +00:00
|
|
|
function Print(const ListaID : TIntegerList): Boolean;
|
2010-09-22 11:07:18 +00:00
|
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''): Boolean;
|
2010-08-11 10:53:06 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
uROTypes, uEditorRegistryUtils, uIEditorRecibosClientePreview,
|
2010-08-26 17:10:53 +00:00
|
|
|
uEditorPreview, uDataModuleRecibosCliente, uEditorBase, cxControls,
|
|
|
|
|
uFactuGES_App, uStringsUtils, uSistemaFunc, schRecibosClienteClient_Intf;
|
|
|
|
|
|
2010-08-11 10:53:06 +00:00
|
|
|
|
|
|
|
|
{ TRecibosClienteReportController }
|
|
|
|
|
|
|
|
|
|
constructor TRecibosClienteReportController.Create;
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
FDataModule := TDataModuleRecibosCliente.Create(Nil);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TRecibosClienteReportController.CreateEditor(const AName: String;
|
|
|
|
|
const IID: TGUID; out Intf): Boolean;
|
|
|
|
|
begin
|
|
|
|
|
Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
destructor TRecibosClienteReportController.Destroy;
|
|
|
|
|
begin
|
|
|
|
|
FDataModule := NIL;
|
|
|
|
|
inherited;
|
|
|
|
|
end;
|
|
|
|
|
|
2010-09-22 11:07:18 +00:00
|
|
|
function TRecibosClienteReportController.ExportToPDF(const AID: Integer; const AFileName: String): Boolean;
|
|
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
begin
|
|
|
|
|
Result := False;
|
|
|
|
|
if EsCadenaVacia(AFileName) then
|
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
|
|
|
|
// AStream := FDataModule.GetRptPDFRecibo(AID);
|
|
|
|
|
try
|
|
|
|
|
AStream.SaveToFile(AFileName);
|
|
|
|
|
Result := True;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
2010-08-11 10:53:06 +00:00
|
|
|
procedure TRecibosClienteReportController.Preview(const ListaID : TIntegerList);
|
|
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
AEditor : IEditorRecibosClientePreview;
|
|
|
|
|
begin
|
|
|
|
|
AEditor := NIL;
|
|
|
|
|
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
|
|
|
|
AStream := FDataModule.GetReport(ListaID);
|
|
|
|
|
try
|
|
|
|
|
CreateEditor('EditorRecibosClientePreview', IEditorRecibosClientePreview, 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;
|
|
|
|
|
|
2010-08-26 17:10:53 +00:00
|
|
|
function TRecibosClienteReportController.Print(const ListaID : TIntegerList): Boolean;
|
2010-08-11 10:53:06 +00:00
|
|
|
var
|
|
|
|
|
AStream: Binary;
|
|
|
|
|
AEditor : IEditorRecibosClientePreview;
|
|
|
|
|
begin
|
2010-08-26 17:10:53 +00:00
|
|
|
Result := False;
|
2010-08-11 10:53:06 +00:00
|
|
|
AEditor := NIL;
|
2010-08-26 17:10:53 +00:00
|
|
|
|
2010-08-11 10:53:06 +00:00
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
|
|
|
|
AStream := FDataModule.GetReport(ListaID);
|
|
|
|
|
try
|
|
|
|
|
CreateEditor('EditorRecibosClientePreview', IEditorRecibosClientePreview, AEditor);
|
|
|
|
|
if Assigned(AEditor) then
|
|
|
|
|
begin
|
|
|
|
|
try
|
|
|
|
|
AEditor.Controller := Self;
|
|
|
|
|
AEditor.ListaID := ListaID;
|
|
|
|
|
AEditor.LoadFromStream(AStream);
|
2010-08-26 17:10:53 +00:00
|
|
|
AEditor.TablaImpresion := nme_RecibosCliente;
|
|
|
|
|
AEditor.IdTablaImpresion := ListaID.ToString;
|
|
|
|
|
Result := AEditor.Print;
|
2010-08-11 10:53:06 +00:00
|
|
|
finally
|
|
|
|
|
AEditor.Release;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(AStream);
|
|
|
|
|
AEditor := Nil;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|