unit uBizOscAddressBookServer;

interface

uses
  schTiendaWebServer_Intf, uDAInterfaces,
  uDADataTable, uDABusinessProcessor, uBusinessUtils;

const
  BIZ_SERVER_OSC_ADDRESSBOOK = 'Server.OSC.AddressBook';

type
  TBizOscAddressBookServer = class(Tosc_CustomersBusinessProcessorRules)

  protected
    procedure AfterProcessChange(Sender: TDABusinessProcessor;
      aChange: TDADeltaChange; Processed: Boolean;
      var CanRemoveFromDelta: Boolean); override;

          
  end;

implementation

uses
  Dialogs, SysUtils, Variants, uDataModuleServer, uDAClasses, DARemoteService_Impl,
  schTiendaWebClient_Intf, uROClasses;

{ TBizOscAddressBookServer }

procedure TBizOscAddressBookServer.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_AddressBookaddress_book_id] := ADataSet.FieldByName('last_id').AsInteger;
              end;
  end;

  CanRemoveFromDelta := False;
end;

initialization
  RegisterBusinessProcessorRules(BIZ_SERVER_OSC_ADDRESSBOOK, TBizOscAddressBookServer);

end.
