From 8b6a55d9adb9f65e455fc77fd7ff172bc93aa692 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 6 Oct 2008 13:54:35 +0000 Subject: [PATCH] =?UTF-8?q?Arreglado=20un=20fallo=20de=20renumerar=20la=20?= =?UTF-8?q?posici=C3=B3n=20al=20copiar=20y=20pegar=20texto=20desde=20el=20?= =?UTF-8?q?portapapeles.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@664 0c75b7a4-871f-7646-8a2f-f78d34cc349f --- Source/Base/Utiles/uGridClipboardUtils.pas | 59 ++++++++++++++++------ 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/Source/Base/Utiles/uGridClipboardUtils.pas b/Source/Base/Utiles/uGridClipboardUtils.pas index a70b89ca..b5f44604 100644 --- a/Source/Base/Utiles/uGridClipboardUtils.pas +++ b/Source/Base/Utiles/uGridClipboardUtils.pas @@ -47,21 +47,33 @@ end; procedure RenumerarCampoPosicion(ADataSet : TDataSet); var - iContador : Integer; + i, j : Integer; AField : TField; begin AField := ADataSet.FindField('POSICION'); if Assigned(AField) and not (ADataSet.IsEmpty) then begin - ADataSet.Last; - iContador := ADataSet.RecordCount; - repeat - ADataSet.Edit; - AField.AsInteger := iContador - 1; - ADataSet.Post; - AdataSet.Prior; - iContador := iContador - 1; - until ADataSet.BOF; + with ADataSet do + begin + for i:=0 to RecordCount-1 do + begin + First; + if not Locate('POSICION', i, []) then + begin + j := i; + First; + while not Locate('POSICION', j, []) do + begin + Inc(j); + First; + end; + + Edit; + FieldByName('POSICION').AsInteger := i; + Post; + end; + end; + end; end; end; @@ -158,21 +170,30 @@ begin if bEstabaVacia then ADataSet.Append else begin - if iContador > 0 then + if iContador = 0 then + ADataSet.Edit + else begin ADataSet.Next; - ADataSet.Insert; + if ADataSet.EOF then + ADataSet.Append + else + ADataSet.Insert; + end; end; try for iCols := 0 to NumCols - 1 do begin AValue := AReader.ReadVariant; - if (Pos(AValueNameList[iCols], AView.DataController.KeyFieldNames) = 0) then + if (Pos(AValueNameList[iCols], AView.DataController.KeyFieldNames) = 0) and + (AValueNameList[iCols] <> 'POSICION') then + begin if _BuscarColumna(AView, AValueNameList[iCols], AValueTypeList[iCols], AIndex) then begin if AIndex <> -1 then ADataSet.FieldByName(AView.DataController.GetItemField(AIndex).FieldName).Value := AValue; end; + end; end; finally ADataSet.Post; @@ -564,9 +585,15 @@ begin if bEstabaVacia then ADataSet.Append else begin - {if iContador > 0 then - ADataSet.Next;} - ADataSet.Insert; + if iContador = 0 then + ADataSet.Edit + else begin + ADataSet.Next; + if ADataSet.EOF then + ADataSet.Append + else + ADataSet.Insert; + end; end; try