Mejora de la funcion de copiar tablas para que se pueda elegir si copiar claves foraneas o no
git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES2/trunk@222 f4e31baf-9722-1c47-927c-6f952f962d4b
This commit is contained in:
parent
0b2cb8c58c
commit
a16ebef7f1
@ -58,47 +58,47 @@
|
|||||||
<DelphiCompile Include="Base.dpk">
|
<DelphiCompile Include="Base.dpk">
|
||||||
<MainSource>MainSource</MainSource>
|
<MainSource>MainSource</MainSource>
|
||||||
</DelphiCompile>
|
</DelphiCompile>
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\adortl.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\adortl.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\cxIntl6D11.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\cxIntl6D11.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\cxIntlPrintSys3D11.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\cxIntlPrintSys3D11.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\DataAbstract_Core_D11.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\DataAbstract_Core_D11.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\dbrtl.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\dbrtl.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\dclIndyCore.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\dclIndyCore.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\designide.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\designide.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\dsnap.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\dsnap.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\GUISDK_D11.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\GUISDK_D11.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\IndyCore.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\IndyCore.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\IndyProtocols.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\IndyProtocols.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\IndySystem.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\IndySystem.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\Jcl.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\Jcl.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\JclVcl.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\JclVcl.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\JSDialog100.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\JSDialog100.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\JvCmpD11R.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\JvCmpD11R.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\JvCoreD11R.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\JvCoreD11R.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\JvCtrlsD11R.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\JvCtrlsD11R.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\JvDlgsD11R.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\JvDlgsD11R.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\JvMMD11R.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\JvMMD11R.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\JvNetD11R.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\JvNetD11R.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\JvPageCompsD11R.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\JvPageCompsD11R.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\JvStdCtrlsD11R.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\JvStdCtrlsD11R.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\JvSystemD11R.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\JvSystemD11R.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\pckMD5.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\pckMD5.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\pckUCDataConnector.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\pckUCDataConnector.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\pckUserControl_RT.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\pckUserControl_RT.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\PluginSDK_D10R.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\PluginSDK_D10R.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\PngComponentsD10.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\PngComponentsD10.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\PNG_D10.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\PNG_D10.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\RemObjects_Core_D11.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\RemObjects_Core_D11.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\rtl.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\rtl.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\TB2k_D10.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\TB2k_D10.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\tbx_d10.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\tbx_d10.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\vcl.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\vcl.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\vclactnband.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\vclactnband.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\vcldb.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\vcldb.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\vcljpg.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\vcljpg.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\VclSmp.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\VclSmp.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\vclx.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\vclx.dcp" />
|
||||||
<DCCReference Include="..\Modulos\Contabilidad\xmlrtl.dcp" />
|
<DCCReference Include="..\..\Output\Debug\Servidor\Informes\xmlrtl.dcp" />
|
||||||
<DCCReference Include="..\Servicios\FactuGES_Intf.pas" />
|
<DCCReference Include="..\Servicios\FactuGES_Intf.pas" />
|
||||||
<DCCReference Include="Conexion\uConfigurarConexion.pas">
|
<DCCReference Include="Conexion\uConfigurarConexion.pas">
|
||||||
<Form>fConfigurarConexion</Form>
|
<Form>fConfigurarConexion</Form>
|
||||||
|
|||||||
@ -34,10 +34,10 @@ function CloneDataTable(const ASource : TDAMemDataTable;
|
|||||||
|
|
||||||
|
|
||||||
procedure DuplicarRegistro(ASource : TDADataTable; ATarget : TDADataTable;
|
procedure DuplicarRegistro(ASource : TDADataTable; ATarget : TDADataTable;
|
||||||
Const WithKey: Boolean = False);
|
Const WithPKKey: Boolean = False; Const WithFKKey: Boolean = False);
|
||||||
procedure DuplicarRegistros(ASource : TDADataTable; ATarget : TDADataTable;
|
procedure DuplicarRegistros(ASource : TDADataTable; ATarget : TDADataTable;
|
||||||
AModo : TModoDuplicarRegistros; APermitirRepetidos: Boolean = True;
|
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);
|
procedure DeleteAllTable(const ADataTable : TDADataTable);
|
||||||
|
|
||||||
@ -511,7 +511,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
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
|
var
|
||||||
i, j: Integer;
|
i, j: Integer;
|
||||||
ATargetField: TDAField;
|
ATargetField: TDAField;
|
||||||
@ -529,7 +529,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
case ATarget.MasterMappingMode of
|
case ATarget.MasterMappingMode of
|
||||||
//mmDataRequest: //Sin hacer;
|
//mmDataRequest: //Sin hacer;
|
||||||
mmParams, mmWhere: begin
|
mmParams, mmWhere: begin
|
||||||
//Creamos la lista de campos foreing key
|
//Creamos la lista de campos foreing key
|
||||||
ADetailFields := TStringList.Create;
|
ADetailFields := TStringList.Create;
|
||||||
ADetailFields.Sorted := True;
|
ADetailFields.Sorted := True;
|
||||||
@ -558,19 +558,39 @@ begin
|
|||||||
// Los campos AutoInc no se rellenan y tampoco los campos que
|
// Los campos AutoInc no se rellenan y tampoco los campos que
|
||||||
// formen parte de la relación maestro-detalle en el
|
// formen parte de la relación maestro-detalle en el
|
||||||
// caso de que la tabla destino sea una tabla detalle.
|
// caso de que la tabla destino sea una tabla detalle.
|
||||||
if not WithKey then
|
if not WithPKKey then
|
||||||
begin
|
begin
|
||||||
//Si no es campo clave
|
//Si no es campo clave
|
||||||
if not (ATargetField.InPrimaryKey) and
|
|
||||||
//Si no es autoinc (podria desaparecer pero no lo quitamos por si acaso
|
//Si no es autoinc (podria desaparecer pero no lo quitamos por si acaso
|
||||||
(ATargetField.DataType <> datAutoInc) and
|
if not (ATargetField.InPrimaryKey)
|
||||||
//Si no hay campos foreing key o los hay pero el campo a copiar no es uno de ellos
|
and (ATargetField.DataType <> datAutoInc) then
|
||||||
(not Assigned(ADetailFields) or not ADetailFields.Find(ATargetField.Name, j)) then
|
begin
|
||||||
//Copiamos el campo
|
//En el caso de no copiar las claves foraneas
|
||||||
ATargetField.Value := ASourceField.Value;
|
//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
|
end
|
||||||
else
|
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;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
@ -582,7 +602,7 @@ end;
|
|||||||
|
|
||||||
procedure DuplicarRegistros(ASource : TDADataTable; ATarget : TDADataTable;
|
procedure DuplicarRegistros(ASource : TDADataTable; ATarget : TDADataTable;
|
||||||
AModo : TModoDuplicarRegistros; APermitirRepetidos: Boolean = True;
|
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
|
begin
|
||||||
if not ASource.Active then
|
if not ASource.Active then
|
||||||
ASource.Open;
|
ASource.Open;
|
||||||
@ -596,18 +616,18 @@ begin
|
|||||||
DesconectarTabla(ATarget);
|
DesconectarTabla(ATarget);
|
||||||
|
|
||||||
if AModo = mdrActual then
|
if AModo = mdrActual then
|
||||||
DuplicarRegistro(ASource, ATarget, WithKey) //ATarget.CloneSelectedRecord(ASource, True)
|
DuplicarRegistro(ASource, ATarget, WithPKKey, WithFKKey) //ATarget.CloneSelectedRecord(ASource, True)
|
||||||
else begin
|
else begin
|
||||||
ASource.First;
|
ASource.First;
|
||||||
while not ASource.EOF do
|
while not ASource.EOF do
|
||||||
begin
|
begin
|
||||||
if APermitirRepetidos then
|
if APermitirRepetidos then
|
||||||
DuplicarRegistro(ASource, ATarget, WithKey)
|
DuplicarRegistro(ASource, ATarget, WithPKKey, WithFKKey)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
ATarget.First;
|
ATarget.First;
|
||||||
if not ATarget.Locate('ID', ASource.FieldByName('ID').AsVariant, []) then
|
if not ATarget.Locate('ID', ASource.FieldByName('ID').AsVariant, []) then
|
||||||
DuplicarRegistro(ASource, ATarget, WithKey);
|
DuplicarRegistro(ASource, ATarget, WithPKKey, WithFKKey);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ASource.Next;
|
ASource.Next;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user