Tecsitel_FactuGES2/Source/ApplicationBase/Empresas/Model/uBizEmpresasServer.pas

66 lines
1.9 KiB
ObjectPascal

unit uBizEmpresasServer;
interface
uses
uDAInterfaces, uDADelta, uDABusinessProcessor,
schEmpresasServer_Intf;
const
BIZ_SERVER_EMPRESAS = 'Server.Empresas';
type
TBizEmpresasServer = class(TEmpresasBusinessProcessorRules)
protected
procedure AfterProcessChange(Sender: TDABusinessProcessor; aChange: TDADeltaChange; Processed: Boolean;
var CanRemoveFromDelta: Boolean); override;
end;
implementation
uses
Variants, uDAClasses, srvReferencias_Impl, uBusinessUtils, uROClasses,
uDataModuleServer, schEmpresasClient_Intf, Dialogs;
{ TBizEmpresasServer }
procedure TBizEmpresasServer.AfterProcessChange(Sender: TDABusinessProcessor;
aChange: TDADeltaChange; Processed: Boolean; var CanRemoveFromDelta: Boolean);
var
AConn : IDAConnection;
begin
inherited;
{ Por defecto, mantenemos los deltas por si alguna tabla hija los necesita }
CanRemoveFromDelta := False;
case aChange.ChangeType of
ctInsert, ctUpdate: begin
if ((Sender.CurrentChange.OldValueByName[fld_EmpresasPARAM_TIEMPO] <> Sender.CurrentChange.NewValueByName[fld_EmpresasPARAM_TIEMPO])
or (Sender.CurrentChange.OldValueByName[fld_EmpresasPARAM_MARGEN] <> Sender.CurrentChange.NewValueByName[fld_EmpresasPARAM_MARGEN])) then
begin
try
//Recalculamos los PVP del catalogo
AConn := dmServer.ConnectionManager.NewConnection(dmServer.ConnectionManager.GetDefaultConnectionName);
AConn.BeginTransaction;
Sender.Schema.NewCommand(AConn, 'RecalcularPVPArticulos', ['ID_EMPRESA'], [Sender.CurrentChange.OldValueByName[fld_EmpresasID]]);
AConn.CommitTransaction;
except
AConn.RollbackTransaction;
RaiseError('RecalcularPVPArticulos');
end;
AConn:= Nil;
end;
end;
end;
end;
initialization
RegisterBusinessProcessorRules(BIZ_SERVER_EMPRESAS, TBizEmpresasServer);
end.