~chronoscz/mydata/trunk

« back to all changes in this revision

Viewing changes to DbEngines/UEngineXML.pas

  • Committer: chronos
  • Date: 2022-09-10 20:54:56 UTC
  • Revision ID: svn-v4:dfc1a4cf-ca09-4be6-80b8-3cecc5d1c945:trunk:29
* Fixed: Load table fields in records list and record edit form.
* Fixed: Record add needs to insert new row into database.

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
  Node2: TDOMNode;
98
98
  I: Integer;
99
99
begin
100
 
  Row.Values.Count := Row.Parent.Fields.Count;
 
100
  Row.Values.Count := Row.Table.Fields.Count;
101
101
  for I := 0 to Row.Values.Count - 1 do
102
 
    Row.Values[I] := TValueClass(Row.Parent.Fields[I].GetValueClass).Create;
 
102
    Row.Values[I] := TValueClass(Row.Table.Fields[I].GetValueClass).Create;
103
103
 
104
104
  Node2 := Node.FirstChild;
105
105
  I := 0;
106
106
  while Assigned(Node2) and (Node2.NodeName = 'Value') and (I < Row.Values.Count) do begin
107
 
    case Row.Parent.Fields[I].DataType.FieldType of
 
107
    case Row.Table.Fields[I].DataType.FieldType of
108
108
      ftString: TValueString(Row.Values[I]).Value := string(Node2.TextContent);
109
109
      ftInteger: TValueInteger(Row.Values[I]).Value := StrToInt(string(Node2.TextContent));
110
110
      ftDateTime: if Node2.TextContent <> '' then
124
124
  for I := 0 to Row.Values.Count - 1 do begin;
125
125
    NewNode := Node.OwnerDocument.CreateElement('Value');
126
126
    Node.AppendChild(NewNode);
127
 
    case Row.Parent.Fields[I].DataType.FieldType of
 
127
    case Row.Table.Fields[I].DataType.FieldType of
128
128
      ftString: NewNode.TextContent := UnicodeString(TValueString(Row.Values[I]).Value);
129
129
      ftInteger: NewNode.TextContent := UnicodeString(IntToStr(TValueInteger(Row.Values[I]).Value));
130
130
      ftDateTime: NewNode.TextContent := UnicodeString(DateTimeToXMLTime(TValueDateTime(Row.Values[I]).Value));
143
143
  Node2 := Node.FirstChild;
144
144
  while Assigned(Node2) and (Node2.NodeName = 'Record') do begin
145
145
    NewRecord := TRecord.Create;
146
 
    NewRecord.Parent := Records.Parent;
 
146
    NewRecord.Table := Records.Table;
147
147
    LoadNodeRecord(NewRecord, Node2);
148
148
    Records.Add(NewRecord);
149
149
    Node2 := Node2.NextSibling;
491
491
        Field := Table.Fields.SearchByName(InsertValues.Names[ValueIndex]);
492
492
        if Assigned(Field) then begin
493
493
          FieldIndex := Table.Fields.IndexOf(Field);
494
 
          TValue(Row.Values[FieldIndex]).SetString(InsertValues.ValueFromIndex[ValueIndex]);
 
494
          Row.Values[FieldIndex].SetString(InsertValues.ValueFromIndex[ValueIndex]);
495
495
        end else raise Exception.Create(Format(SColumnNotFoundInTable,
496
496
          [InsertValues.Names[ValueIndex], TableName]));
497
497
      end;