git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES2/trunk@149 b2cfbe5a-eba1-4a0c-8b32-7feea0a119f2
172 lines
4.5 KiB
ObjectPascal
172 lines
4.5 KiB
ObjectPascal
unit uBizAgentesServer;
|
|
|
|
interface
|
|
|
|
uses
|
|
schContactosServer_Intf, uDAInterfaces, uDADelta,
|
|
uDADataTable, uDABusinessProcessor, uBizContactosServer;
|
|
|
|
const
|
|
BIZ_SERVER_AGENTE = 'Server.Agente';
|
|
|
|
type
|
|
TBizAgenteServer = class(TBizContactosServer)
|
|
protected
|
|
function DarReferenciaContacto : String; override;
|
|
function IncrementarReferenciaContacto : Boolean; override;
|
|
|
|
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, SysUtils, DateUtils,
|
|
schContactosClient_Intf, uBusinessUtils, Dialogs;
|
|
|
|
const
|
|
REF_AGENTES = 'REF_AGENTES';
|
|
|
|
{ TBizAgenteServer }
|
|
|
|
function TBizAgenteServer.DarReferenciaContacto: String;
|
|
begin
|
|
Result := _DarReferenciaInterna(REF_AGENTES)
|
|
end;
|
|
|
|
procedure TBizAgenteServer.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_AgentesDatos');
|
|
try
|
|
with ACommand do
|
|
begin
|
|
ParamByName('OLD_ID_AGENTE').Value := aChange.OldValueByName[fld_AgentesID];
|
|
Execute;
|
|
end;
|
|
finally
|
|
ACommand := NIL;
|
|
end;
|
|
{
|
|
ACommand := ASchema.NewCommand(ACurrentConn, 'Delete_Agentes_Objetivos_albaranes');
|
|
try
|
|
with ACommand do
|
|
begin
|
|
ParamByName('OLD_ID').Value := aChange.OldValueByName[fld_AgentesID];
|
|
Execute;
|
|
end;
|
|
finally
|
|
ACommand := NIL;
|
|
end;
|
|
|
|
ACommand := ASchema.NewCommand(ACurrentConn, 'Delete_Agentes_Objetivos_facturas');
|
|
try
|
|
with ACommand do
|
|
begin
|
|
ParamByName('OLD_ID').Value := aChange.OldValueByName[fld_AgentesID];
|
|
Execute;
|
|
end;
|
|
finally
|
|
ACommand := NIL;
|
|
end;
|
|
}
|
|
end;
|
|
|
|
function TBizAgenteServer.IncrementarReferenciaContacto: Boolean;
|
|
begin
|
|
Result := _IncrementarReferenciaInterna(REF_AGENTES)
|
|
end;
|
|
|
|
procedure TBizAgenteServer.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_AgentesDatos');
|
|
try
|
|
with ACommand do
|
|
begin
|
|
ParamByName('ID_AGENTE').Value := aChange.NewValueByName[fld_AgentesID];
|
|
ParamByName('FECHA_ALTA_EMPRESA').Value := aChange.NewValueByName[fld_AgentesFECHA_ALTA_EMPRESA];
|
|
ParamByName('FECHA_BAJA').Value := aChange.NewValueByName[fld_AgentesFECHA_BAJA];
|
|
ParamByName('CAUSA_BAJA').Value := aChange.NewValueByName[fld_AgentesCAUSA_BAJA];
|
|
Execute;
|
|
end;
|
|
finally
|
|
ACommand := NIL;
|
|
end;
|
|
|
|
ACommand := ASchema.NewCommand(ACurrentConn, 'Insert_ObjetivosAgentes');
|
|
try
|
|
with ACommand do
|
|
begin
|
|
ParamByName('ID_AGENTE').Value := aChange.NewValueByName[fld_AgentesID];
|
|
ParamByName('ANO').Value := YearOf(now);
|
|
Execute;
|
|
end;
|
|
finally
|
|
ACommand := NIL;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TBizAgenteServer.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_AgentesDatos');
|
|
try
|
|
with ACommand do
|
|
begin
|
|
ParamByName('OLD_ID_AGENTE').Value := aChange.OldValueByName[fld_AgentesID];
|
|
ParamByName('FECHA_ALTA_EMPRESA').Value := aChange.NewValueByName[fld_AgentesFECHA_ALTA_EMPRESA];
|
|
ParamByName('FECHA_BAJA').Value := aChange.NewValueByName[fld_AgentesFECHA_BAJA];
|
|
ParamByName('CAUSA_BAJA').Value := aChange.NewValueByName[fld_AgentesCAUSA_BAJA];
|
|
Execute;
|
|
end;
|
|
finally
|
|
ACommand := NIL;
|
|
end;
|
|
|
|
ACommand := ASchema.NewCommand(ACurrentConn, 'Insert_ObjetivosAgentes');
|
|
try
|
|
with ACommand do
|
|
begin
|
|
ParamByName('ID_AGENTE').Value := aChange.NewValueByName[fld_AgentesID];
|
|
ParamByName('ANO').Value := YearOf(now);
|
|
Execute;
|
|
end;
|
|
finally
|
|
ACommand := NIL;
|
|
end;
|
|
|
|
end;
|
|
|
|
initialization
|
|
RegisterBusinessProcessorRules(BIZ_SERVER_AGENTE, TBizAgenteServer);
|
|
|
|
end.
|