Browse Source

+ Fixes from joost van der sluis: tfieldsdefs.tdatafield and size, cancel of only record and dataset.fieldvalyes

michael 21 years ago
parent
commit
7ddaad98cc
2 changed files with 41 additions and 7 deletions
  1. 31 3
      fcl/db/dataset.inc
  2. 10 4
      fcl/db/db.pp

+ 31 - 3
fcl/db/dataset.inc

@@ -342,6 +342,7 @@ end;
 Procedure TDataset.DoInternalClose;
 
 begin
+  CheckBrowsemode;
   FreeFieldBuffers;
   ClearBuffers;
   SetBufListSize(-1);
@@ -934,8 +935,19 @@ begin
     UpdateCursorPos;
     InternalCancel;
     FreeFieldBuffers;
-    SetState(dsBrowse);
-    Resync([]);
+    if (state = dsInsert) and (FRecordcount = 1) then
+      begin
+      FEOF := true;
+      FBOF := true;
+      FRecordcount := 0;
+      SetState(dsBrowse);
+      DataEvent(deDatasetChange,0);
+      end
+    else
+      begin
+      SetState(dsBrowse);
+      resync([]);
+      end;
     DoAfterCancel;
     end;
 end;
@@ -1679,6 +1691,19 @@ begin
   FBuffers[0]:=TempBuf;
 end;
 
+function TDataset.GetFieldValues(Fieldname : string) : string;
+
+begin
+  result := findfield(Fieldname).asstring;
+end;
+
+procedure TDataset.SetFieldValues(Fieldname : string;value : string);
+
+begin
+  findfield(Fieldname).asstring := value;
+end;
+
+
 Procedure TDataset.UnRegisterDataSource(ADatasource : TDatasource);
 
 begin
@@ -1688,7 +1713,10 @@ end;
 
 {
   $Log$
-  Revision 1.20  2004-08-21 21:10:00  michael
+  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
+
+  Revision 1.20  2004/08/21 21:10:00  michael
   * Patch from Joost van der Sluis
     - Empty recordsets don't show any bogus data anymore
     - Floatfiels.gettext fix

+ 10 - 4
fcl/db/db.pp

@@ -127,9 +127,9 @@ type
   Published  
     property Attributes: TFieldAttributes read FAttributes write FAttributes default [];
     property Name: string read FName write FName; // Must move to TNamedItem
-    property DataType: TFieldType read FDataType;
+    property DataType: TFieldType read FDataType write FDataType;
     property Precision: Longint read FPrecision write FPrecision;
-    property Size: Word read FSize;
+    property Size: Word read FSize write FSize;
   end;
 
 { TFieldDefs }
@@ -883,6 +883,7 @@ type
     procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
     function  GetFieldClass(FieldType: TFieldType): TFieldClass; virtual;
     Function  GetfieldCount : Integer;
+    function  GetFieldValues(fieldname : string) : string; virtual;
     function  GetIsIndexField(Field: TField): Boolean; virtual;
     function  GetNextRecords: Longint; virtual;
     function  GetNextRecord: Boolean; virtual;
@@ -907,6 +908,7 @@ type
     procedure SetFilterOptions(Value: TFilterOptions); virtual;
     procedure SetFilterText(const Value: string); virtual;
     procedure SetFound(const Value: Boolean);
+    procedure SetFieldValues(fieldname : string;value : string); virtual;
     procedure SetModified(Value: Boolean);
     procedure SetName(const Value: TComponentName); override;
     procedure SetOnFilterRecord(const Value: TFilterRecordEvent); virtual;
@@ -1014,7 +1016,8 @@ type
     property RecNo: Longint read FRecNo write FRecNo;
     property RecordSize: Word read FRecordSize;
     property State: TDataSetState read FState;
-    property Fields : TFields Read FFieldList;
+    property Fields : TFields read FFieldList;
+    property FieldValues[fieldname : string] : string read GetFieldValues write SetFieldValues; default;
     property Filter: string read FFilterText write SetFilterText;
     property Filtered: Boolean read FFiltered write SetFiltered default False;
     property FilterOptions: TFilterOptions read FFilterOptions write FFilterOptions;
@@ -1500,7 +1503,10 @@ end.
 
 {
   $Log$
-  Revision 1.21  2004-08-14 12:46:35  michael
+  Revision 1.22  2004-08-23 07:30:19  michael
+  + Fixes from joost van der sluis: tfieldsdefs.tdatafield and size, cancel of only record and dataset.fieldvalyes
+
+  Revision 1.21  2004/08/14 12:46:35  michael
   + Patch from Joost van der Sluis to implement Modified and UpdateRecord event
 
   Revision 1.20  2004/08/13 07:06:02  michael