Mejora de DataTableUtils, y insercion de BeginUpdate y EndUpdate en los tratamientos de los detalles de toda la aplicacion
git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@386 0c75b7a4-871f-7646-8a2f-f78d34cc349f
This commit is contained in:
parent
4609fb7704
commit
c0a81786db
@ -34,10 +34,10 @@ function CloneDataTable(const ASource : TDAMemDataTable;
|
||||
|
||||
|
||||
procedure DuplicarRegistro(ASource : TDADataTable; ATarget : TDADataTable;
|
||||
Const WithKey: Boolean = False);
|
||||
Const WithPKKey: Boolean = False; Const WithFKKey: Boolean = False);
|
||||
procedure DuplicarRegistros(ASource : TDADataTable; ATarget : TDADataTable;
|
||||
AModo : TModoDuplicarRegistros; APermitirRepetidos: Boolean = True;
|
||||
Const WithDeltas: Boolean = True; Const WithKey: Boolean = False);
|
||||
Const WithDeltas: Boolean = True; Const WithPKKey: Boolean = False; Const WithFKKey: Boolean = False);
|
||||
|
||||
procedure DeleteAllTable(const ADataTable : TDADataTable);
|
||||
|
||||
@ -418,7 +418,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure DuplicarRegistro(ASource : TDADataTable; ATarget : TDADataTable; Const WithKey: Boolean = False);
|
||||
procedure DuplicarRegistro(ASource : TDADataTable; ATarget : TDADataTable; Const WithPKKey: Boolean = False; Const WithFKKey: Boolean = False);
|
||||
var
|
||||
i, j: Integer;
|
||||
ATargetField: TDAField;
|
||||
@ -467,19 +467,40 @@ begin
|
||||
// Los campos AutoInc no se rellenan y tampoco los campos que
|
||||
// formen parte de la relación maestro-detalle en el
|
||||
// caso de que la tabla destino sea una tabla detalle.
|
||||
if not WithKey then
|
||||
if not WithPKKey then
|
||||
begin
|
||||
//Si no es campo clave
|
||||
if not (ATargetField.InPrimaryKey) and
|
||||
//Si no es autoinc (podria desaparecer pero no lo quitamos por si acaso
|
||||
(ATargetField.DataType <> datAutoInc) and
|
||||
//Si no hay campos foreing key o los hay pero el campo a copiar no es uno de ellos
|
||||
(not Assigned(ADetailFields) or not ADetailFields.Find(ATargetField.Name, j)) then
|
||||
//Copiamos el campo
|
||||
ATargetField.Value := ASourceField.Value;
|
||||
if not (ATargetField.InPrimaryKey) and
|
||||
(ATargetField.DataType <> datAutoInc) then
|
||||
begin
|
||||
//En el caso de no copiar las claves foraneas
|
||||
//Si no hay campos foreing key o los hay pero el campo a copiar no es uno de ellos
|
||||
if not WithFKKey then
|
||||
begin
|
||||
if (not Assigned(ADetailFields) or not ADetailFields.Find(ATargetField.Name, j)) then
|
||||
//Copiamos el campo
|
||||
ATargetField.Value := ASourceField.Value;
|
||||
end
|
||||
else
|
||||
//Copiamos el campo
|
||||
ATargetField.Value := ASourceField.Value;
|
||||
|
||||
end;
|
||||
end
|
||||
else
|
||||
ATargetField.Value := ASourceField.Value;
|
||||
//En el caso de no copiar las claves foraneas
|
||||
//Si no hay campos foreing key o los hay pero el campo a copiar no es uno de ellos
|
||||
if not WithFKKey then
|
||||
begin
|
||||
//Si no hay campos foreing key o los hay pero el campo a copiar no es uno de ellos
|
||||
if (not Assigned(ADetailFields) or not ADetailFields.Find(ATargetField.Name, j)) then
|
||||
//Copiamos el campo
|
||||
ATargetField.Value := ASourceField.Value;
|
||||
end
|
||||
else
|
||||
//Copiamos el campo
|
||||
ATargetField.Value := ASourceField.Value;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
@ -491,7 +512,7 @@ end;
|
||||
|
||||
procedure DuplicarRegistros(ASource : TDADataTable; ATarget : TDADataTable;
|
||||
AModo : TModoDuplicarRegistros; APermitirRepetidos: Boolean = True;
|
||||
Const WithDeltas: Boolean = True; Const WithKey: Boolean = False);
|
||||
Const WithDeltas: Boolean = True; Const WithPKKey: Boolean = False; Const WithFKKey: Boolean = False);
|
||||
begin
|
||||
if not ASource.Active then
|
||||
ASource.Open;
|
||||
@ -505,18 +526,18 @@ begin
|
||||
DesconectarTabla(ATarget);
|
||||
|
||||
if AModo = mdrActual then
|
||||
DuplicarRegistro(ASource, ATarget, WithKey) //ATarget.CloneSelectedRecord(ASource, True)
|
||||
DuplicarRegistro(ASource, ATarget, WithPKKey, WithFKKey) //ATarget.CloneSelectedRecord(ASource, True)
|
||||
else begin
|
||||
ASource.First;
|
||||
while not ASource.EOF do
|
||||
begin
|
||||
if APermitirRepetidos then
|
||||
DuplicarRegistro(ASource, ATarget, WithKey)
|
||||
DuplicarRegistro(ASource, ATarget, WithPKKey, WithFKKey)
|
||||
else
|
||||
begin
|
||||
ATarget.First;
|
||||
if not ATarget.Locate('ID', ASource.FieldByName('ID').AsVariant, []) then
|
||||
DuplicarRegistro(ASource, ATarget, WithKey);
|
||||
DuplicarRegistro(ASource, ATarget, WithPKKey, WithFKKey);
|
||||
end;
|
||||
|
||||
ASource.Next;
|
||||
|
||||
@ -198,6 +198,11 @@ begin
|
||||
ADetallesController := TDetallesAlbaranProveedorController.Create;
|
||||
AArticulosController := TArticulosController.Create;
|
||||
try
|
||||
//OJO IMPORTANTE
|
||||
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
|
||||
//obligarle siempre a recalcular los detalles una sola vez
|
||||
ADetallesController.BeginUpdate(ADetalles);
|
||||
|
||||
AInventarioRecibido.DataTable.First;
|
||||
for i := 0 to AInventarioRecibido.DataTable.RecordCount - 1 do
|
||||
begin
|
||||
@ -228,8 +233,8 @@ begin
|
||||
|
||||
AInventarioRecibido.Next;
|
||||
end;
|
||||
|
||||
finally
|
||||
ADetallesController.EndUpdate(ADetalles);
|
||||
ADetallesController := NIL;
|
||||
AArticulosController := NIL;
|
||||
end;
|
||||
@ -243,6 +248,11 @@ begin
|
||||
ADetallesController := TDetallesAlbaranProveedorController.Create;
|
||||
AArticulosController := TArticulosController.Create;
|
||||
try
|
||||
//OJO IMPORTANTE
|
||||
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
|
||||
//obligarle siempre a recalcular los detalles una sola vez
|
||||
ADetallesController.BeginUpdate(ADetalles);
|
||||
|
||||
APedido.Detalles.DataTable.First;
|
||||
for i := 0 to APedido.Detalles.DataTable.RecordCount - 1 do
|
||||
begin
|
||||
@ -265,11 +275,8 @@ begin
|
||||
APedido.Detalles.Next;
|
||||
end;
|
||||
|
||||
//Obligamos a actualizar los totales para que asi los importes totales de los artículos
|
||||
//se recalculen y actualicen
|
||||
ADetallesController.ActualizarTotales(ADetalles);
|
||||
|
||||
finally
|
||||
ADetallesController.EndUpdate(ADetalles);
|
||||
ADetallesController := NIL;
|
||||
AArticulosController := NIL;
|
||||
end;
|
||||
|
||||
Binary file not shown.
@ -3,7 +3,7 @@ unit schArticulosClient_Intf;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, DB, SysUtils, uROClasses, uDADataTable, FmtBCD, uROXMLIntf;
|
||||
Classes, DB, schBase_Intf, SysUtils, uROClasses, uDADataTable, FmtBCD, uROXMLIntf;
|
||||
|
||||
const
|
||||
{ Data table rules ids
|
||||
@ -254,7 +254,7 @@ type
|
||||
end;
|
||||
|
||||
{ TArticulosDataTableRules }
|
||||
TArticulosDataTableRules = class(TDADataTableRules, IArticulos)
|
||||
TArticulosDataTableRules = class(TIntfObjectDADataTableRules, IArticulos)
|
||||
private
|
||||
f_IMAGEN: IROStream;
|
||||
procedure IMAGEN_OnChange(Sender: TObject);
|
||||
@ -544,7 +544,7 @@ type
|
||||
end;
|
||||
|
||||
{ TArticulosParaClienteDataTableRules }
|
||||
TArticulosParaClienteDataTableRules = class(TDADataTableRules, IArticulosParaCliente)
|
||||
TArticulosParaClienteDataTableRules = class(TIntfObjectDADataTableRules, IArticulosParaCliente)
|
||||
private
|
||||
f_IMAGEN: IROStream;
|
||||
procedure IMAGEN_OnChange(Sender: TObject);
|
||||
|
||||
@ -141,6 +141,11 @@ begin
|
||||
|
||||
ADetallesController := TDetallesFacturaClienteController.Create;
|
||||
try
|
||||
//OJO IMPORTANTE
|
||||
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
|
||||
//obligarle siempre a recalcular los detalles una sola vez
|
||||
ADetallesController.BeginUpdate(ADestino);
|
||||
|
||||
AOrigen.DataTable.First;
|
||||
for i := 0 to AOrigen.DataTable.RecordCount - 1 do
|
||||
begin
|
||||
@ -161,6 +166,7 @@ begin
|
||||
AOrigen.Next;
|
||||
end;
|
||||
finally
|
||||
ADetallesController.EndUpdate(ADestino);
|
||||
ADetallesController := NIL;
|
||||
end;
|
||||
end;}
|
||||
@ -186,6 +192,11 @@ begin
|
||||
|
||||
ADetallesController := TDetallesFacturaClienteController.Create;
|
||||
try
|
||||
//OJO IMPORTANTE
|
||||
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
|
||||
//obligarle siempre a recalcular los detalles una sola vez
|
||||
ADetallesController.BeginUpdate(ADestino);
|
||||
|
||||
AOrigen.DataTable.First;
|
||||
for i := 0 to AOrigen.DataTable.RecordCount - 1 do
|
||||
begin
|
||||
@ -206,6 +217,7 @@ begin
|
||||
AOrigen.Next;
|
||||
end;
|
||||
finally
|
||||
ADetallesController.EndUpdate(ADestino);
|
||||
ADetallesController := NIL;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -141,6 +141,11 @@ begin
|
||||
|
||||
ADetallesController := TDetallesFacturaProveedorController.Create;
|
||||
try
|
||||
//OJO IMPORTANTE
|
||||
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
|
||||
//obligarle siempre a recalcular los detalles una sola vez
|
||||
ADetallesController.BeginUpdate(ADestino);
|
||||
|
||||
AOrigen.DataTable.First;
|
||||
for i := 0 to AOrigen.DataTable.RecordCount - 1 do
|
||||
begin
|
||||
@ -161,6 +166,7 @@ begin
|
||||
AOrigen.Next;
|
||||
end;
|
||||
finally
|
||||
ADetallesController.EndUpdate(ADestino);
|
||||
ADetallesController := NIL;
|
||||
end;
|
||||
end;
|
||||
@ -185,6 +191,11 @@ begin
|
||||
|
||||
ADetallesController := TDetallesFacturaProveedorController.Create;
|
||||
try
|
||||
//OJO IMPORTANTE
|
||||
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
|
||||
//obligarle siempre a recalcular los detalles una sola vez
|
||||
ADetallesController.BeginUpdate(ADestino);
|
||||
|
||||
AOrigen.DataTable.First;
|
||||
for i := 0 to AOrigen.DataTable.RecordCount - 1 do
|
||||
begin
|
||||
@ -205,6 +216,7 @@ begin
|
||||
AOrigen.Next;
|
||||
end;
|
||||
finally
|
||||
ADetallesController.EndUpdate(ADestino);
|
||||
ADetallesController := NIL;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -103,6 +103,11 @@ begin
|
||||
AArticulosPendientes.DataTable.First;
|
||||
for i := 0 to AArticulosPendientes.DataTable.RecordCount - 1 do
|
||||
begin
|
||||
//OJO IMPORTANTE
|
||||
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
|
||||
//obligarle siempre a recalcular los detalles una sola vez
|
||||
ADetallesController.BeginUpdate(ADetalles);
|
||||
|
||||
AAlbaran.Detalles.First;
|
||||
if (AAlbaran.Detalles.Locate('ID_ARTICULO', AArticulosPendientes.ID_ARTICULO, [])) then
|
||||
if (AArticulosPendientes.CANTIDAD_PENDIENTE > 0) then
|
||||
@ -124,6 +129,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
ADetallesController.EndUpdate(ADetalles);
|
||||
ADetallesController := NIL;
|
||||
end;
|
||||
end; }
|
||||
|
||||
@ -103,6 +103,11 @@ begin
|
||||
AArticulosPendientes.DataTable.First;
|
||||
for i := 0 to AArticulosPendientes.DataTable.RecordCount - 1 do
|
||||
begin
|
||||
//OJO IMPORTANTE
|
||||
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
|
||||
//obligarle siempre a recalcular los detalles una sola vez
|
||||
ADetallesController.BeginUpdate(ADetalles);
|
||||
|
||||
AAlbaran.Detalles.First;
|
||||
if (AAlbaran.Detalles.Locate('ID_ARTICULO', AArticulosPendientes.ID_ARTICULO, [])) then
|
||||
if (AArticulosPendientes.CANTIDAD_PENDIENTE > 0) then
|
||||
@ -124,6 +129,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
ADetallesController.EndUpdate(ADetalles);
|
||||
ADetallesController := NIL;
|
||||
end;
|
||||
end; }
|
||||
|
||||
@ -98,6 +98,11 @@ begin
|
||||
AArticulosPendientes.DataTable.First;
|
||||
for i := 0 to AArticulosPendientes.DataTable.RecordCount - 1 do
|
||||
begin
|
||||
//OJO IMPORTANTE
|
||||
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
|
||||
//obligarle siempre a recalcular los detalles una sola vez
|
||||
ADetallesController.BeginUpdate(ADetalles);
|
||||
|
||||
APedido.Detalles.First;
|
||||
if (APedido.Detalles.Locate('ID_ARTICULO', AArticulosPendientes.ID_ARTICULO, [])) then
|
||||
if (AArticulosPendientes.CANTIDAD_PENDIENTE > 0) then
|
||||
@ -120,6 +125,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
ADetallesController.EndUpdate(ADetalles);
|
||||
ADetallesController := NIL;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -122,6 +122,11 @@ begin
|
||||
APedidoProv.ID_PEDIDO_CLIENTE := APedidoCli.ID;
|
||||
end;
|
||||
|
||||
//OJO IMPORTANTE
|
||||
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
|
||||
//obligarle siempre a recalcular los detalles una sola vez
|
||||
ADetallesController.BeginUpdate(APedidoProv.Detalles);
|
||||
|
||||
ADetallesPedidosProvController.Add(APedidoProv.Detalles, TIPO_DETALLE_CONCEPTO);
|
||||
ADetallesPedidosProvController.AnadirArticulo(APedidoProv.Detalles, AArticulosPend.ID_ARTICULO);
|
||||
with APedidoProv.Detalles do
|
||||
@ -130,6 +135,7 @@ begin
|
||||
CANTIDAD := AArticulosPend.CANT_PENDIENTE_PEDIR;
|
||||
Post;
|
||||
end;
|
||||
ADetallesController.EndUpdate(APedidoProv.Detalles);
|
||||
AArticulosPend.DataTable.Next;
|
||||
end;
|
||||
|
||||
|
||||
@ -100,13 +100,18 @@ begin
|
||||
AArticulosPendientes.DataTable.First;
|
||||
for i := 0 to AArticulosPendientes.DataTable.RecordCount - 1 do
|
||||
begin
|
||||
//OJO IMPORTANTE
|
||||
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
|
||||
//obligarle siempre a recalcular los detalles una sola vez
|
||||
ADetallesController.BeginUpdate(ADetalles);
|
||||
|
||||
APedido.Detalles.First;
|
||||
if (APedido.Detalles.Locate('ID_ARTICULO', AArticulosPendientes.ID_ARTICULO, [])) then
|
||||
if (AArticulosPendientes.CANTIDAD > 0) then
|
||||
begin
|
||||
ADetallesController.Add(ADetalles, TIPO_DETALLE_CONCEPTO);
|
||||
ADetalles.Edit;
|
||||
ADetalles.ID_PEDIDO := APedido.Detalles.ID_PEDIDO;
|
||||
ADetalles.ID_PEDIDO := APedido.Detalles.ID_PEDIDO;
|
||||
ADetalles.REFERENCIA := APedido.Detalles.REFERENCIA;
|
||||
ADetalles.ID_ARTICULO := APedido.Detalles.ID_ARTICULO;
|
||||
ADetalles.CONCEPTO := APedido.Detalles.CONCEPTO;
|
||||
@ -122,6 +127,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
ADetallesController.EndUpdate(ADetalles);
|
||||
ADetallesController := NIL;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -102,6 +102,11 @@ begin
|
||||
AArticulosPendientes.DataTable.First;
|
||||
for i := 0 to AArticulosPendientes.DataTable.RecordCount - 1 do
|
||||
begin
|
||||
//OJO IMPORTANTE
|
||||
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
|
||||
//obligarle siempre a recalcular los detalles una sola vez
|
||||
ADetallesController.BeginUpdate(ADetalles);
|
||||
|
||||
APedido.Detalles.First;
|
||||
if (APedido.Detalles.Locate('ID_ARTICULO', AArticulosPendientes.ID_ARTICULO, [])) then
|
||||
if (AArticulosPendientes.CANTIDAD_PENDIENTE > 0) then
|
||||
@ -123,6 +128,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
ADetallesController.EndUpdate(ADetalles);
|
||||
ADetallesController := NIL;
|
||||
end;
|
||||
end; }
|
||||
|
||||
@ -102,6 +102,11 @@ begin
|
||||
AArticulosPendientes.DataTable.First;
|
||||
for i := 0 to AArticulosPendientes.DataTable.RecordCount - 1 do
|
||||
begin
|
||||
//OJO IMPORTANTE
|
||||
//Siempre que vayamos a trabajar con los detalles debemos hacer un beginupdate de los mismos y un endupdate para
|
||||
//obligarle siempre a recalcular los detalles una sola vez
|
||||
ADetallesController.BeginUpdate(ADetalles);
|
||||
|
||||
APedido.Detalles.First;
|
||||
if (APedido.Detalles.Locate('ID_ARTICULO', AArticulosPendientes.ID_ARTICULO, [])) then
|
||||
if (AArticulosPendientes.CANTIDAD_PENDIENTE > 0) then
|
||||
@ -123,6 +128,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
ADetallesController.EndUpdate(ADetalles);
|
||||
ADetallesController := NIL;
|
||||
end;
|
||||
end; }
|
||||
|
||||
Binary file not shown.
@ -14,7 +14,7 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "FileVersion", "1.0.4.0\0"
|
||||
VALUE "ProductVersion", "1.0.4.0\0"
|
||||
VALUE "CompileDate", "martes, 20 de mayo de 2008 20:39\0"
|
||||
VALUE "CompileDate", "lunes, 26 de mayo de 2008 18:50\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user