git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES2/trunk@79 b2cfbe5a-eba1-4a0c-8b32-7feea0a119f2
387 lines
11 KiB
ObjectPascal
387 lines
11 KiB
ObjectPascal
{
|
|
===============================================================================
|
|
Copyright (©) 2007. Rodax Software.
|
|
===============================================================================
|
|
Los contenidos de este fichero son propiedad de Rodax Software titular del
|
|
copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
|
|
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
|
|
acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
|
|
bajo el que se suministra.
|
|
-----------------------------------------------------------------------------
|
|
Web: www.rodax-software.com
|
|
===============================================================================
|
|
Fecha primera versión:
|
|
Versión actual: 1.0.0
|
|
Fecha versión actual:
|
|
===============================================================================
|
|
Modificaciones:
|
|
|
|
Fecha Comentarios
|
|
---------------------------------------------------------------------------
|
|
===============================================================================
|
|
}
|
|
|
|
unit uDataModuleTiendaWeb;
|
|
|
|
interface
|
|
|
|
uses
|
|
SysUtils, Classes, DB, uDADataTable, uDABINAdapter,
|
|
uDAScriptingProvider, uDACDSDataTable, uROWinInetHttpChannel, uROTypes,
|
|
uRORemoteService, uROClient, uROBinMessage,
|
|
uDADesigntimeCall,
|
|
|
|
uIDataModuleTiendaWeb, uBizTiendaWeb, uBizOscAddressBook, uBizOscCustomers,
|
|
uBizOscManufacturers, uBizOscProducts, uBizOscOrderProducts, uBizOscOrders,
|
|
uDataModuleBase, uDAMemDataTable, uDARemoteDataAdapter, uDADataStreamer,
|
|
uDABin2DataStreamer, uDAInterfaces, uRODynamicRequest;
|
|
|
|
type
|
|
TDataModuleTiendaWeb = class(TDataModuleBase, IDataModuleTiendaWeb)
|
|
RORemoteService: TRORemoteService;
|
|
DADesigntimeCall1: TDADesigntimeCall;
|
|
LoginRemoteService: TRORemoteService;
|
|
ROWinInetHTTPChannel1: TROWinInetHTTPChannel;
|
|
ROBinMessage1: TROBinMessage;
|
|
tbl_osc_AddressBook: TDAMemDataTable;
|
|
ds_osc_AddressBook: TDADataSource;
|
|
tbl_osc_Customers: TDAMemDataTable;
|
|
ds_osc_Customers: TDADataSource;
|
|
tbl_osc_Manufacturers: TDAMemDataTable;
|
|
ds_osc_Manufacturers: TDADataSource;
|
|
tbl_osc_Orders: TDAMemDataTable;
|
|
ds_osc_Orders: TDADataSource;
|
|
tbl_osc_Orders_products: TDAMemDataTable;
|
|
ds_osc_Orders_products: TDADataSource;
|
|
Bin2DataStreamer: TDABin2DataStreamer;
|
|
rda_TiendaWeb: TDARemoteDataAdapter;
|
|
tbl_TiendaWeb: TDAMemDataTable;
|
|
ds_TiendaWeb: TDADataSource;
|
|
tbl_osc_Products: TDAMemDataTable;
|
|
ds_osc_Products: TDADataSource;
|
|
procedure DAClientDataModuleCreate(Sender: TObject);
|
|
protected
|
|
function _GetOSCAddressBook: IBizOscAddressBook;
|
|
function _GetOSCOrderProducts: IBizOSCOrderProducts;
|
|
public
|
|
function GetItems: IBizTiendaWeb;
|
|
function GetItem(const ID_Empresa : Integer) : IBizTiendaWeb;
|
|
function NewItem : IBizTiendaWeb;
|
|
|
|
function GetOSCCustomers: IBizOSCCustomer;
|
|
function GetOSCCustomer(const IDLocal : Integer): IBizOSCCustomer;
|
|
function NewOSCCustomer : IBizOSCCustomer;
|
|
|
|
function GetOSCManufacturers: IBizOSCManufacturer;
|
|
function GetOSCManufacturer(const IDLocal : Integer): IBizOSCManufacturer;
|
|
function NewOSCManufacturer : IBizOSCManufacturer;
|
|
|
|
function GetOSCProducts: IBizOSCProduct;
|
|
function GetOSCProduct(const IDLocal : Integer): IBizOSCProduct;
|
|
function NewOSCProduct : IBizOSCProduct;
|
|
|
|
function GetOSCOrders: IBizOscOrder;
|
|
function GetOSCOrder(const IDLocal : Integer): IBizOscOrder;
|
|
|
|
function HayConexionConTienda : Boolean;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{$R *.DFM}
|
|
|
|
uses
|
|
FactuGES_Intf, uDataModuleConexion, uDataTableUtils, cxControls,
|
|
schTiendaWebClient_Intf;
|
|
|
|
{ TDataModuleTiendaWeb }
|
|
|
|
|
|
// Descomentar si tiene informe
|
|
// function TDataModuleTiendaWeb.GetReport(const AIBizTiendaWebID: Integer): Binary;
|
|
// begin
|
|
// Result := (RORemoteService as IsrvTiendaWeb).GenerateReport(AIBizTiendaWebID)
|
|
// end;
|
|
|
|
procedure TDataModuleTiendaWeb.DAClientDataModuleCreate(Sender: TObject);
|
|
begin
|
|
RORemoteService.Channel := dmConexion.Channel;
|
|
RORemoteService.Message := dmConexion.Message;
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb._GetOSCAddressBook: IBizOscAddressBook;
|
|
var
|
|
AAddressBook : TDAMemDataTable;
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
AAddressBook := CloneDataTable(tbl_osc_AddressBook);
|
|
with AAddressBook do
|
|
begin
|
|
BusinessRulesID := BIZ_CLIENT_OSC_ADDRESSBOOK;
|
|
DetailOptions := DetailOptions -
|
|
[dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates];
|
|
end;
|
|
Result := (AAddressBook as IBizOscAddressBook);
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb._GetOSCOrderProducts: IBizOscOrderProducts;
|
|
var
|
|
AOrderProducts : TDAMemDataTable;
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
AOrderProducts := CloneDataTable(tbl_osc_Orders_products);
|
|
with AOrderProducts do
|
|
begin
|
|
BusinessRulesID := BIZ_CLIENT_OSC_ORDERPRODUCTS;
|
|
DetailOptions := DetailOptions -
|
|
[dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates];
|
|
end;
|
|
Result := (AOrderProducts as IBizOscOrderProducts);
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb.GetItems: IBizTiendaWeb;
|
|
var
|
|
AIBizTiendaWeb : TDAMemDataTable;
|
|
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
AIBizTiendaWeb := CloneDataTable(tbl_TiendaWeb);
|
|
AIBizTiendaWeb.BusinessRulesID := BIZ_CLIENT_TIENDAWEB;
|
|
|
|
Result := (AIBizTiendaWeb as IBizTiendaWeb);
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb.GetItem(const ID_Empresa: Integer): IBizTiendaWeb;
|
|
var
|
|
Condicion: TDAWhereExpression;
|
|
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
Result := Self.GetItems;
|
|
|
|
with Result.DataTable.DynamicWhere do
|
|
begin
|
|
// (ID = :ID)
|
|
Condicion := NewBinaryExpression(NewField('', fld_TiendaWebID_EMPRESA), NewConstant(ID_EMPRESA, datInteger), dboEqual);
|
|
|
|
if IsEmpty then
|
|
Expression := Condicion
|
|
else
|
|
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
|
|
end;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb.NewItem: IBizTiendaWeb;
|
|
begin
|
|
Result := GetItem(ID_NULO)
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb.NewOSCCustomer: IBizOSCCustomer;
|
|
begin
|
|
Result := GetOSCCustomer(ID_NULO)
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb.NewOSCManufacturer: IBizOSCManufacturer;
|
|
begin
|
|
Result := GetOSCManufacturer(ID_NULO)
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb.NewOSCProduct: IBizOSCProduct;
|
|
begin
|
|
Result := GetOSCProduct(ID_NULO)
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb.GetOSCCustomer(const IDLocal: Integer): IBizOSCCustomer;
|
|
var
|
|
Condicion: TDAWhereExpression;
|
|
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
Result := Self.GetOSCCustomers;
|
|
|
|
with Result.DataTable.DynamicWhere do
|
|
begin
|
|
// (ID = :ID)
|
|
Condicion := NewBinaryExpression(NewField('', fld_osc_Customersrdx_customers_id_local), NewConstant(IDLocal, datInteger), dboEqual);
|
|
|
|
if IsEmpty then
|
|
Expression := Condicion
|
|
else
|
|
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
|
|
end;
|
|
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb.GetOSCCustomers: IBizOSCCustomer;
|
|
var
|
|
ACustomer : TDAMemDataTable;
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
ACustomer := CloneDataTable(tbl_osc_Customers);
|
|
ACustomer.BusinessRulesID := BIZ_CLIENT_OSC_CUSTOMER;
|
|
|
|
with TBizOSCCustomer(ACustomer.BusinessEventsObj) do
|
|
begin
|
|
AddressBook := _GetOSCAddressBook;
|
|
end;
|
|
|
|
Result := (ACustomer as IBizOSCCustomer);
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TDataModuleTiendaWeb.GetOSCManufacturer(const IDLocal: Integer): IBizOSCManufacturer;
|
|
var
|
|
Condicion: TDAWhereExpression;
|
|
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
Result := Self.GetOSCManufacturers;
|
|
|
|
with Result.DataTable.DynamicWhere do
|
|
begin
|
|
// (ID = :ID)
|
|
Condicion := NewBinaryExpression(NewField('', fld_osc_Manufacturersrdx_manufacturers_id_local), NewConstant(IDLocal, datInteger), dboEqual);
|
|
|
|
if IsEmpty then
|
|
Expression := Condicion
|
|
else
|
|
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
|
|
end;
|
|
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb.GetOSCManufacturers: IBizOSCManufacturer;
|
|
var
|
|
AManufacturer : TDAMemDataTable;
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
AManufacturer := CloneDataTable(tbl_osc_Manufacturers);
|
|
AManufacturer.BusinessRulesID := BIZ_CLIENT_OSC_MANUFACTURER;
|
|
|
|
Result := (AManufacturer as IBizOSCManufacturer);
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb.GetOSCOrder(const IDLocal: Integer): IBizOscOrder;
|
|
var
|
|
Condicion: TDAWhereExpression;
|
|
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
Result := Self.GetOSCOrders;
|
|
|
|
with Result.DataTable.DynamicWhere do
|
|
begin
|
|
// (ID = :ID)
|
|
Condicion := NewBinaryExpression(NewField('', fld_osc_Ordersorders_id), NewConstant(IDLocal, datInteger), dboEqual);
|
|
|
|
if IsEmpty then
|
|
Expression := Condicion
|
|
else
|
|
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
|
|
end;
|
|
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb.GetOSCOrders: IBizOscOrder;
|
|
var
|
|
AOrder : TDAMemDataTable;
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
AOrder := CloneDataTable(tbl_osc_Orders);
|
|
AOrder.BusinessRulesID := BIZ_CLIENT_OSC_ORDER;
|
|
|
|
with TBizOscOrder(AOrder.BusinessEventsObj) do
|
|
begin
|
|
OrderProducts := _GetOSCOrderProducts;
|
|
end;
|
|
|
|
Result := (AOrder as IBizOscOrder);
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb.GetOSCProduct(const IDLocal: Integer): IBizOSCProduct;
|
|
var
|
|
Condicion: TDAWhereExpression;
|
|
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
Result := Self.GetOSCProducts;
|
|
|
|
with Result.DataTable.DynamicWhere do
|
|
begin
|
|
// (ID = :ID)
|
|
Condicion := NewBinaryExpression(NewField('', fld_osc_Productsrdx_products_id_local), NewConstant(IDLocal, datInteger), dboEqual);
|
|
|
|
if IsEmpty then
|
|
Expression := Condicion
|
|
else
|
|
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
|
|
end;
|
|
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb.GetOSCProducts: IBizOSCProduct;
|
|
var
|
|
AProduct : TDAMemDataTable;
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
AProduct := CloneDataTable(tbl_osc_Products);
|
|
AProduct.BusinessRulesID := BIZ_CLIENT_OSC_PRODUCT;
|
|
|
|
Result := (AProduct as IBizOSCProduct);
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
function TDataModuleTiendaWeb.HayConexionConTienda: Boolean;
|
|
begin
|
|
Result := (RORemoteService as IsrvTiendaWeb).HayConexionConTienda;
|
|
end;
|
|
|
|
end.
|