git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES2/trunk@148 f4e31baf-9722-1c47-927c-6f952f962d4b
This commit is contained in:
parent
b9812693f3
commit
04e6004730
@ -0,0 +1,104 @@
|
|||||||
|
unit uBizRecibosClienteServer;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
uDAInterfaces, uDADelta, uDABusinessProcessor,
|
||||||
|
schRecibosClienteServer_Intf;
|
||||||
|
|
||||||
|
const
|
||||||
|
BIZ_SERVER_RECIBOS_CLIENTE = 'Server.RecibosCliente';
|
||||||
|
|
||||||
|
type
|
||||||
|
TBizRecibosClienteServer = class(TRecibosClienteBusinessProcessorRules)
|
||||||
|
private
|
||||||
|
FReferenciaAutomatica : Boolean;
|
||||||
|
function DarReferencia : String;
|
||||||
|
function IncrementarReferencia : Boolean;
|
||||||
|
protected
|
||||||
|
procedure BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); override;
|
||||||
|
procedure AfterProcessChange(Sender: TDABusinessProcessor; aChange: TDADeltaChange; Processed: Boolean; var CanRemoveFromDelta: Boolean); override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
||||||
|
schRecibosClienteClient_Intf, srvReferencias_Impl;
|
||||||
|
|
||||||
|
const
|
||||||
|
REF_RECIBOS_CLIENTE = 'REF_RECIBOS_CLIENTE';
|
||||||
|
|
||||||
|
{ TBizRecibosClienteServer }
|
||||||
|
|
||||||
|
procedure TBizRecibosClienteServer.AfterProcessChange(Sender: TDABusinessProcessor; aChange: TDADeltaChange; Processed: Boolean;
|
||||||
|
var CanRemoveFromDelta: Boolean);
|
||||||
|
begin
|
||||||
|
|
||||||
|
// No hay que quitar los deltas para que los datos del contacto se
|
||||||
|
// mantengan por si alguna tabla detalle lo necesita
|
||||||
|
// (por ejemplo, DireccionesContacto)
|
||||||
|
CanRemoveFromDelta := False;
|
||||||
|
|
||||||
|
// Actualizamos el contador de referencias.
|
||||||
|
case aChange.ChangeType of
|
||||||
|
ctInsert, ctUpdate: begin
|
||||||
|
if FReferenciaAutomatica then
|
||||||
|
begin
|
||||||
|
IncrementarReferencia;
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBizRecibosClienteServer.BeforeProcessDelta(
|
||||||
|
Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
||||||
|
begin
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
|
||||||
|
case Sender.CurrentChange.ChangeType of
|
||||||
|
ctInsert, ctUpdate: begin
|
||||||
|
//Si la referencia no ha sido asignada le asignamos una nosotros
|
||||||
|
if REFERENCIAIsNull or (Length(REFERENCIA) = 0) then
|
||||||
|
begin
|
||||||
|
FReferenciaAutomatica := True;
|
||||||
|
REFERENCIA := DarReferencia;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBizRecibosClienteServer.DarReferencia: String;
|
||||||
|
var
|
||||||
|
ATipo : String;
|
||||||
|
begin
|
||||||
|
ATipo := REF_RECIBOS_CLIENTE;
|
||||||
|
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := DarNuevaReferencia(ATipo, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBizRecibosClienteServer.IncrementarReferencia: Boolean;
|
||||||
|
var
|
||||||
|
ATipo : String;
|
||||||
|
begin
|
||||||
|
ATipo := REF_RECIBOS_CLIENTE;
|
||||||
|
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := IncrementarValorReferencia(ATipo,
|
||||||
|
Self.REFERENCIA, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
RegisterBusinessProcessorRules(BIZ_SERVER_RECIBOS_CLIENTE, TBizRecibosClienteServer);
|
||||||
|
|
||||||
|
end.
|
||||||
Loading…
Reference in New Issue
Block a user