2013-12-02 18:23:44 +00:00
|
|
|
unit uDataModuleFacturasProforma;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
SysUtils, Classes, DB, uDADataTable, uDABINAdapter,
|
|
|
|
|
uDAScriptingProvider, uDACDSDataTable, uROWinInetHttpChannel, uROTypes,
|
|
|
|
|
uRORemoteService, uROClient, uROBinMessage,
|
|
|
|
|
|
|
|
|
|
uIDataModuleFacturasProforma, uBizFacturasProforma, uBizDetallesFacturaProforma,
|
|
|
|
|
uDADesigntimeCall, uDataModuleBase, uDAInterfaces, uDAMemDataTable,
|
|
|
|
|
uDADataStreamer, uDABin2DataStreamer, uDARemoteDataAdapter, uIntegerListUtils,
|
|
|
|
|
uIDataModuleFacturasProformaReport;
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
TDataModuleFacturasProforma = class(TDataModuleBase, IDataModuleFacturasProforma, IDataModuleFacturasProformaReport)
|
|
|
|
|
RORemoteService: TRORemoteService;
|
|
|
|
|
rda_FacturasProforma: TDARemoteDataAdapter;
|
|
|
|
|
Bin2DataStreamer: TDABin2DataStreamer;
|
|
|
|
|
tbl_FacturasProforma: TDAMemDataTable;
|
|
|
|
|
ds_FacturasProforma: TDADataSource;
|
|
|
|
|
tbl_FacturasProforma_Detalles: TDAMemDataTable;
|
|
|
|
|
ds_FacturasProforma_Detalles: TDADataSource;
|
|
|
|
|
tbl_ListaAnosFacturas: TDAMemDataTable;
|
|
|
|
|
ds_ListaAnosFacturas: TDADataSource;
|
|
|
|
|
procedure DAClientDataModuleCreate(Sender: TObject);
|
|
|
|
|
private
|
|
|
|
|
function _GetDetalles : IBizDetallesFacturaProforma;
|
|
|
|
|
public
|
|
|
|
|
function GetAnosItems : TStringList;
|
|
|
|
|
function GetItems : IBizFacturaProforma;
|
|
|
|
|
function GetItem(const ID : Integer) : IBizFacturaProforma;
|
|
|
|
|
function NewItem : IBizFacturaProforma;
|
|
|
|
|
|
|
|
|
|
// Report
|
|
|
|
|
function GetRptFacturas(const AListaID: TIntegerList): Binary;
|
|
|
|
|
function GetRptPDFFactura(const AID: Integer): Binary;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
{$R *.DFM}
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
FactuGES_Intf, uDataModuleConexion, uDataTableUtils, cxControls,
|
|
|
|
|
schFacturasProformaClient_Intf, uBizContactos, Dialogs;
|
|
|
|
|
|
|
|
|
|
{ TdmPresupuestos }
|
|
|
|
|
|
|
|
|
|
procedure TDataModuleFacturasProforma.DAClientDataModuleCreate(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
RORemoteService.Channel := dmConexion.Channel;
|
|
|
|
|
RORemoteService.Message := dmConexion.Message;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TDataModuleFacturasProforma.GetRptFacturas(const AListaID: TIntegerList): Binary;
|
|
|
|
|
var
|
|
|
|
|
AParam : TIntegerArray;
|
|
|
|
|
begin
|
|
|
|
|
AParam := AListaID.ToIntegerArray;
|
|
|
|
|
try
|
2013-12-12 17:42:50 +00:00
|
|
|
Result := (RORemoteService as IsrvFacturasProforma).GenerarInforme(AParam);
|
2013-12-02 18:23:44 +00:00
|
|
|
finally
|
|
|
|
|
FreeANDNIL(AParam);
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TDataModuleFacturasProforma.GetRptPDFFactura(const AID: Integer): Binary;
|
|
|
|
|
var
|
|
|
|
|
AParam : TIntegerArray;
|
|
|
|
|
begin
|
|
|
|
|
AParam := TIntegerArray.Create;
|
|
|
|
|
try
|
|
|
|
|
AParam.Add(AID);
|
2013-12-12 17:42:50 +00:00
|
|
|
Result := (RORemoteService as IsrvFacturasProforma).GenerarInformeEnPDF(AParam);
|
2013-12-02 18:23:44 +00:00
|
|
|
finally
|
|
|
|
|
FreeANDNIL(AParam);
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TDataModuleFacturasProforma.NewItem: IBizFacturaProforma;
|
|
|
|
|
begin
|
|
|
|
|
Result := GetItem(ID_NULO)
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TDataModuleFacturasProforma._GetDetalles: IBizDetallesFacturaProforma;
|
|
|
|
|
var
|
|
|
|
|
ADetalles : TDAMemDataTable;
|
|
|
|
|
begin
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
|
|
|
|
ADetalles := CloneDataTable(tbl_FacturasProforma_Detalles);
|
|
|
|
|
with ADetalles do
|
|
|
|
|
begin
|
|
|
|
|
BusinessRulesID := BIZ_CLIENT_DETALLES_FACTURA_PROFORMA;
|
|
|
|
|
DetailOptions := DetailOptions - [dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates];
|
|
|
|
|
end;
|
|
|
|
|
Result := (ADetalles as IBizDetallesFacturaProforma);
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TDataModuleFacturasProforma.GetItem(const ID: Integer): IBizFacturaProforma;
|
|
|
|
|
var
|
|
|
|
|
Condicion: TDAWhereExpression;
|
|
|
|
|
begin
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
|
|
|
|
Result := Self.GetItems;
|
|
|
|
|
|
|
|
|
|
with Result.DataTable.DynamicWhere do
|
|
|
|
|
begin
|
|
|
|
|
// (ID = :ID)
|
|
|
|
|
Condicion := NewBinaryExpression(NewField('', fld_FacturasProformaID), NewConstant(ID, datInteger), dboEqual);
|
|
|
|
|
|
|
|
|
|
if IsEmpty then
|
|
|
|
|
Expression := Condicion
|
|
|
|
|
else
|
|
|
|
|
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TDataModuleFacturasProforma.GetAnosItems: TStringList;
|
|
|
|
|
var
|
|
|
|
|
AListaAnos: TStringList;
|
|
|
|
|
begin
|
|
|
|
|
AListaAnos := TStringList.Create;
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
|
|
|
|
with tbl_ListaAnosFacturas 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;
|
|
|
|
|
|
|
|
|
|
function TDataModuleFacturasProforma.GetItems: IBizFacturaProforma;
|
|
|
|
|
var
|
|
|
|
|
AFactura : TDAMemDataTable;
|
|
|
|
|
begin
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
try
|
|
|
|
|
AFactura := CloneDataTable(tbl_FacturasProforma);
|
|
|
|
|
|
|
|
|
|
// EL CAMPO REFERENCIA TIENE QUE SER AUTOREFRESH!!!!!
|
|
|
|
|
AFactura.FieldByName(fld_FacturasProformaREFERENCIA).ServerAutoRefresh := TRUE;
|
|
|
|
|
|
|
|
|
|
AFactura.BusinessRulesID := BIZ_CLIENT_FACTURA_PROFORMA;
|
|
|
|
|
|
|
|
|
|
with TBizFacturaProforma(AFactura.BusinessEventsObj) do
|
|
|
|
|
begin
|
|
|
|
|
Detalles := _GetDetalles;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
Result := (AFactura as IBizFacturaProforma);
|
|
|
|
|
finally
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|