This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
LuisLeon_FactuGES2/Source/Modulos/Informe ventas por articulo/Data/uDataModuleInfVentasArticulo.pas

128 lines
4.0 KiB
ObjectPascal

unit uDataModuleInfVentasArticulo;
interface
uses {vcl:} SysUtils, Classes, DB, DBClient,
{RemObjects:} uDADataTable, uRORemoteService, uROClient, uROBinMessage,
uROWinInetHttpChannel, uDAScriptingProvider, uDACDSDataTable,
uBizInfVentasArticulo, uIDataModuleInfVentasArticulo, uDADesigntimeCall,
uDataModuleBase, uDARemoteDataAdapter, uDADataStreamer, uDABin2DataStreamer,
uDAMemDataTable, uRODynamicRequest;
//uBizControlVentasTerminadas,
//const
// CATEGORIA_VENTA_TERMINADA = 'VENTATERMINADA';
type
TdmInfVentasArticulo = class(TDataModuleBase, IDataModuleInfVentasArticulo)
RORemoteService: TRORemoteService;
DADesigntimeCall1: TDADesigntimeCall;
LoginRemoteService: TRORemoteService;
ROWinInetHTTPChannel1: TROWinInetHTTPChannel;
ROBinMessage1: TROBinMessage;
Bin2DataStreamer: TDABin2DataStreamer;
rda_InfVentasArticulo: TDARemoteDataAdapter;
rda_TablaVacia: TDARemoteDataAdapter;
tbl_TablaVacia: TDAMemDataTable;
tbl_InfVentasArticulo: TDAMemDataTable;
procedure DAClientDataModuleCreate(Sender: TObject);
private
procedure InitRDA(var aDataTable: TDAMemDataTable; const AWhere: String; aIncludeSchema: Boolean; AMaxRecords: integer);
public
function GetItems(const AColumns: String; const AWhere: String) : IBizInfVentasArticulo;
function GetNameColumns: String;
end;
var
dmInfVentasArticulo: TdmInfVentasArticulo;
implementation
{$R *.DFM}
uses
Controls, Forms, uDAInterfaces, uDataTableUtils,
uROTypes, Dialogs, uDataModuleConexion,
cxControls, uDMBASE, uFactuGES_App,
schInfVentasArticuloClient_Intf; //DataAbstract_Intf,, uEditorPreview, uDataModuleControles, uDBSelectionList,
const
CAMPOS_AVG = '#IMPORTE_NETO_VENTA#';
CAMPOS_SUMA = '#IMPORTE_TOTAL_FACTURA#IMPORTE_UNIDAD_COSTE#IMPORTE_NETO_COSTE#IMPORTE_PORTE_COSTE#CANTIDAD#IMPORTE_UNIDAD_VENTA#IMPORTE_PORTE_VENTA#IMPORTE_TOTAL_VENTA#IMPORTE_COMISION_AGENTE#';
procedure TdmInfVentasArticulo.DAClientDataModuleCreate(Sender: TObject);
begin
RORemoteService.Channel := dmConexion.Channel;
RORemoteService.Message := dmConexion.Message;
end;
function TdmInfVentasArticulo.GetItems(const AColumns: String; const AWhere: String): IBizInfVentasArticulo;
var
AInfVentasArticulo : TDAMemDataTable;
begin
ShowHourglassCursor;
try
AInfVentasArticulo := CloneDataTable(tbl_TablaVacia);
AInfVentasArticulo.BusinessRulesID := BIZ_InfVentasArticulo;
(AInfVentasArticulo as IBizInfVentasArticulo).VisibleColumns := AColumns;
InitRDA(AInfVentasArticulo, Awhere, True, 0);
AInfVentasArticulo.Close;
Result := (AInfVentasArticulo as IBizInfVentasArticulo);
finally
HideHourglassCursor;
end;
end;
function TdmInfVentasArticulo.GetNameColumns: String;
var
AList : TStringList;
i : integer;
begin
AList := TStringList.Create;
try
for i := 0 to tbl_InfVentasArticulo.FieldCount - 1 do
if tbl_InfVentasArticulo.Fields[i].Visible then
AList.Add(tbl_InfVentasArticulo.Fields[i].Name);
Result := AList.CommaText;
finally
FreeAndNil(AList);
end;
end;
procedure TdmInfVentasArticulo.InitRDA(var aDataTable: TDAMemDataTable; const AWhere: String;
aIncludeSchema: Boolean; AMaxRecords: integer);
var
ASql: String;
begin
with tbl_TablaVacia do begin
Close;
with TReplicarDataSet.Create do
begin
FROM_SQL := 'FROM V_INF_VENTAS_ARTICULOS ' + 'where (' + fld_InfVentasArticuloID_EMPRESA + ' = ' + IntToStr(AppFactuGES.EmpresaActiva.ID) + ') and ' + AWhere ;
Columnas := (aDataTable as IBizInfVentasArticulo).VisibleColumns;
ColumnasQueSuman := CAMPOS_SUMA;
ColumnasQueAVG := CAMPOS_AVG;
try
ASql := GenerateNewSQL;
dmBase.EscribirLog(ASql);
finally
Free;
end;
end;
rda_TablaVacia.GetDataCall.ParamByName('aSQLText').AsString := ASql;
MaxRecords := AMaxRecords;
rda_TablaVacia.Fill([tbl_TablaVacia], true, aIncludeSchema);
end;
end;
end.