Cambio para que los recibos relacionados con las facturas se eliminen en las reglas de negocio del servidor en vez de por integridad referencial de la BD

git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@334 0c75b7a4-871f-7646-8a2f-f78d34cc349f
This commit is contained in:
roberto 2008-03-12 13:12:04 +00:00
parent 0ca1948d80
commit 7436c5163a
4 changed files with 108 additions and 4 deletions

View File

@ -16,10 +16,9 @@ type
function DarReferencia : String;
function IncrementarReferencia : Boolean;
protected
procedure BeforeProcessDelta(Sender: TDABusinessProcessor;
const aDelta: IDADelta); override;
procedure AfterProcessChange(Sender: TDABusinessProcessor;
aChange: TDADeltaChange; Processed: Boolean;
procedure Delete_Asiento_Factura(aChange: TDADeltaChange); virtual;
procedure BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); override;
procedure AfterProcessChange(Sender: TDABusinessProcessor; aChange: TDADeltaChange; Processed: Boolean;
var CanRemoveFromDelta: Boolean); override;
end;
@ -42,6 +41,18 @@ procedure TBizFacturasClienteServer.AfterProcessChange(
var CanRemoveFromDelta: Boolean);
begin
inherited;
case aChange.ChangeType of
ctInsert: begin
// Insert_Asiento_Factura(aChange);
end;
ctUpdate: begin
// Update_Asiento_Factura(aChange);
end;
ctDelete: begin
Delete_Asiento_Factura(aChange);
end;
end;
{ Por defecto, mantenemos los deltas por si alguna tabla hija los necesita }
CanRemoveFromDelta := False;
@ -88,6 +99,28 @@ begin
end;
end;
procedure TBizFacturasClienteServer.Delete_Asiento_Factura(aChange: TDADeltaChange);
var
ASchema : TDASchema;
ACurrentConn : IDAConnection;
ACommand : IDASQLCommand;
begin
ASchema := BusinessProcessor.Schema;
ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);
//Eliminamos los recibos de la factura
ACommand := ASchema.NewCommand(ACurrentConn, 'Delete_RecibosFactura');
try
with ACommand do
begin
ParamByName('ID_FACTURA').Value := aChange.OldValueByName[fld_FacturasClienteID];
Execute;
end;
finally
ACommand := NIL;
end;
end;
function TBizFacturasClienteServer.IncrementarReferencia: Boolean;
var
ATipo : String;

View File

@ -497,6 +497,24 @@ object srvFacturasCliente: TsrvFacturasCliente
JoinDataTables = <>
UnionDataTables = <>
Commands = <
item
Params = <
item
Name = 'ID_FACTURA'
Value = ''
end>
Statements = <
item
Connection = 'IBX'
ConnectionType = 'Interbase'
Default = True
Name = 'IBX'
SQL = 'delete from recibos_cliente'#10'where id_factura = :ID_FACTURA'#10
StatementType = stSQL
ColumnMappings = <>
end>
Name = 'Delete_RecibosFactura'
end
item
Params = <
item

View File

@ -17,6 +17,7 @@ type
function DarReferencia : String;
function IncrementarReferencia : Boolean;
protected
procedure Delete_Asiento_Factura(aChange: TDADeltaChange); virtual;
procedure BeforeProcessDelta(Sender: TDABusinessProcessor;
const aDelta: IDADelta); override;
procedure AfterProcessChange(Sender: TDABusinessProcessor;
@ -43,6 +44,18 @@ procedure TBizFacturasProveedorServer.AfterProcessChange(
var CanRemoveFromDelta: Boolean);
begin
inherited;
case aChange.ChangeType of
ctInsert: begin
// Insert_Asiento_Factura(aChange);
end;
ctUpdate: begin
// Update_Asiento_Factura(aChange);
end;
ctDelete: begin
Delete_Asiento_Factura(aChange);
end;
end;
{ Por defecto, mantenemos los deltas por si alguna tabla hija los necesita }
CanRemoveFromDelta := False;
@ -88,6 +101,28 @@ begin
end;
end;
procedure TBizFacturasProveedorServer.Delete_Asiento_Factura(aChange: TDADeltaChange);
var
ASchema : TDASchema;
ACurrentConn : IDAConnection;
ACommand : IDASQLCommand;
begin
ASchema := BusinessProcessor.Schema;
ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);
//Eliminamos los recibos de la factura
ACommand := ASchema.NewCommand(ACurrentConn, 'Delete_RecibosFactura');
try
with ACommand do
begin
ParamByName('ID_FACTURA').Value := aChange.OldValueByName[fld_FacturasProveedorID];
Execute;
end;
finally
ACommand := NIL;
end;
end;
function TBizFacturasProveedorServer.IncrementarReferencia: Boolean;
var
ATipo : String;

View File

@ -483,6 +483,24 @@ object srvFacturasProveedor: TsrvFacturasProveedor
JoinDataTables = <>
UnionDataTables = <>
Commands = <
item
Params = <
item
Name = 'ID_FACTURA'
Value = ''
end>
Statements = <
item
Connection = 'IBX'
ConnectionType = 'Interbase'
Default = True
Name = 'IBX'
SQL = 'delete from recibos_proveedor'#10'where id_factura = :ID_FACTURA'#10
StatementType = stSQL
ColumnMappings = <>
end>
Name = 'Delete_RecibosFactura'
end
item
Params = <
item