unit srvInfVentasArticulo_Impl;

{----------------------------------------------------------------------------}
{ This unit was automatically generated by the RemObjects SDK after reading  }
{ the RODL file associated with this project .                               }
{                                                                            }
{ This is where you are supposed to code the implementation of your objects. }
{----------------------------------------------------------------------------}

interface

uses
  {vcl:} Classes, SysUtils,
  {RemObjects:} uROClientIntf, uROTypes, uROServer, uROServerIntf, uROSessions,
  {Ancestor Implementation:} DARemoteService_Impl,
  {Used RODLs:} DataAbstract_Intf,
  {Generated:} FactuGES_Intf, uDAClasses,
  uDataModuleServer, uDAInterfaces, uDADataTable, uDABINAdapter;

type
  { TsrvInfVentasArticulo }
  TsrvInfVentasArticulo = class(TDARemoteService, IsrvInfVentasArticulo)
    DABINAdapter: TDABINAdapter;
    schInfVentasArticulo: TDASchema;
    DataDictionary: TDADataDictionary;
  private
  protected
    { IsrvInfVentasArticulo methods }
    function GetData(const DatasetName: String; const MaxRecords: Integer; const Columns: String; const Params: TDADatasetParamArray): Binary;
    function GetSchema(const DatasetName: String; const Columns: String): Binary;
  end;

implementation

{$R *.dfm}
uses
  {Generated:} FactuGES_Invk, uSchemaUtilsServer, dialogs;

const
  CAMPOS_SUMA = '#IMPORTE_TOTAL_FACTURA#IMPORTE_UNIDAD_COSTE#IMPORTE_NETO_COSTE#IMPORTE_PORTE_COSTE#CANTIDAD#IMPORTE_UNIDAD_VENTA#IMPORTE_NETO_VENTA#IMPORTE_PORTE_VENTA#IMPORTE_TOTAL_VENTA#IMPORTE_COMISION_AGENTE#';

  
procedure Create_srv_InfVentasArticulo(out anInstance : IUnknown);
begin
  anInstance := TsrvInfVentasArticulo.Create(NIL);
end;

{ srvInfVentasArticulo }

function TsrvInfVentasArticulo.GetData(const DatasetName: String;
  const MaxRecords: Integer; const Columns: String;
  const Params: TDADatasetParamArray): TROBinaryMemoryStream;
var
  ds : IDADataset;
  i : integer;
begin
  result := Binary.Create;
  try
    { Prepares the parameter arrays}

    with TReplicarDataSet.Create do
    begin
      SourceDataSetName := DatasetName;
      Service := Self;
      Columnas := Columns;
      ColumnasQueSuman := CAMPOS_SUMA;
      try
        ds := GetNewDataSet;
      finally
        Free;
      end;
    end;

    for i := 0 to (Params.Count-1) do
      ds.ParamByName(Params[i].Name).Value := Params[i].Value;

    ds.Open;
    ServiceAdapter.WriteDataset(Result, ds, [woRows], MaxRecords);
  except
    FreeAndNIl(result);
    raise;
  end;
end;

function TsrvInfVentasArticulo.GetSchema(const DatasetName: String; const Columns: String): TROBinaryMemoryStream;
var
  ds : IDADataset;
begin
  result := Binary.Create;
  try
    with TReplicarDataSet.Create do
    begin
      SourceDataSetName := DatasetName;
      Service := Self;
      Columnas := Columns;
      ColumnasQueSuman := CAMPOS_SUMA;
      try
        ds := GetNewDataSet;
      finally
        Free;
      end;
    end;
    ServiceAdapter.WriteDataset(result, ds, [woSchema]);
  except
    FreeAndNIl(result);
    raise;
  end;
end;


initialization
  TROClassFactory.Create('srvInfVentasArticulo', Create_srv_InfVentasArticulo, TsrvInfVentasArticulo_Invoker);

finalization

end.
