git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES2/trunk@4 f4e31baf-9722-1c47-927c-6f952f962d4b
77 lines
2.5 KiB
ObjectPascal
77 lines
2.5 KiB
ObjectPascal
unit uBizPresupuestosClienteServer;
|
|
|
|
interface
|
|
|
|
uses
|
|
uDAInterfaces, uDADelta, uDABusinessProcessor,
|
|
schPresupuestosClienteServer_Intf;
|
|
|
|
const
|
|
BIZ_SERVER_PRESUPUESTOS_CLIENTE = 'Server.PresupuestosCliente';
|
|
REF_PRESUPUESTOS_CLIENTE = 'REF_PRESUPUESTOS_CLIENTE';
|
|
|
|
type
|
|
TBizPresupuestosClienteServer = class(TPresupuestosClienteBusinessProcessorRules)
|
|
protected
|
|
procedure BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); override;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
|
schPresupuestosClienteClient_Intf;
|
|
|
|
{ TBizPresupuestosClienteServer }
|
|
|
|
procedure TBizPresupuestosClienteServer.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_PresupuestosClienteREFERENCIA]))
|
|
or (VarToStr(Sender.CurrentChange.NewValueByName[fld_PresupuestosClienteREFERENCIA]) = '') then
|
|
begin
|
|
ASchema := BusinessProcessor.Schema;
|
|
ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);
|
|
|
|
try
|
|
//Siempre va a estar rellena
|
|
Empresa := Sender.CurrentChange.NewValueByName[fld_PresupuestosClienteID_EMPRESA];
|
|
dsData := ASchema.NewDataset(ACurrentConn, 'DarReferencia', ['CODIGO', 'EMPRESA'], [REF_PRESUPUESTOS_CLIENTE, Empresa]);
|
|
except
|
|
RaiseError('No existe la tabla REFERENCIAS');
|
|
end;
|
|
|
|
dsData.Active := True;
|
|
|
|
if dsData.IsEmpty then
|
|
RaiseError('NO HAY REFERENCIA ' + REF_PRESUPUESTOS_CLIENTE + ' DECLARADA EN TABLA REFERENCIAS');
|
|
|
|
REFERENCIA := dsData.FieldByName(fld_DarReferenciaVALOR).AsString;
|
|
|
|
try
|
|
ASchema.NewCommand(ACurrentConn, 'ModificarReferencia', ['CODIGO', 'VALOR', 'EMPRESA'], [REF_PRESUPUESTOS_CLIENTE, DarReferenciaSiguiente(REFERENCIA), Empresa]);
|
|
except
|
|
RaiseError('Error al asignar la nueva ' + REFERENCIA + ' referencia en tabla');
|
|
end;
|
|
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
initialization
|
|
RegisterBusinessProcessorRules(BIZ_SERVER_PRESUPUESTOS_CLIENTE, TBizPresupuestosClienteServer);
|
|
|
|
end.
|