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/Tienda web/Model/uBizOscCustomerServer.pas
2010-09-23 14:09:01 +00:00

117 lines
3.4 KiB
ObjectPascal

unit uBizOscCustomerServer;
interface
uses
uDAInterfaces, uDADelta, uDABusinessProcessor,
SysUtils, schTiendaWebServer_Intf,
uDADataTable, uBusinessUtils;
const
BIZ_SERVER_OSC_CUSTOMER = 'Server.OSC.Customer';
type
TBizOscCustomerServer = class(Tosc_CustomersBusinessProcessorRules)
protected
procedure Insert_Customers_Info(aChange: TDADeltaChange);
procedure Update_Customers_Info(aChange: TDADeltaChange);
procedure Delete_Customers_Info(aChange: TDADeltaChange);
procedure AfterProcessChange(Sender: TDABusinessProcessor;
aChange: TDADeltaChange; Processed: Boolean;
var CanRemoveFromDelta: Boolean); override;
procedure ProcessError(Sender: TDABusinessProcessor;
aChangeType: TDAChangeType; aChange: TDADeltaChange;
const aCommand: IDASQLCommand; var CanRemoveFromDelta: Boolean;
Error: Exception); override;
end;
implementation
uses
Dialogs, Variants, uDataModuleServer, uDAClasses, DARemoteService_Impl,
schTiendaWebClient_Intf, uROClasses, srvTiendaWeb_Impl, Windows, uServerMainForm;
{ TBizOscCustomerServer }
procedure TBizOscCustomerServer.AfterProcessChange(Sender: TDABusinessProcessor;
aChange: TDADeltaChange; Processed: Boolean; var CanRemoveFromDelta: Boolean);
begin
inherited;
case aChange.ChangeType of
ctInsert: Insert_Customers_Info(aChange);
ctUpdate: Update_Customers_Info(aChange);
ctDelete: Delete_Customers_Info(aChange);
end;
CanRemoveFromDelta := False;
end;
procedure TBizOscCustomerServer.Delete_Customers_Info(aChange: TDADeltaChange);
var
ASchema : TDASchema;
ACurrentConn : IDAConnection;
ACommand : IDASQLCommand;
begin
ASchema := BusinessProcessor.Schema;
ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);
ACommand := ASchema.NewCommand(ACurrentConn, 'Delete_Customers_info');
try
with ACommand do
begin
ParamByName('OLD_customers_info_id').Value := aChange.OldValueByName[fld_osc_Customerscustomers_id];
Execute;
end;
finally
ACommand := NIL;
end;
end;
procedure TBizOscCustomerServer.Insert_Customers_Info(aChange: TDADeltaChange);
var
ASchema : TDASchema;
ACurrentConn : IDAConnection;
ACommand : IDASQLCommand;
begin
ASchema := BusinessProcessor.Schema;
ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);
ACommand := ASchema.NewCommand(ACurrentConn, 'Insert_Customers_info');
try
with ACommand do
begin
ParamByName('customers_info_id').Value := aChange.NewValueByName[fld_osc_Customerscustomers_id];
ParamByName('rdx_customers_info_id_local').Value := aChange.NewValueByName[fld_osc_Customersrdx_customers_id_local];
Execute;
end;
finally
ACommand := NIL;
end;
end;
procedure TBizOscCustomerServer.ProcessError(Sender: TDABusinessProcessor;
aChangeType: TDAChangeType; aChange: TDADeltaChange;
const aCommand: IDASQLCommand; var CanRemoveFromDelta: Boolean;
Error: Exception);
begin
inherited;
//IMPORTANTE ESTO HACE QUE EL CLIENTE SE ENTERE DEL ERROR Y LOS BP ASOCIADOS EN EL
//SCHEMA HAGAN ROLLBACK TAMBIEN
CanRemoveFromDelta := True;
raise Exception.Create(Error.Message);
end;
procedure TBizOscCustomerServer.Update_Customers_Info(aChange: TDADeltaChange);
begin
// NO HACE FALTA HACER NADA
end;
initialization
RegisterBusinessProcessorRules(BIZ_SERVER_OSC_CUSTOMER, TBizOscCustomerServer);
end.