unit uBizVendedoresServer;

interface

uses
  schContactosServer_Intf, uDAInterfaces, uDADelta,
  uDADataTable, uDABusinessProcessor, uBizContactosServer;

const
  BIZ_SERVER_VENDEDOR = 'Server.Vendedor';

type
  TBizVendedorServer = class(TBizContactosServer)
  protected
    procedure Insert_Datos_Contacto(aChange: TDADeltaChange); override;
    procedure Update_Datos_Contacto(aChange: TDADeltaChange); override;
    procedure Delete_Datos_Contacto(aChange: TDADeltaChange); override;
  end;

implementation

uses
  uDataModuleServer, uDAClasses,
  schContactosClient_Intf, uBusinessUtils;

{ TBizVendedorServer }

procedure TBizVendedorServer.Delete_Datos_Contacto(aChange: TDADeltaChange);
var
  ASchema : TDASchema;
  ACurrentConn : IDAConnection;
  ACommand : IDASQLCommand;
begin
  inherited;

  ASchema := BusinessProcessor.Schema;
  ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);

  ACommand := ASchema.NewCommand(ACurrentConn, 'Delete_VendedoresDatos');
  try
    with ACommand do
    begin
      ParamByName('OLD_ID_VENDEDOR').Value := aChange.OldValueByName[fld_VendedoresID];
      Execute;
    end;
  finally
    ACommand := NIL;
  end;
end;

procedure TBizVendedorServer.Insert_Datos_Contacto(aChange: TDADeltaChange);
var
  ASchema : TDASchema;
  ACurrentConn : IDAConnection;
  ACommand : IDASQLCommand;
begin
  inherited;

  ASchema := BusinessProcessor.Schema;
  ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);

  ACommand := ASchema.NewCommand(ACurrentConn, 'Insert_VendedoresDatos');
  try
    with ACommand do
    begin
      ParamByName('ID_VENDEDOR').Value := aChange.NewValueByName[fld_VendedoresID];
      ParamByName('ID_USUARIO').Value := aChange.NewValueByName[fld_VendedoresID_USUARIO];
      ParamByName('COMISION').Value := aChange.NewValueByName[fld_VendedoresCOMISION];
      Execute;
    end;
  finally
    ACommand := NIL;
  end;
end;

procedure TBizVendedorServer.Update_Datos_Contacto(aChange: TDADeltaChange);
var
  ASchema : TDASchema;
  ACurrentConn : IDAConnection;
  ACommand : IDASQLCommand;
begin
  inherited;

  ASchema := BusinessProcessor.Schema;
  ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);

  ACommand := ASchema.NewCommand(ACurrentConn, 'Update_VendedoresDatos');
  try
    with ACommand do
    begin
      ParamByName('OLD_ID_VENDEDOR').Value := aChange.OldValueByName[fld_VendedoresID];
      ParamByName('ID_USUARIO').Value := aChange.NewValueByName[fld_VendedoresID_USUARIO];
      ParamByName('COMISION').Value := aChange.NewValueByName[fld_VendedoresCOMISION];
      Execute;
    end;
  finally
    ACommand := NIL;
  end;
end;

initialization
  RegisterBusinessProcessorRules(BIZ_SERVER_VENDEDOR, TBizVendedorServer);

end.
