Browse Source

+ Patch from Joost van der Sluis for Insert/Resync

michael 21 years ago
parent
commit
9ced5ec803
1 changed files with 16 additions and 5 deletions
  1. 16 5
      fcl/db/dataset.inc

+ 16 - 5
fcl/db/dataset.inc

@@ -471,6 +471,7 @@ begin
      ftWord: Result := TWordField;
      ftWord: Result := TWordField;
      ftBoolean: Result := TBooleanField;
      ftBoolean: Result := TBooleanField;
      ftFloat: Result := TFloatField;
      ftFloat: Result := TFloatField;
+     ftBCD: Result := TBCDField;
      ftDate: Result := TDateField;
      ftDate: Result := TDateField;
      ftTime: Result := TTimeField;
      ftTime: Result := TTimeField;
      ftDateTime: Result := TDateTimeField;
      ftDateTime: Result := TDateTimeField;
@@ -946,6 +947,7 @@ begin
     else
     else
       begin
       begin
       SetState(dsBrowse);
       SetState(dsBrowse);
+      SetCurrentRecord(FActiverecord);
       resync([]);
       resync([]);
       end;
       end;
     DoAfterCancel;
     DoAfterCancel;
@@ -1023,6 +1025,7 @@ begin
 {$ifdef dsdebug}
 {$ifdef dsdebug}
     writeln ('Delete: Browse mode set');
     writeln ('Delete: Browse mode set');
 {$endif}
 {$endif}
+    SetCurrentRecord(FActiverecord);
     Resync([]);
     Resync([]);
     DoAfterDelete;
     DoAfterDelete;
     DoAfterScroll;
     DoAfterScroll;
@@ -1060,7 +1063,8 @@ Procedure TDataset.DoInsertAppend(DoAppend : Boolean);
   if FActiveRecord < FRecordCount-1 then
   if FActiveRecord < FRecordCount-1 then
     begin
     begin
     TempBuf := FBuffers[FBuffercount];
     TempBuf := FBuffers[FBuffercount];
-    move(FBuffers[FActiveRecord],FBuffers[FActiveRecord+1],(Fbuffercount-FActiveRecord)*sizeof(FBuffers[0]));      FBuffers[FActiveRecord]:=TempBuf;
+    move(FBuffers[FActiveRecord],FBuffers[FActiveRecord+1],(Fbuffercount-FActiveRecord)*sizeof(FBuffers[0]));
+    FBuffers[FActiveRecord]:=TempBuf;
     end
     end
   else
   else
     inc(FActiveRecord);
     inc(FActiveRecord);
@@ -1078,7 +1082,7 @@ Procedure TDataset.DoInsertAppend(DoAppend : Boolean);
   else
   else
     begin
     begin
     fBOF := false;
     fBOF := false;
-    if FRecordcount > 0 then SetBookMarkData(ActiveBuffer,@BookBeforeInsert);
+    if FRecordcount > 0 then SetBookMarkData(ActiveBuffer,pointer(BookBeforeInsert));
     end;
     end;
   // update buffer count.
   // update buffer count.
   If FRecordCount<FBufferCount then
   If FRecordCount<FBufferCount then
@@ -1115,6 +1119,7 @@ begin
   try
   try
     DoOnNewRecord;
     DoOnNewRecord;
   except
   except
+    SetCurrentRecord(FActiverecord);
     resync([]);
     resync([]);
     raise;
     raise;
   end;
   end;
@@ -1302,6 +1307,7 @@ begin
     CheckBrowseMode;
     CheckBrowseMode;
     DoBeforeScroll;
     DoBeforeScroll;
     InternalGotoBookMark(ABookMark);
     InternalGotoBookMark(ABookMark);
+    SetCurrentRecord(FActiverecord);
     Resync([rmExact,rmCenter]);
     Resync([rmExact,rmCenter]);
     DoAfterScroll;
     DoAfterScroll;
     end;
     end;
@@ -1498,6 +1504,7 @@ begin
     writeln ('Post: Internalpost succeeded');
     writeln ('Post: Internalpost succeeded');
 {$endif}
 {$endif}
     FreeFieldBuffers;
     FreeFieldBuffers;
+//    SetCurrentRecord(FActiverecord);
     Resync([]);
     Resync([]);
     SetState(dsBrowse);
     SetState(dsBrowse);
 {$ifdef dsdebug}
 {$ifdef dsdebug}
@@ -1519,6 +1526,7 @@ begin
   CheckbrowseMode;
   CheckbrowseMode;
   UpdateCursorPos;
   UpdateCursorPos;
   InternalRefresh;
   InternalRefresh;
+  SetCurrentRecord(FActiverecord);
   Resync([]);
   Resync([]);
 end;
 end;
 
 
@@ -1541,7 +1549,7 @@ begin
 {$endif}
 {$endif}
 
 
 // place the cursor of the underlying dataset to the active record
 // place the cursor of the underlying dataset to the active record
-  SetCurrentRecord(FActiverecord);
+//  SetCurrentRecord(FActiverecord);
 
 
 // Now look if the data on the current cursor of the underlying dataset is still available
 // Now look if the data on the current cursor of the underlying dataset is still available
   If GetRecord(Fbuffers[0],gmcurrent,True)<>grOk Then
   If GetRecord(Fbuffers[0],gmcurrent,True)<>grOk Then
@@ -1580,7 +1588,7 @@ begin
 // Fill the rest of the buffer
 // Fill the rest of the buffer
   getnextrecords;
   getnextrecords;
 // If the buffer is not full yet, try to fetch some more prior records
 // If the buffer is not full yet, try to fetch some more prior records
-  if FRecordcount < FBuffercount then getpriorrecords;
+  if FRecordcount < FBuffercount then inc(FActiverecord,getpriorrecords);
 // That's all folks!
 // That's all folks!
   DataEvent(deDatasetChange,0);
   DataEvent(deDatasetChange,0);
 end;
 end;
@@ -1713,7 +1721,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.21  2004-08-23 07:30:19  michael
+  Revision 1.22  2004-08-30 12:02:17  michael
+  + Patch from Joost van der Sluis for Insert/Resync
+
+  Revision 1.21  2004/08/23 07:30:19  michael
   + Fixes from joost van der sluis: tfieldsdefs.tdatafield and size, cancel of only record and dataset.fieldvalyes
   + Fixes from joost van der sluis: tfieldsdefs.tdatafield and size, cancel of only record and dataset.fieldvalyes
 
 
   Revision 1.20  2004/08/21 21:10:00  michael
   Revision 1.20  2004/08/21 21:10:00  michael