2011-11-14 17:40:41 +00:00
|
|
|
|
unit uRptAlbaranesCliente_Server;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, frxClass, frxDBSet, uDAScriptingProvider,
|
|
|
|
|
|
uDADataTable, uDACDSDataTable, DB, uDAClasses, frxChart, frxGradient,
|
|
|
|
|
|
frxChBox, frxCross, frxOLE, frxBarcode, frxRich, uDABINAdapter, uROTypes,
|
|
|
|
|
|
uDAInterfaces, uDADataStreamer, uDABin2DataStreamer, uDAMemDataTable,
|
|
|
|
|
|
frxExportPDF, FactuGES_Intf;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
TRptAlbaranesCliente = class(TDataModule)
|
|
|
|
|
|
DADataCabecera: TDADataSource;
|
|
|
|
|
|
DADataDetalles: TDADataSource;
|
|
|
|
|
|
tbl_Cabecera: TDAMemDataTable;
|
|
|
|
|
|
tbl_Detalles: TDAMemDataTable;
|
|
|
|
|
|
frxRichObject1: TfrxRichObject;
|
|
|
|
|
|
frxBarCodeObject1: TfrxBarCodeObject;
|
|
|
|
|
|
frxOLEObject1: TfrxOLEObject;
|
|
|
|
|
|
frxCrossObject1: TfrxCrossObject;
|
|
|
|
|
|
frxCheckBoxObject1: TfrxCheckBoxObject;
|
|
|
|
|
|
frxGradientObject1: TfrxGradientObject;
|
|
|
|
|
|
frxChartObject1: TfrxChartObject;
|
|
|
|
|
|
frxDBCabecera: TfrxDBDataset;
|
|
|
|
|
|
frxDBDetalles: TfrxDBDataset;
|
|
|
|
|
|
frxReport: TfrxReport;
|
|
|
|
|
|
Bin2DataStreamer: TDABin2DataStreamer;
|
|
|
|
|
|
tbl_Etiquetas: TDAMemDataTable;
|
|
|
|
|
|
DADataEtiquetas: TDADataSource;
|
|
|
|
|
|
frxDBEtiquetas: TfrxDBDataset;
|
|
|
|
|
|
frxPDFExport1: TfrxPDFExport;
|
|
|
|
|
|
schReport: TDASchema;
|
|
|
|
|
|
DataDictionary: TDADataDictionary;
|
|
|
|
|
|
procedure DataModuleCreate(Sender: TObject);
|
|
|
|
|
|
private
|
|
|
|
|
|
FConnection: IDAConnection;
|
2011-11-23 16:45:58 +00:00
|
|
|
|
FVerLogotipo: Boolean;
|
2013-06-03 16:01:08 +00:00
|
|
|
|
FVerPrecios: Boolean;
|
2013-06-07 16:09:30 +00:00
|
|
|
|
FVerTotales: Boolean;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
//Genera cada uno de los albaranes a imprimir
|
|
|
|
|
|
procedure _GenerarAlbaran(const ID: Integer);
|
|
|
|
|
|
public
|
2013-06-07 16:09:30 +00:00
|
|
|
|
function GenerarAlbaran(const ListaID : TIntegerArray; const VerLogotipo: Boolean = True; const VerPrecios: Boolean = True; const VerTotales: Boolean = True): Binary;
|
|
|
|
|
|
function GenerarAlbaranEnPDF(const ListaID : TIntegerArray; const VerLogotipo: Boolean = True; const VerPrecios: Boolean = True; const VerTotales: Boolean = True): Binary;
|
2021-02-07 17:20:37 +00:00
|
|
|
|
function GenerarEtiquetas(const AID : Integer; const AAgencia: Variant; const ARefPedido: Variant; const ANumEtiquetas: Integer; const AEtiquetaIni: Integer): Binary;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
uSistemaFunc, uDataModuleServer, schAlbaranesClienteClient_Intf;
|
|
|
|
|
|
|
|
|
|
|
|
const
|
|
|
|
|
|
rptInfAlbaran = 'InfAlbaranCliente.fr3';
|
|
|
|
|
|
rptInfEtiquetas = 'InfEtiquetasAlbaranCliente.fr3';
|
|
|
|
|
|
|
|
|
|
|
|
{ Dataset names for schReport }
|
|
|
|
|
|
ds_InformeCabecera = 'Informe_Cabecera';
|
|
|
|
|
|
ds_InformeDetalles = 'Informe_Detalles';
|
|
|
|
|
|
ds_InformeDetallesEtiquetas = 'Informe_Detalles_Etiquetas';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ TRptAlbaranesCliente }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
procedure TRptAlbaranesCliente.DataModuleCreate(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
schReport.ConnectionManager := dmServer.ConnectionManager;
|
|
|
|
|
|
FConnection := dmServer.DarNuevaConexion;
|
|
|
|
|
|
frxReport.EngineOptions.NewSilentMode := simReThrow;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2013-06-07 16:09:30 +00:00
|
|
|
|
function TRptAlbaranesCliente.GenerarAlbaran(const ListaID : TIntegerArray; const VerLogotipo: Boolean = True; const VerPrecios: Boolean= True; const VerTotales: Boolean = True): Binary;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
var
|
|
|
|
|
|
i: Integer;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := Binary.Create;
|
2011-11-23 16:45:58 +00:00
|
|
|
|
//Inicializamos parametros
|
|
|
|
|
|
FVerLogotipo := VerLogotipo;
|
2013-06-07 16:09:30 +00:00
|
|
|
|
FVerPrecios := VerPrecios;
|
|
|
|
|
|
FVerTotales := VerTotales;
|
2011-11-23 16:45:58 +00:00
|
|
|
|
|
2011-11-14 17:40:41 +00:00
|
|
|
|
//Vamos generando todos y cada uno de los presupuestos recibidos
|
|
|
|
|
|
for i := 0 to ListaID.Count - 1 do
|
|
|
|
|
|
_GenerarAlbaran(ListaID.Items[i]);
|
|
|
|
|
|
|
|
|
|
|
|
frxReport.PreviewPages.SaveToStream(Result);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2013-06-07 16:09:30 +00:00
|
|
|
|
function TRptAlbaranesCliente.GenerarAlbaranEnPDF(const ListaID: TIntegerArray; const VerLogotipo: Boolean = True; const VerPrecios: Boolean = True; const VerTotales: Boolean = True): Binary;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
var
|
|
|
|
|
|
i: Integer;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := Binary.Create;
|
|
|
|
|
|
|
2011-11-23 16:45:58 +00:00
|
|
|
|
//Inicializamos parametros
|
|
|
|
|
|
FVerLogotipo := VerLogotipo;
|
2013-06-07 16:09:30 +00:00
|
|
|
|
FVerPrecios := VerPrecios;
|
|
|
|
|
|
FVerTotales := VerTotales;
|
2011-11-23 16:45:58 +00:00
|
|
|
|
|
2011-11-14 17:40:41 +00:00
|
|
|
|
//Vamos generando todos y cada uno de los presupuestos recibidos
|
|
|
|
|
|
for i := 0 to ListaID.Count - 1 do
|
|
|
|
|
|
_GenerarAlbaran(ListaID.Items[i]);
|
|
|
|
|
|
|
|
|
|
|
|
frxPDFExport1.Stream := Result;
|
|
|
|
|
|
frxReport.Export(frxPDFExport1)
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TRptAlbaranesCliente._GenerarAlbaran(const ID: integer);
|
|
|
|
|
|
var
|
|
|
|
|
|
AInforme: Variant;
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
FConnection.BeginTransaction; //<--- Creo que no va a hacer falta. "PUES SI ES NECESARIO"
|
|
|
|
|
|
try
|
|
|
|
|
|
tbl_Cabecera.Active := False;
|
|
|
|
|
|
tbl_Detalles.Active := False;
|
|
|
|
|
|
|
|
|
|
|
|
tbl_Cabecera.ParamByName('ID').AsInteger := ID;
|
|
|
|
|
|
tbl_Detalles.ParamByName('ID_ALBARAN').AsInteger := ID;
|
|
|
|
|
|
|
|
|
|
|
|
tbl_Cabecera.Active := True;
|
|
|
|
|
|
tbl_Detalles.Active := True;
|
|
|
|
|
|
|
|
|
|
|
|
AInforme := DarRutaFichero(DarRutaInformes, rptInfAlbaran, tbl_Cabecera.FieldByName('ID_EMPRESA').AsString, tbl_Cabecera.FieldByName('ID_TIENDA').AsString);
|
|
|
|
|
|
if VarIsNull(AInforme) then
|
|
|
|
|
|
raise Exception.Create (('Error Servidor: _GenerarAlbaran, no encuentra informe' + rptInfAlbaran));
|
|
|
|
|
|
|
|
|
|
|
|
frxReport.LoadFromFile(AInforme, True);
|
2011-11-23 16:45:58 +00:00
|
|
|
|
frxReport.Variables.Variables['VerLogotipo'] := FVerLogotipo;
|
2013-06-07 16:09:30 +00:00
|
|
|
|
frxReport.Variables.Variables['VerPrecios'] := FVerPrecios;
|
|
|
|
|
|
frxReport.Variables.Variables['VerTotales'] := FVerTotales;
|
2011-11-23 16:45:58 +00:00
|
|
|
|
frxReport.ReportOptions.Name := 'Albar<61>n de cliente ' + tbl_Cabecera.FieldByName('REFERENCIA').AsString;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
frxReport.PrepareReport(False);
|
|
|
|
|
|
finally
|
|
|
|
|
|
FConnection.RollbackTransaction; //<--- Creo que no va a hacer falta. "PUES SI ES NECESARIO"
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2021-02-07 17:20:37 +00:00
|
|
|
|
function TRptAlbaranesCliente.GenerarEtiquetas(const AID : Integer; const AAgencia: Variant; const ARefPedido: Variant; const ANumEtiquetas: Integer; const AEtiquetaIni: Integer): Binary;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
var
|
|
|
|
|
|
AInforme: Variant;
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := Binary.Create;
|
|
|
|
|
|
FConnection.BeginTransaction;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
tbl_Etiquetas.ParamByName('ID_ALBARAN').AsInteger := AID;
|
2021-02-07 17:20:37 +00:00
|
|
|
|
tbl_Etiquetas.ParamByName('AGENCIA').AsString := AAgencia;
|
|
|
|
|
|
tbl_Etiquetas.ParamByName('REF_PEDIDO').AsString := ARefPedido;
|
|
|
|
|
|
tbl_Etiquetas.ParamByName('NUM_ETIQUETAS').AsInteger := ANumEtiquetas;
|
|
|
|
|
|
tbl_Etiquetas.ParamByName('ETIQUETA_INI').AsInteger := AEtiquetaIni;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
tbl_Etiquetas.Active := True;
|
|
|
|
|
|
|
2021-02-07 17:20:37 +00:00
|
|
|
|
AInforme := DarRutaFichero(DarRutaInformes, rptInfEtiquetas, tbl_Cabecera.FieldByName('ID_EMPRESA').AsString);
|
2011-11-14 17:40:41 +00:00
|
|
|
|
if VarIsNull(AInforme) then
|
|
|
|
|
|
raise Exception.Create (('Error Servidor: GenerarEtiquetas, no encuentra informe' + rptInfEtiquetas));
|
|
|
|
|
|
|
|
|
|
|
|
frxReport.LoadFromFile(AInforme, True);
|
2021-02-07 17:20:37 +00:00
|
|
|
|
// if withRefCliente then
|
|
|
|
|
|
// frxReport.Variables.Variables['withRefCliente'] := 1
|
|
|
|
|
|
// else
|
|
|
|
|
|
// frxReport.Variables.Variables['withRefCliente'] := 0;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
frxReport.PrepareReport(False);
|
|
|
|
|
|
frxReport.PreviewPages.SaveToStream(Result);
|
|
|
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
|
FConnection.RollbackTransaction;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|