unit uBizProveedoresServer;

interface

uses
  schContactosServer_Intf, uDAInterfaces,
  uDADataTable, uDABusinessProcessor, uBizContactosServer;

const
  BIZ_SERVER_PROVEEDOR = 'Server.Proveedor';

type
  TBizProveedorServer = 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, DARemoteService_Impl,
  schContactosClient_Intf, uBusinessUtils;

{ TBizProveedorServer }

procedure TBizProveedorServer.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_ProveedoresDatos');
  try
    with ACommand do
    begin
      ParamByName('OLD_ID_PROVEEDOR').Value := aChange.OldValueByName[fld_ProveedoresID];
      Execute;
    end;
  finally
    ACommand := NIL;
  end;
end;

procedure TBizProveedorServer.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_ProveedoresDatos');
  try
    with ACommand do
    begin
      ParamByName('ID_PROVEEDOR').Value := aChange.NewValueByName[fld_ProveedoresID];
      ParamByName('DESCUENTO').Value := aChange.NewValueByName[fld_ProveedoresDESCUENTO];
      ParamByName('REGIMEN_IVA').Value := aChange.NewValueByName[fld_ProveedoresREGIMEN_IVA];
      ParamByName('ID_TIPO_IVA').Value := aChange.NewValueByName[fld_ProveedoresID_TIPO_IVA];
      ParamByName('ID_FORMA_PAGO').Value := aChange.NewValueByName[fld_ProveedoresID_FORMA_PAGO];
      ParamByName('TIENDA_WEB').Value := aChange.NewValueByName[fld_ProveedoresTIENDA_WEB];      
      Execute;
    end;
  finally
    ACommand := NIL;
  end;
end;


procedure TBizProveedorServer.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_ProveedoresDatos');
  try
    with ACommand do
    begin
      ParamByName('OLD_ID_PROVEEDOR').Value := aChange.OldValueByName[fld_ProveedoresID];
      ParamByName('ID_PROVEEDOR').Value := aChange.NewValueByName[fld_ProveedoresID];
      ParamByName('DESCUENTO').Value := aChange.NewValueByName[fld_ProveedoresDESCUENTO];
      ParamByName('REGIMEN_IVA').Value := aChange.NewValueByName[fld_ProveedoresREGIMEN_IVA];
      ParamByName('ID_TIPO_IVA').Value := aChange.NewValueByName[fld_ProveedoresID_TIPO_IVA];
      ParamByName('ID_FORMA_PAGO').Value := aChange.NewValueByName[fld_ProveedoresID_FORMA_PAGO];
      ParamByName('TIENDA_WEB').Value := aChange.NewValueByName[fld_ProveedoresTIENDA_WEB];      
      Execute;
    end;
  finally
    ACommand := NIL;
  end;
end;

initialization
  RegisterBusinessProcessorRules(BIZ_SERVER_PROVEEDOR, TBizProveedorServer);

end.
