Facturas de cliente: exportación a word del informe (en preparación).
git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@290 0c75b7a4-871f-7646-8a2f-f78d34cc349f
This commit is contained in:
parent
e6f9cf0502
commit
7e01bc60d4
@ -8,13 +8,14 @@ uses
|
|||||||
uBizFacturasCliente;
|
uBizFacturasCliente;
|
||||||
|
|
||||||
type
|
type
|
||||||
IFacturasClienteReportController = interface
|
IFacturasClienteReportController = interface(IControllerBase)
|
||||||
['{A0F41767-4FF6-4BAE-9FC9-894DD721D756}']
|
['{A0F41767-4FF6-4BAE-9FC9-894DD721D756}']
|
||||||
procedure Preview(const AFacturaID : String);
|
procedure Preview(const AListaID : String);
|
||||||
procedure Print(const AFacturaID : String);
|
procedure Print(const AListaID : String);
|
||||||
|
function ExportToWord(const AID: Integer; const AFileName : String = ''): Boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TFacturasClienteReportController = class(TInterfacedObject, IFacturasClienteReportController)
|
TFacturasClienteReportController = class(TControllerBase, IFacturasClienteReportController)
|
||||||
private
|
private
|
||||||
FDataModule : IDataModuleFacturasClienteReport;
|
FDataModule : IDataModuleFacturasClienteReport;
|
||||||
function CreateEditor(const AName: String; const IID: TGUID;
|
function CreateEditor(const AName: String; const IID: TGUID;
|
||||||
@ -23,8 +24,9 @@ type
|
|||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
procedure Preview(const AFacturaID : String);
|
procedure Preview(const AListaID : String);
|
||||||
procedure Print(const AFacturaID : String);
|
procedure Print(const AListaID : String);
|
||||||
|
function ExportToWord(const AID: Integer; const AFileName : String = ''): Boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -32,7 +34,8 @@ implementation
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
uROTypes, uEditorRegistryUtils, uIEditorFacturasClientePreview,
|
uROTypes, uEditorRegistryUtils, uIEditorFacturasClientePreview,
|
||||||
uEditorPreview, uDataModuleFacturasCliente, uEditorBase, cxControls;
|
uEditorPreview, uDataModuleFacturasCliente, uEditorBase, cxControls,
|
||||||
|
uStringsUtils, uSistemaFunc;
|
||||||
|
|
||||||
{ TFacturasClienteReportController }
|
{ TFacturasClienteReportController }
|
||||||
|
|
||||||
@ -54,7 +57,31 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFacturasClienteReportController.Preview(const AFacturaID : String);
|
function TFacturasClienteReportController.ExportToWord(const AID: Integer;
|
||||||
|
const AFileName: String): Boolean;
|
||||||
|
var
|
||||||
|
AStream: Binary;
|
||||||
|
AFile : String;
|
||||||
|
begin
|
||||||
|
AFile := AFileName;
|
||||||
|
if EsCadenaVacia(AFile) and (not DarFicheroWordExportar(AFile)) then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
ShowHourglassCursor;
|
||||||
|
try
|
||||||
|
AStream := FDataModule.GetRptWordFactura(AID);
|
||||||
|
try
|
||||||
|
AStream.SaveToFile(AFile);
|
||||||
|
Result := True;
|
||||||
|
finally
|
||||||
|
FreeAndNil(AStream);
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
HideHourglassCursor;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFacturasClienteReportController.Preview(const AListaID : String);
|
||||||
var
|
var
|
||||||
AStream: Binary;
|
AStream: Binary;
|
||||||
AEditor : IEditorFacturasClientePreview;
|
AEditor : IEditorFacturasClientePreview;
|
||||||
@ -62,12 +89,14 @@ begin
|
|||||||
AEditor := NIL;
|
AEditor := NIL;
|
||||||
ShowHourglassCursor;
|
ShowHourglassCursor;
|
||||||
try
|
try
|
||||||
AStream := FDataModule.GetReport(AFacturaID);
|
AStream := FDataModule.GetRptFacturas(AListaID);
|
||||||
try
|
try
|
||||||
CreateEditor('EditorFacturasClientePreview', IEditorFacturasClientePreview, AEditor);
|
CreateEditor('EditorFacturasClientePreview', IEditorFacturasClientePreview, AEditor);
|
||||||
if Assigned(AEditor) then
|
if Assigned(AEditor) then
|
||||||
with AEditor do
|
with AEditor do
|
||||||
begin
|
begin
|
||||||
|
AEditor.Controller := Self;
|
||||||
|
AEditor.ListaID := AListaID;
|
||||||
LoadFromStream(AStream);
|
LoadFromStream(AStream);
|
||||||
Preview;
|
Preview;
|
||||||
Release;
|
Release;
|
||||||
@ -81,7 +110,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFacturasClienteReportController.Print(const AFacturaID : String);
|
procedure TFacturasClienteReportController.Print(const AListaID : String);
|
||||||
var
|
var
|
||||||
AStream: Binary;
|
AStream: Binary;
|
||||||
AEditor : IEditorFacturasClientePreview;
|
AEditor : IEditorFacturasClientePreview;
|
||||||
@ -89,12 +118,14 @@ begin
|
|||||||
AEditor := NIL;
|
AEditor := NIL;
|
||||||
ShowHourglassCursor;
|
ShowHourglassCursor;
|
||||||
try
|
try
|
||||||
AStream := FDataModule.GetReport(AFacturaID);
|
AStream := FDataModule.GetRptFacturas(AListaID);
|
||||||
try
|
try
|
||||||
CreateEditor('EditorFacturasClientePreview', IEditorFacturasClientePreview, AEditor);
|
CreateEditor('EditorFacturasClientePreview', IEditorFacturasClientePreview, AEditor);
|
||||||
if Assigned(AEditor) then
|
if Assigned(AEditor) then
|
||||||
with AEditor do
|
with AEditor do
|
||||||
begin
|
begin
|
||||||
|
AEditor.Controller := Self;
|
||||||
|
AEditor.ListaID := AListaID;
|
||||||
LoadFromStream(AStream);
|
LoadFromStream(AStream);
|
||||||
Print;
|
Print;
|
||||||
Release;
|
Release;
|
||||||
|
|||||||
@ -30,7 +30,8 @@ type
|
|||||||
function NewItem : IBizFacturaCliente;
|
function NewItem : IBizFacturaCliente;
|
||||||
|
|
||||||
// Report
|
// Report
|
||||||
function GetReport(const AFacturaID: String): Binary;
|
function GetRptFacturas(const AListaID: String): Binary;
|
||||||
|
function GetRptWordFactura(const AID: Integer): Binary;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -49,9 +50,16 @@ begin
|
|||||||
RORemoteService.Message := dmConexion.Message;
|
RORemoteService.Message := dmConexion.Message;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TDataModuleFacturasCliente.GetReport(const AFacturaID: String): Binary;
|
function TDataModuleFacturasCliente.GetRptFacturas(
|
||||||
|
const AListaID: String): Binary;
|
||||||
begin
|
begin
|
||||||
// Result := (RORemoteService as IsrvFacturasCliente).GenerateReport(AFacturaID)
|
Result := (RORemoteService as IsrvFacturasCliente).GenerateReport(AListaID)
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TDataModuleFacturasCliente.GetRptWordFactura(
|
||||||
|
const AID: Integer): Binary;
|
||||||
|
begin
|
||||||
|
Result := (RORemoteService as IsrvFacturasCliente).GenerateReportEnWord(AID)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TDataModuleFacturasCliente.NewItem: IBizFacturaCliente;
|
function TDataModuleFacturasCliente.NewItem: IBizFacturaCliente;
|
||||||
|
|||||||
@ -7,8 +7,9 @@ uses
|
|||||||
|
|
||||||
type
|
type
|
||||||
IDataModuleFacturasClienteReport = interface
|
IDataModuleFacturasClienteReport = interface
|
||||||
['{F498AC70-AA38-4C06-B301-85A4AC0B210B}']
|
['{D241A912-78C6-4C65-AEBF-8DDEFE35F511}']
|
||||||
function GetReport(const AFacturaID: String): Binary;
|
function GetRptFacturas(const AListaID: String): Binary;
|
||||||
|
function GetRptWordFactura(const AID: Integer): Binary;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|||||||
@ -2,9 +2,4 @@ inherited fEditorFacturasClientePreview: TfEditorFacturasClientePreview
|
|||||||
Caption = 'Previsualizar la factura'
|
Caption = 'Previsualizar la factura'
|
||||||
PixelsPerInch = 96
|
PixelsPerInch = 96
|
||||||
TextHeight = 13
|
TextHeight = 13
|
||||||
inherited frxReport1: TfrxReport
|
|
||||||
Datasets = <>
|
|
||||||
Variables = <>
|
|
||||||
Style = <>
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -12,10 +12,13 @@ uses
|
|||||||
JvFormPlacement, ImgList, PngImageList, StdActns, ActnList, ComCtrls,
|
JvFormPlacement, ImgList, PngImageList, StdActns, ActnList, ComCtrls,
|
||||||
TB2ExtItems, TBXExtItems, TBX, TB2Item, TB2Dock, TB2Toolbar, pngimage,
|
TB2ExtItems, TBXExtItems, TBX, TB2Item, TB2Dock, TB2Toolbar, pngimage,
|
||||||
ExtCtrls, JvExControls, JvComponent, JvNavigationPane, uIEditorFacturasClientePreview,
|
ExtCtrls, JvExControls, JvComponent, JvNavigationPane, uIEditorFacturasClientePreview,
|
||||||
JvExComCtrls, JvStatusBar;
|
JvExComCtrls, JvStatusBar, frxExportText, frxExportRTF, frxExportMail,
|
||||||
|
frxExportXLS, frxExportImage, frxExportPDF, frxClass, frxDCtrl, frxGradient,
|
||||||
|
frxChBox, frxCross, frxRich, frxOLE, frxBarcode;
|
||||||
|
|
||||||
type
|
type
|
||||||
TfEditorFacturasClientePreview = class(TfEditorPreview, IEditorFacturasClientePreview)
|
TfEditorFacturasClientePreview = class(TfEditorPreview, IEditorFacturasClientePreview)
|
||||||
|
procedure actExportarRTFExecute(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ Private declarations }
|
{ Private declarations }
|
||||||
public
|
public
|
||||||
@ -27,4 +30,26 @@ implementation
|
|||||||
|
|
||||||
{$R *.dfm}
|
{$R *.dfm}
|
||||||
|
|
||||||
|
uses
|
||||||
|
uFacturasClienteReportController;
|
||||||
|
|
||||||
|
procedure TfEditorFacturasClientePreview.actExportarRTFExecute(Sender: TObject);
|
||||||
|
var
|
||||||
|
AListaID : TStringList;
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
// inherited; <- No llamar al padre
|
||||||
|
if not Assigned(Controller) then
|
||||||
|
raise Exception.Create('No se ha asignado el controlador necesario');
|
||||||
|
|
||||||
|
AListaID := TStringList.Create;
|
||||||
|
try
|
||||||
|
AListaID.CommaText := Self.ListaID;
|
||||||
|
for I := 0 to AListaID.Count - 1 do
|
||||||
|
(Controller as IFacturasClienteReportController).ExportToWord(StrToInt(AListaID[I]));
|
||||||
|
finally
|
||||||
|
FreeAndNIL(AListaID);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user