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_FactuGES/Source/Modulos/Tienda web/Model/uBizOscCustomerServer.pas
david 344ba18b08 Tienda web:
- poder indicar individualmente qué artículos están en la tienda o no
 - arreglado el problema con ñ y tildes al volcar información a MySQL.

git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES/trunk@247 c93665c3-c93d-084d-9b98-7d5f4a9c3376
2008-06-16 16:43:21 +00:00

139 lines
4.3 KiB
ObjectPascal

unit uBizOscCustomerServer;
interface
uses
SysUtils, schTiendaWebServer_Intf, uDAInterfaces,
uDADataTable, uDABusinessProcessor, 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;
procedure GenerateSQL(Sender: TDABusinessProcessor;
ChangeType: TDAChangeType; const ReferencedStatement: TDAStatement;
const aDelta: IDADelta; var SQL: string); 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);
var
ASchema : TDASchema;
ACurrentConn : IDAConnection;
ADataset : IDADataset;
begin
ASchema := Sender.Schema;
ACurrentConn := GetBusinessProcessorConnection(Sender);
inherited;
case aChange.ChangeType of
ctInsert: begin
ADataSet := ASchema.NewDataset(ACurrentConn, 'GetLastID', [], [], True);
aChange.NewValueByName[fld_osc_Customerscustomers_id] := ADataSet.FieldByName('last_id').AsInteger;
Insert_Customers_Info(aChange);
end;
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.GenerateSQL(Sender: TDABusinessProcessor;
ChangeType: TDAChangeType; const ReferencedStatement: TDAStatement;
const aDelta: IDADelta; var SQL: string);
begin
inherited;
fServerForm.Memo1.Lines.Add(SQL);
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.