2007-10-29 19:18:51 +00:00
|
|
|
unit uDataModuleAlbaranesCliente;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
2007-11-25 17:18:25 +00:00
|
|
|
DB, Classes, SysUtils, uDADesigntimeCall, uROTypes,
|
2007-10-29 19:18:51 +00:00
|
|
|
uRORemoteService, uROClient, uROBinMessage, uDAScriptingProvider,
|
|
|
|
|
uDACDSDataTable, uROWinInetHttpChannel, uDADataTable, uDABINAdapter,
|
2007-11-25 17:18:25 +00:00
|
|
|
|
2007-10-29 19:18:51 +00:00
|
|
|
uIDataModuleAlbaranesCliente, uBizAlbaranesCliente, uBizDetallesAlbaranCliente,
|
|
|
|
|
uIDataModuleAlbaranesClienteReport, uDataModuleBase, uDABin2DataStreamer, uDAMemDataTable,
|
2008-08-22 14:52:35 +00:00
|
|
|
uDAInterfaces, uDADataStreamer, uDARemoteDataAdapter, uIntegerListUtils;
|
2007-10-29 19:18:51 +00:00
|
|
|
|
|
|
|
|
type
|
|
|
|
|
TDataModuleAlbaranesCliente = class(TDataModuleBase, IDataModuleAlbaranesCliente, IDataModuleAlbaranesClienteReport)
|
|
|
|
|
RORemoteService: TRORemoteService;
|
|
|
|
|
rda_AlbaranesCliente: TDARemoteDataAdapter;
|
|
|
|
|
Bin2DataStreamer: TDABin2DataStreamer;
|
|
|
|
|
tbl_AlbaranesCliente: TDAMemDataTable;
|
|
|
|
|
ds_AlbaranesCliente: TDADataSource;
|
|
|
|
|
tbl_AlbaranesCliente_Detalles: TDAMemDataTable;
|
|
|
|
|
ds_AlbaranesCliente_Detalles: TDADataSource;
|
2009-02-27 10:44:29 +00:00
|
|
|
tbl_ListaAnosAlbaranes: TDAMemDataTable;
|
|
|
|
|
ds_ListaAnosAlbaranes: TDADataSource;
|
2007-10-29 19:18:51 +00:00
|
|
|
procedure DAClientDataModuleCreate(Sender: TObject);
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
function _GetDetalles : IBizDetallesAlbaranCliente;
|
|
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
procedure AsignarClaseNegocio(AAlbaran: TDADataTable); virtual;
|
|
|
|
|
|
|
|
|
|
public
|
|
|
|
|
function GetItems : IBizAlbaranCliente; virtual;
|
|
|
|
|
function GetItem(const ID : Integer) : IBizAlbaranCliente;
|
|
|
|
|
function NewItem : IBizAlbaranCliente;
|
|
|
|
|
|
|
|
|
|
// Report
|
2013-03-11 16:10:38 +00:00
|
|
|
function GetRptAlbaranes(const AListaID: TIntegerList; const ImprimirPrecio: Boolean = True;
|
|
|
|
|
const ImprimirRef: Boolean = True): Binary;
|
|
|
|
|
function GetRptWordAlbaran(const AID: Integer; const ImprimirPrecio: Boolean = True;
|
|
|
|
|
const ImprimirRef: Boolean = True): Binary;
|
|
|
|
|
function GetRptPDFAlbaran(const AID: Integer; const ImprimirPrecio: Boolean = True;
|
|
|
|
|
const ImprimirRef: Boolean = True): Binary;
|
|
|
|
|
function GetEtiquetas(const AID: Integer; withRefCliente: Boolean): Binary;
|
2009-02-27 10:44:29 +00:00
|
|
|
function GetAnosItems : TStringList;
|
2007-10-29 19:18:51 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
{$R *.DFM}
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
cxControls, FactuGES_Intf, uDataModuleConexion,
|
|
|
|
|
uDataTableUtils, schAlbaranesClienteClient_Intf, uBizContactos;
|
|
|
|
|
|
|
|
|
|
{ TdmAlbaranesCliente }
|
|
|
|
|
|
|
|
|
|
procedure TDataModuleAlbaranesCliente.AsignarClaseNegocio(AAlbaran: TDADataTable);
|
|
|
|
|
begin
|
|
|
|
|
AAlbaran.BusinessRulesID := BIZ_CLIENT_ALBARAN_CLIENTE;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TDataModuleAlbaranesCliente.DAClientDataModuleCreate(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
RORemoteService.Channel := dmConexion.Channel;
|
|
|
|
|
RORemoteService.Message := dmConexion.Message;
|
|
|
|
|
end;
|
|
|
|
|
|
2013-03-11 16:10:38 +00:00
|
|
|
function TDataModuleAlbaranesCliente.GetRptAlbaranes(
|
|
|
|
|
const AListaID: TIntegerList; const ImprimirPrecio,
|
|
|
|
|
ImprimirRef: Boolean): Binary;
|
2008-08-22 14:52:35 +00:00
|
|
|
var
|
|
|
|
|
AParam : TIntegerArray;
|
|
|
|
|
begin
|
2013-03-11 16:10:38 +00:00
|
|
|
AParam := AListaID.ToIntegerArray;
|
2008-08-22 14:52:35 +00:00
|
|
|
try
|
2013-03-11 16:10:38 +00:00
|
|
|
Result := (RORemoteService as IsrvAlbaranesCliente).GenerarInforme(AParam, ImprimirPrecio, ImprimirRef);
|
2008-08-22 14:52:35 +00:00
|
|
|
finally
|
|
|
|
|
FreeAndNil(AParam);
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
2013-03-11 16:10:38 +00:00
|
|
|
function TDataModuleAlbaranesCliente.GetRptPDFAlbaran(const AID: Integer; const ImprimirPrecio: Boolean = True;
|
|
|
|
|
const ImprimirRef: Boolean = True): Binary;
|
2008-08-22 14:52:35 +00:00
|
|
|
var
|
|
|
|
|
AParam : TIntegerArray;
|
2007-10-29 19:18:51 +00:00
|
|
|
begin
|
2008-08-22 14:52:35 +00:00
|
|
|
AParam := TIntegerArray.Create;
|
|
|
|
|
try
|
|
|
|
|
AParam.Add(AID);
|
2013-03-11 16:10:38 +00:00
|
|
|
Result := (RORemoteService as IsrvAlbaranesCliente).GenerarInforme(AParam, ImprimirPrecio, ImprimirRef);
|
2008-08-22 14:52:35 +00:00
|
|
|
finally
|
|
|
|
|
FreeAndNil(AParam);
|
|
|
|
|
end;
|
2007-10-29 19:18:51 +00:00
|
|
|
end;
|
|
|
|
|
|
2013-03-11 16:10:38 +00:00
|
|
|
function TDataModuleAlbaranesCliente.GetRptWordAlbaran(const AID: Integer; const ImprimirPrecio: Boolean = True;
|
|
|
|
|
const ImprimirRef: Boolean = True): Binary;
|
2008-02-07 09:59:33 +00:00
|
|
|
begin
|
2013-03-11 16:10:38 +00:00
|
|
|
Result := (RORemoteService as IsrvAlbaranesCliente).GenerarInformeEnWord(AID, ImprimirPrecio, ImprimirRef)
|
2008-02-07 09:59:33 +00:00
|
|
|
end;
|
|
|
|
|
|
2007-10-29 19:18:51 +00:00
|
|
|
function TDataModuleAlbaranesCliente.NewItem: IBizAlbaranCliente;
|
|
|
|
|
begin
|
|
|
|
|
Result := GetItem(ID_NULO)
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TDataModuleAlbaranesCliente._GetDetalles: IBizDetallesAlbaranCliente;
|
|
|
|
|
var
|
|
|
|
|
ADetalles : TDAMemDataTable;
|
|
|
|
|
begin
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
|
|
|
|
ADetalles := CloneDataTable(tbl_AlbaranesCliente_Detalles);
|
|
|
|
|
with ADetalles do
|
|
|
|
|
begin
|
|
|
|
|
BusinessRulesID := BIZ_CLIENT_DETALLES_ALBARAN_CLIENTE;
|
2007-11-13 19:36:56 +00:00
|
|
|
DetailOptions := DetailOptions - [dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates];
|
2007-10-29 19:18:51 +00:00
|
|
|
end;
|
|
|
|
|
Result := (ADetalles as IBizDetallesAlbaranCliente);
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
2009-02-27 10:44:29 +00:00
|
|
|
function TDataModuleAlbaranesCliente.GetAnosItems: TStringList;
|
|
|
|
|
var
|
|
|
|
|
AListaAnos: TStringList;
|
|
|
|
|
begin
|
|
|
|
|
AListaAnos := TStringList.Create;
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
|
|
|
|
with tbl_ListaAnosAlbaranes do
|
|
|
|
|
begin
|
|
|
|
|
Open;
|
|
|
|
|
First;
|
|
|
|
|
while not eof do
|
|
|
|
|
begin
|
|
|
|
|
AListaAnos.Add(Format('%s=%s', [Fields[0].AsString, Fields[0].AsString]));
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
Close;
|
|
|
|
|
end;
|
|
|
|
|
Result := AListaAnos;
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
2007-10-29 19:18:51 +00:00
|
|
|
function TDataModuleAlbaranesCliente.GetEtiquetas(const AID: Integer; withRefCliente: Boolean): Binary;
|
|
|
|
|
begin
|
2008-08-22 14:52:35 +00:00
|
|
|
Result := (RORemoteService as IsrvAlbaranesCliente).GenerarInformeEtiquetas(AID, withRefCliente)
|
2007-10-29 19:18:51 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TDataModuleAlbaranesCliente.GetItem(const ID: Integer): IBizAlbaranCliente;
|
2007-11-14 19:41:42 +00:00
|
|
|
var
|
|
|
|
|
Condicion: TDAWhereExpression;
|
2007-10-29 19:18:51 +00:00
|
|
|
begin
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
|
|
|
|
Result := Self.GetItems;
|
2007-11-14 19:41:42 +00:00
|
|
|
|
|
|
|
|
with Result.DataTable.DynamicWhere do
|
2007-10-29 19:18:51 +00:00
|
|
|
begin
|
2007-11-14 19:41:42 +00:00
|
|
|
// (ID = :ID)
|
|
|
|
|
Condicion := NewBinaryExpression(NewField('', fld_AlbaranesClienteID), NewConstant(ID, datInteger), dboEqual);
|
|
|
|
|
|
|
|
|
|
if IsEmpty then
|
|
|
|
|
Expression := Condicion
|
|
|
|
|
else
|
|
|
|
|
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
|
2007-10-29 19:18:51 +00:00
|
|
|
end;
|
2007-11-14 19:41:42 +00:00
|
|
|
|
2007-10-29 19:18:51 +00:00
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TDataModuleAlbaranesCliente.GetItems: IBizAlbaranCliente;
|
|
|
|
|
var
|
|
|
|
|
AAlbaran : TDAMemDataTable;
|
|
|
|
|
begin
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
|
|
|
|
AAlbaran := CloneDataTable(tbl_AlbaranesCliente);
|
2007-11-14 19:41:42 +00:00
|
|
|
AsignarClaseNegocio(AAlbaran);
|
2007-10-29 19:18:51 +00:00
|
|
|
|
|
|
|
|
// EL CAMPO REFERENCIA TIENE QUE SER AUTOREFRESH!!!!!
|
|
|
|
|
AAlbaran.FieldByName(fld_AlbaranesClienteREFERENCIA).ServerAutoRefresh := TRUE;
|
|
|
|
|
|
|
|
|
|
with TBizAlbaranCliente(AAlbaran.BusinessEventsObj) do
|
|
|
|
|
begin
|
|
|
|
|
Detalles := _GetDetalles;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
Result := (AAlbaran as IBizAlbaranCliente);
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|