78 lines
2.3 KiB
ObjectPascal
78 lines
2.3 KiB
ObjectPascal
unit uBizRemesasClienteServer;
|
|
|
|
interface
|
|
|
|
uses
|
|
uDAInterfaces, uDADelta, uDABusinessProcessor,
|
|
schRemesasClienteServer_Intf;
|
|
|
|
const
|
|
BIZ_SERVER_REMESAS_CLIENTE = 'Server.RemesasCliente';
|
|
REF_REMESAS_CLIENTE = 'REF_REMESAS_CLIENTE';
|
|
|
|
type
|
|
TBizRemesasClienteServer = class(TRemesasClienteBusinessProcessorRules)
|
|
protected
|
|
procedure BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); override;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
|
schRemesasClienteClient_Intf;
|
|
|
|
|
|
{ TBizRemesasClienteServer }
|
|
|
|
procedure TBizRemesasClienteServer.BeforeProcessDelta(
|
|
Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
|
var
|
|
ASchema : TDASchema;
|
|
ACurrentConn : IDAConnection;
|
|
dsData: IDADataset;
|
|
Empresa : Variant;
|
|
|
|
begin
|
|
inherited;
|
|
case Sender.CurrentChange.ChangeType of
|
|
ctInsert, ctUpdate: begin
|
|
//Si la referencia no ha sido asignada le asignamos una nosotros
|
|
if (VarIsNull(Sender.CurrentChange.NewValueByName[fld_RemesasClienteREFERENCIA]))
|
|
or (VarToStr(Sender.CurrentChange.NewValueByName[fld_RemesasClienteREFERENCIA]) = '') then
|
|
begin
|
|
ASchema := BusinessProcessor.Schema;
|
|
ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);
|
|
|
|
try
|
|
//Siempre va a estar rellena
|
|
Empresa := Sender.CurrentChange.NewValueByName[fld_RemesasClienteID_EMPRESA];
|
|
|
|
dsData := ASchema.NewDataset(ACurrentConn, 'DarReferencia', ['CODIGO', 'EMPRESA'], [REF_REMESAS_CLIENTE, Empresa]);
|
|
except
|
|
RaiseError('No existe la tabla REFERENCIAS');
|
|
end;
|
|
|
|
dsData.Active := True;
|
|
|
|
if dsData.IsEmpty then
|
|
RaiseError('NO HAY REFERENCIA ' + REF_REMESAS_CLIENTE + ' DECLARADA EN TABLA REFERENCIAS');
|
|
|
|
REFERENCIA := dsData.FieldByName('VALOR').AsString;
|
|
|
|
try
|
|
ASchema.NewCommand(ACurrentConn, 'ModificarReferencia', ['CODIGO', 'VALOR', 'ID_EMPRESA'], [REF_Remesas_CLIENTE, DarReferenciaSiguiente(REFERENCIA), Empresa]);
|
|
except
|
|
RaiseError('Error al asignar la nueva ' + REFERENCIA + ' referencia en tabla');
|
|
end;
|
|
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
initialization
|
|
RegisterBusinessProcessorRules(BIZ_SERVER_REMESAS_CLIENTE, TBizRemesasClienteServer);
|
|
|
|
end.
|