git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@947 0c75b7a4-871f-7646-8a2f-f78d34cc349f
170 lines
5.0 KiB
ObjectPascal
170 lines
5.0 KiB
ObjectPascal
unit uFacturasClienteReportController;
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, uDADataTable, uControllerBase, uIDataModuleFacturasClienteReport,
|
|
uClientesController, uDetallesFacturaClienteController,
|
|
uBizFacturasCliente, uIntegerListUtils;
|
|
|
|
type
|
|
IFacturasClienteReportController = interface(IControllerBase)
|
|
['{A0F41767-4FF6-4BAE-9FC9-894DD721D756}']
|
|
procedure Preview(const AListaID : TIntegerList; const VerSello: Boolean = True; const VerCopia: Boolean = True);
|
|
procedure Print(const AListaID : TIntegerList; const VerSello: Boolean = True; const VerCopia: Boolean = True);
|
|
function ExportToWord(const AID: Integer; const AFileName : String = ''; const VerSello: Boolean = True): Boolean;
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''; const VerSello: Boolean = True): Boolean;
|
|
end;
|
|
|
|
TFacturasClienteReportController = class(TControllerBase, IFacturasClienteReportController)
|
|
private
|
|
FDataModule : IDataModuleFacturasClienteReport;
|
|
function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
|
|
public
|
|
constructor Create; override;
|
|
destructor Destroy; override;
|
|
|
|
procedure Preview(const AListaID : TIntegerList; const VerSello: Boolean = True; const VerCopia: Boolean = True);
|
|
procedure Print(const AListaID : TIntegerList; const VerSello: Boolean = True; const VerCopia: Boolean = True);
|
|
function ExportToWord(const AID: Integer; const AFileName : String = ''; const VerSello: Boolean = True): Boolean;
|
|
function ExportToPDF(const AID: Integer; const AFileName : String = ''; const VerSello: Boolean = True): Boolean;
|
|
end;
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
uROTypes, uEditorRegistryUtils, uIEditorFacturasClientePreview,
|
|
uEditorPreview, uDataModuleFacturasCliente, uEditorBase, cxControls,
|
|
uStringsUtils, uSistemaFunc;
|
|
|
|
{ TFacturasClienteReportController }
|
|
|
|
constructor TFacturasClienteReportController.Create;
|
|
begin
|
|
inherited;
|
|
FDataModule := TDataModuleFacturasCliente.Create(Nil);
|
|
end;
|
|
|
|
function TFacturasClienteReportController.CreateEditor(const AName: String;
|
|
const IID: TGUID; out Intf): Boolean;
|
|
begin
|
|
Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf);
|
|
end;
|
|
|
|
|
|
destructor TFacturasClienteReportController.Destroy;
|
|
begin
|
|
FDataModule := NIL;
|
|
inherited;
|
|
end;
|
|
|
|
function TFacturasClienteReportController.ExportToPDF(const AID: Integer; const AFileName: String = ''; const VerSello: Boolean = True): Boolean;
|
|
var
|
|
AStream: Binary;
|
|
begin
|
|
Result := False;
|
|
if EsCadenaVacia(AFileName) then
|
|
Exit;
|
|
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetRptPDFFactura(AID, VerSello);
|
|
try
|
|
AStream.SaveToFile(AFileName);
|
|
Result := True;
|
|
finally
|
|
FreeAndNil(AStream);
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
function TFacturasClienteReportController.ExportToWord(const AID: Integer;
|
|
const AFileName: String = ''; const VerSello: Boolean = True): Boolean;
|
|
var
|
|
AStream: Binary;
|
|
AFile : String;
|
|
begin
|
|
Result := False;
|
|
AFile := AFileName;
|
|
|
|
if EsCadenaVacia(AFile) and (not PreguntarFicheroWordExportar(AFile)) then
|
|
Exit;
|
|
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetRptWordFactura(AID, VerSello);
|
|
try
|
|
AStream.SaveToFile(AFile);
|
|
Result := True;
|
|
finally
|
|
FreeAndNil(AStream);
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
procedure TFacturasClienteReportController.Preview(const AListaID : TIntegerList; const VerSello: Boolean = True; const VerCopia: Boolean = True);
|
|
var
|
|
AStream: Binary;
|
|
AEditor : IEditorFacturasClientePreview;
|
|
begin
|
|
AEditor := NIL;
|
|
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetRptFacturas(AListaID, VerSello, VerCopia);
|
|
try
|
|
CreateEditor('EditorFacturasClientePreview', IEditorFacturasClientePreview, AEditor);
|
|
if Assigned(AEditor) then
|
|
try
|
|
AEditor.Controller := Self;
|
|
AEditor.ListaID := AListaID;
|
|
AEditor.LoadFromStream(AStream);
|
|
AEditor.Preview;
|
|
finally
|
|
AEditor.Release;
|
|
end;
|
|
finally
|
|
FreeAndNil(AStream);
|
|
AEditor := Nil;
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
procedure TFacturasClienteReportController.Print(const AListaID : TIntegerList; const VerSello: Boolean = True; const VerCopia: Boolean = True);
|
|
var
|
|
AStream: Binary;
|
|
AEditor : IEditorFacturasClientePreview;
|
|
begin
|
|
AEditor := NIL;
|
|
|
|
ShowHourglassCursor;
|
|
try
|
|
AStream := FDataModule.GetRptFacturas(AListaID, VerSello, VerCopia);
|
|
try
|
|
CreateEditor('EditorFacturasClientePreview', IEditorFacturasClientePreview, AEditor);
|
|
if Assigned(AEditor) then
|
|
try
|
|
AEditor.Controller := Self;
|
|
AEditor.LoadFromStream(AStream);
|
|
AEditor.Print;
|
|
finally
|
|
AEditor.Release;
|
|
end;
|
|
finally
|
|
FreeAndNil(AStream);
|
|
AEditor := Nil;
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
end.
|