Changeset 14


Ignore:
Timestamp:
Mar 22, 2018, 7:59:13 PM (7 years ago)
Author:
chronos
Message:
  • Added: Support for item references.
  • Added: Data and Time value types.
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/DbEngines/UEngineMySQL.pas

    r13 r14  
    66
    77uses
    8   Classes, SysUtils, UDatabase, USqlDatabase, UHtmlClasses, SpecializedDictionary;
     8  Classes, Dialogs, SysUtils, UDatabase, USqlDatabase, UHtmlClasses, SpecializedDictionary;
    99
    1010type
     
    3232var
    3333  DbRows: TDbRows;
     34  DbRows2: TDbRows;
    3435  NewField: TField;
    3536  I: Integer;
    3637  DataType: Integer;
     38  TypeName: string;
    3739begin
    3840  DbRows := TDbRows.Create;
     41  DbRows2 := TDbRows.Create;
    3942  try
    4043    SqlDatabase.Query(DbRows, 'SELECT * FROM `ModelField` WHERE `Model` = ' + IntToStr(Table.Id) + '');
     
    4447      NewField.Name := TDictionaryStringString(DbRows[I]).Values['Name'];
    4548      NewField.TextBefore := TDictionaryStringString(DbRows[I]).Values['Title'];
    46       DataType := StrToInt(TDictionaryStringString(DbRows[I]).Values['DataType']);
    47       NewField.DataType := Table.Database.Engine.DataTypes.FindByType(TFieldType(DataType));
    48       if not Assigned(NewField.DataType) then
     49      DataType := StrToInt(TDictionaryStringString(DbRows[I]).Values['Type']);
     50      SqlDatabase.Query(DbRows2, 'SELECT * FROM `DataType` WHERE `Id` = ' + IntToStr(DataType) + '');
     51      if DbRows2.Count > 0 then begin
     52        TypeName := TDictionaryStringString(DbRows2[0]).Values['Name'];
     53        NewField.DataType := Table.Database.Engine.DataTypes.FindByName(TypeName);
     54        if not Assigned(NewField.DataType) then
     55          NewField.DataType := Table.Database.Engine.DataTypes.FindByType(ftString);
     56      end else begin
     57        // Use string as default
    4958        NewField.DataType := Table.Database.Engine.DataTypes.FindByType(ftString);
     59      end;
    5060      Table.Fields.Add(NewField);
    5161    end;
    5262  finally
    5363    DbRows.Free;
     64    DbRows2.Free;
    5465  end;
    5566end;
     
    7283      NewTable.Caption := TDictionaryStringString(DbRows[I]).Values['Title'];
    7384      LoadFields(NewTable);
    74       DbRows2 := TDbRows.Create;
    75       try
    76         SqlDatabase.Query(DbRows2, 'SELECT COUNT(*) FROM `' + NewTable.Name + '`');
    77         if DbRows2.Count = 1 then
    78           NewTable.RecordsCount := StrToInt(DbRows2[0].Values['COUNT(*)']);
    79       finally
    80         DbRows2.Free;
    81       end;
    8285      Database.Tables.Add(NewTable);
    8386    end;
  • trunk/Forms/UFormField.pas

    r8 r14  
    9494      ComboBoxType.Items.Add('');
    9595    for I := 0 to Count - 1 do begin
    96       ComboBoxType.Items.Strings[I] := TDataType(Items[I]).Name;
     96      ComboBoxType.Items.Strings[I] := TDataType(Items[I]).Title;
    9797      ComboBoxType.Items.Objects[I] := Items[I];
    9898    end;
  • trunk/Forms/UFormFields.pas

    r11 r14  
    131131  with TField(Fields[Item.Index]) do begin
    132132    Item.Caption := Name;
    133     Item.SubItems.Add(DataType.Name);
     133    Item.SubItems.Add(DataType.Title);
    134134    Item.SubItems.Add(BoolToStr(Required));
    135135    Item.SubItems.Add(TextBefore);
  • trunk/Forms/UFormMain.lfm

    r11 r14  
    1212  OnShow = FormShow
    1313  LCLVersion = '1.5'
     14  WindowState = wsMaximized
    1415  object StatusBar1: TStatusBar
    1516    Left = 0
  • trunk/Forms/UFormRecord.pas

    r8 r14  
    8787  NewControl: TControl;
    8888  CellRect: TRect;
     89const
     90  LabelWidth = 300;
    8991begin
    9092  Row := DataRecord;
     
    9294  Labels.Clear;
    9395  for I := 0 to Table.Fields.Count - 1 do begin
    94     CellRect := Rect(10, 10 + I * 70, Panel1.Width - 20, (I + 1) * 70);
     96    CellRect := Rect(10, 10 + I * 35, Panel1.Width - 20, (I + 1) * 35);
    9597    NewLabel := TLabel.Create(Panel1);
    9698    NewLabel.Caption := TField(Table.Fields[I]).TextBefore;
     
    103105      ftString: begin
    104106        NewControl := TEdit.Create(Panel1);
    105         NewControl.Parent := Panel1;
    106         NewControl.Left := CellRect.Left;
    107         NewControl.Top := CellRect.Top + NewLabel.Height + 6;
    108         NewControl.Width := CellRect.Right - CellRect.Left;
     107        NewControl.Anchors := [akLeft, akTop, akRight];
     108        NewControl.Parent := Panel1;
     109        NewControl.Left := CellRect.Left + LabelWidth;
     110        NewControl.Top := CellRect.Top;
     111        NewControl.Width := CellRect.Right - CellRect.Left - LabelWidth;
    109112        NewControl.Visible := True;
    110113        TEdit(NewControl).Text := TValueString(Row.Values[I]).Value;
     
    114117        NewControl := TSpinEdit.Create(Panel1);
    115118        NewControl.Parent := Panel1;
    116         NewControl.Left := CellRect.Left;
    117         NewControl.Top := CellRect.Top + NewLabel.Height + 6;
    118         NewControl.Width := CellRect.Right - CellRect.Left;
     119        NewControl.Left := CellRect.Left + LabelWidth;
     120        NewControl.Top := CellRect.Top;
     121        NewControl.Width := CellRect.Right - CellRect.Left - LabelWidth;
    119122        NewControl.Visible := True;
    120123        TSpinEdit(NewControl).Value := TValueInteger(Row.Values[I]).Value;
     
    124127        NewControl := TDateEdit.Create(Panel1);
    125128        NewControl.Parent := Panel1;
    126         NewControl.Left := CellRect.Left;
    127         NewControl.Top := CellRect.Top + NewLabel.Height + 6;
    128         NewControl.Width := CellRect.Right - CellRect.Left;
     129        NewControl.Left := CellRect.Left + LabelWidth;
     130        NewControl.Top := CellRect.Top;
     131        NewControl.Width := CellRect.Right - CellRect.Left - LabelWidth;
    129132        NewControl.Visible := True;
    130133        TDateEdit(NewControl).Date := TValueDateTime(Row.Values[I]).Value;
     
    134137        NewControl := TCheckBox.Create(Panel1);
    135138        NewControl.Parent := Panel1;
    136         NewControl.Left := CellRect.Left;
    137         NewControl.Top := CellRect.Top + NewLabel.Height + 6;
    138         NewControl.Width := CellRect.Right - CellRect.Left;
     139        NewControl.Left := CellRect.Left + LabelWidth;
     140        NewControl.Top := CellRect.Top;
     141        NewControl.Width := CellRect.Right - CellRect.Left - LabelWidth;
    139142        NewControl.Visible := True;
    140143        TCheckBox(NewControl).Checked := TValueBoolean(Row.Values[I]).Value;
     
    144147        NewControl := TFloatSpinEdit.Create(Panel1);
    145148        NewControl.Parent := Panel1;
    146         NewControl.Left := CellRect.Left;
    147         NewControl.Top := CellRect.Top + NewLabel.Height + 6;
    148         NewControl.Width := CellRect.Right - CellRect.Left;
     149        NewControl.Left := CellRect.Left + LabelWidth;
     150        NewControl.Top := CellRect.Top;
     151        NewControl.Width := CellRect.Right - CellRect.Left - LabelWidth;
    149152        NewControl.Visible := True;
    150153        TFloatSpinEdit(NewControl).Value := TValueFloat(Row.Values[I]).Value;
     154        Controls.Add(NewControl);
     155      end;
     156      ftImage: begin
     157        NewControl := TImage.Create(Panel1);
     158        NewControl.Parent := Panel1;
     159        NewControl.Left := CellRect.Left + LabelWidth;
     160        NewControl.Top := CellRect.Top;
     161        NewControl.Width := CellRect.Right - CellRect.Left - LabelWidth;
     162        NewControl.Height := NewLabel.Height;
     163        NewControl.Visible := True;
     164        //TImage(NewControl).Value := TValueFloat(Row.Values[I]).Value;
     165        Controls.Add(NewControl);
     166      end;
     167      ftReference: begin
     168        NewControl := TComboBox.Create(Panel1);
     169        NewControl.Parent := Panel1;
     170        NewControl.Left := CellRect.Left + LabelWidth;
     171        NewControl.Top := CellRect.Top;
     172        NewControl.Width := CellRect.Right - CellRect.Left - LabelWidth;
     173        NewControl.Height := NewLabel.Height;
     174        NewControl.Visible := True;
     175
     176        TComboBox(NewControl).Items.Add(IntToStr(TValueReference(Row.Values[I]).Value));
    151177        Controls.Add(NewControl);
    152178      end;
     
    166192      ftBoolean: TValueBoolean(Row.Values[I]).Value := TCheckBox(Controls[I]).Checked;
    167193      ftFloat: TValueFloat(Row.Values[I]).Value := TFloatSpinEdit(Controls[I]).Value;
     194      //ftImage: TValueFloat(Row.Values[I]).Value := TFloatSpinEdit(Controls[I]).Value;
    168195    end;
    169196  end;
  • trunk/Languages/MyData.cs.po

    r13 r14  
    378378msgstr "Pozice na mapě"
    379379
     380#: ucore.stypereference
     381msgid "Reference"
     382msgstr ""
     383
    380384#: ucore.stypestring
    381385msgid "String"
     
    429433msgid "Database query error: \"%s\""
    430434msgstr "Chyba požadavku databáze: \"%s\""
     435
  • trunk/Languages/MyData.po

    r13 r14  
    369369msgstr ""
    370370
     371#: ucore.stypereference
     372msgid "Reference"
     373msgstr ""
     374
    371375#: ucore.stypestring
    372376msgid "String"
  • trunk/MyData.lpi

    r13 r14  
    111111        <HasResources Value="True"/>
    112112        <ResourceBaseClass Value="Form"/>
    113         <UnitName Value="UFormTables"/>
    114113      </Unit1>
    115114      <Unit2>
    116115        <Filename Value="UDatabase.pas"/>
    117116        <IsPartOfProject Value="True"/>
    118         <UnitName Value="UDatabase"/>
    119117      </Unit2>
    120118      <Unit3>
     
    124122        <HasResources Value="True"/>
    125123        <ResourceBaseClass Value="DataModule"/>
    126         <UnitName Value="UCore"/>
    127124      </Unit3>
    128125      <Unit4>
    129126        <Filename Value="DbEngines/UEngineXML.pas"/>
    130127        <IsPartOfProject Value="True"/>
    131         <UnitName Value="UEngineXML"/>
    132128      </Unit4>
    133129      <Unit5>
     
    144140        <HasResources Value="True"/>
    145141        <ResourceBaseClass Value="Form"/>
    146         <UnitName Value="UFormRecords"/>
    147142      </Unit6>
    148143      <Unit7>
     
    152147        <HasResources Value="True"/>
    153148        <ResourceBaseClass Value="Form"/>
    154         <UnitName Value="UFormRecord"/>
    155149      </Unit7>
    156150      <Unit8>
     
    171165        <Filename Value="UDataTypes.pas"/>
    172166        <IsPartOfProject Value="True"/>
    173         <UnitName Value="UDataTypes"/>
    174167      </Unit10>
    175168      <Unit11>
    176169        <Filename Value="DbEngines/UEngineMySQL.pas"/>
    177170        <IsPartOfProject Value="True"/>
    178         <UnitName Value="UEngineMySQL"/>
    179171      </Unit11>
    180172      <Unit12>
    181173        <Filename Value="DbEngines/UEngineSQLite.pas"/>
    182174        <IsPartOfProject Value="True"/>
    183         <UnitName Value="UEngineSQLite"/>
    184175      </Unit12>
    185176      <Unit13>
     
    203194        <HasResources Value="True"/>
    204195        <ResourceBaseClass Value="Form"/>
    205         <UnitName Value="UFormDatabases"/>
    206196      </Unit15>
    207197      <Unit16>
  • trunk/Packages/CoolWeb/Persistence/USqlDatabase.pas

    r12 r14  
    149149  TimeParts: TListString;
    150150begin
     151  if Value = '' then Result := 0 else
    151152  try
    152153    Parts := TListString.Create;
     
    156157    Parts.Explode(Value, ' ', StrToStr);
    157158    DateParts.Explode(Parts[0], '-', StrToStr);
     159    if (StrToInt(DateParts[0]) = 0) or (StrToInt(DateParts[1]) = 0) or
     160    (StrToInt(DateParts[2]) = 0) then Result := 0 else
    158161    Result := EncodeDate(StrToInt(DateParts[0]), StrToInt(DateParts[1]),
    159162      StrToInt(DateParts[2]));
  • trunk/Packages/TemplateGenerics/Generic/GenericDictionary.inc

    r10 r14  
    9191    Result := Result + 1;
    9292  end;
     93  if Result >= Count then Result := -1;
    9394end;
    9495
  • trunk/Packages/TemplateGenerics/Generic/GenericMatrix.inc

    r10 r14  
    5050    function Implode(RowSeparator, ColSeparator: string; Converter: TToStringConverter): string;
    5151    procedure Explode(Text, Separator: string; Converter: TFromStringConverter; SlicesCount: Integer = -1);
    52     function IndexOf(Item: TGMatrixItem; Start: TIndex = 0): TIndex;
    53     function IndexOfList(List: TGMatrix; Start: TIndex = 0): TIndex;
     52    function IndexOf(Item: TGMatrixItem; Start: TIndex): TIndex;
     53    function IndexOfList(List: TGMatrix; Start: TIndex): TIndex;
    5454    procedure Insert(Index: TIndex; Item: TGMatrixItem);
    5555    procedure InsertList(Index: TIndex; List: TGMatrix);
  • trunk/UCore.lfm

    r11 r14  
    14251425  end
    14261426  object XMLConfig1: TXMLConfig
    1427     Filename = 'Config.xml'
    14281427    StartEmpty = False
    14291428    RootName = 'CONFIG'
     1429    ReadOnly = False
    14301430    left = 294
    14311431    top = 216
  • trunk/UCore.pas

    r13 r14  
    6868  STypeTime = 'Time';
    6969  STypeDateTime = 'Date and time';
     70  STypeReference = 'Reference';
    7071
    7172{ TCore }
     
    109110begin
    110111  for I := 0 to DataTypes.Count - 1 do begin
    111     TDataType(DataTypes[I]).Name := CoolTranslator1.TranslateText(TDataType(DataTypes[I]).Name, TDataType(DataTypes[I]).Name);
     112    TDataType(DataTypes[I]).Title := CoolTranslator1.TranslateText(TDataType(DataTypes[I]).Title, TDataType(DataTypes[I]).Title);
    112113  end;
    113114end;
     
    130131
    131132  NewEngine := Engines.RegisterEngine('MySQL', TDatabaseMySQL);
    132   NewEngine.UseTypes(DataTypes, [ftString, ftInteger, ftDateTime, ftBoolean, ftFloat]);
     133  NewEngine.UseTypes(DataTypes, [ftString, ftInteger, ftDateTime, ftBoolean, ftFloat,
     134    ftReference]);
    133135
    134136  NewEngine := Engines.RegisterEngine('SQLite', TDatabaseSQLite);
     
    140142  DataTypes.Clear;
    141143  with DataTypes do begin
    142     RegisterType(1, STypeString, ftString, TFieldString);
    143     RegisterType(2, STypeInteger, ftInteger, TFieldInteger);
    144     RegisterType(3, STypeDateTime, ftDateTime, TFieldDateTime);
    145     RegisterType(4, STypeBoolean, ftBoolean, TFieldBoolean);
    146     RegisterType(5, STypeFloat, ftFloat, TFieldFloat);
    147     RegisterType(6, STypeMapPosition, ftMapPosition, TFieldMapPosition);
    148     RegisterType(7, STypeDate, ftDate, TFieldDate);
    149     RegisterType(8, STypeTime, ftTime, TFieldTime);
    150     RegisterType(9, STypeImage, ftImage, TFieldImage);
     144    RegisterType(1, 'String', STypeString, ftString, TFieldString);
     145    RegisterType(2, 'Integer', STypeInteger, ftInteger, TFieldInteger);
     146    RegisterType(3, 'DateTime', STypeDateTime, ftDateTime, TFieldDateTime);
     147    RegisterType(4, 'Boolean', STypeBoolean, ftBoolean, TFieldBoolean);
     148    RegisterType(5, 'Float', STypeFloat, ftFloat, TFieldFloat);
     149    RegisterType(6, 'MapPosition', STypeMapPosition, ftMapPosition, TFieldMapPosition);
     150    RegisterType(7, 'Date', STypeDate, ftDate, TFieldDate);
     151    RegisterType(8, 'Time', STypeTime, ftTime, TFieldTime);
     152    RegisterType(9, 'Image', STypeImage, ftImage, TFieldImage);
     153    RegisterType(10, 'Reference', STypeReference, ftReference, TFieldReference);
    151154  end;
    152155end;
     
    174177  Engine: TDatabaseEngine;
    175178begin
     179  XMLConfig1.FileName := 'Config.xml';
    176180  Databases.Count := XMLConfig1.GetValue('Database/Count', 0);
    177181  for I := 0 to Databases.Count - 1 do begin
  • trunk/UDataTypes.pas

    r13 r14  
    66
    77uses
    8   Classes, SysUtils, UDatabase, Contnrs;
     8  Classes, SysUtils, UDatabase, Contnrs, USqlDatabase;
    99
    1010type
     
    1515    procedure Assign(Source: TValue); override;
    1616    function GetString: string; override;
    17     function SetString(Value: string): string; override;
     17    procedure SetString(Value: string); override;
    1818  end;
    1919
     
    2424    procedure Assign(Source: TValue); override;
    2525    function GetString: string; override;
    26     function SetString(Value: string): string; override;
     26    procedure SetString(Value: string); override;
    2727  end;
    2828
     
    3333    procedure Assign(Source: TValue); override;
    3434    function GetString: string; override;
    35     function SetString(Value: string): string; override;
     35    procedure SetString(Value: string); override;
     36  end;
     37
     38  { TValueDate }
     39
     40  TValueDate = class(TValueDateTime)
     41  end;
     42
     43  { TValueTime }
     44
     45  TValueTime = class(TValueDateTime)
    3646  end;
    3747
     
    4252    procedure Assign(Source: TValue); override;
    4353    function GetString: string; override;
    44     function SetString(Value: string): string; override;
     54    procedure SetString(Value: string); override;
    4555  end;
    4656
     
    5161    procedure Assign(Source: TValue); override;
    5262    function GetString: string; override;
    53     function SetString(Value: string): string; override;
     63    procedure SetString(Value: string); override;
     64  end;
     65
     66  { TValueReference }
     67
     68  TValueReference = class(TValueInteger)
    5469  end;
    5570
     
    94109    Min: TDate;
    95110    Max: TDate;
    96   end;
     111    procedure Assign(Source: TFieldTypeSpecific); override;
     112    function GetValueClass: TValueClass; override;
     113  end;
     114
     115  { TFieldTime }
    97116
    98117  TFieldTime = class(TFieldTypeSpecific)
    99118    Min: TTime;
    100119    Max: TTime;
     120    procedure Assign(Source: TFieldTypeSpecific); override;
     121    function GetValueClass: TValueClass; override;
    101122  end;
    102123
     
    106127  end;
    107128
     129  { TFieldReference }
     130
     131  TFieldReference = class(TFieldTypeSpecific)
     132    TableName: string;
     133    Id: Integer;
     134    procedure Assign(Source: TFieldTypeSpecific); override;
     135    function GetValueClass: TValueClass; override;
     136  end;
     137
    108138  { TFieldBoolean }
    109139
     
    120150implementation
    121151
     152{ TFieldReference }
     153
     154procedure TFieldReference.Assign(Source: TFieldTypeSpecific);
     155begin
     156  if Source is TFieldReference then begin
     157    Id := TFieldReference(Source).Id;
     158    TableName := TFieldReference(Source).TableName;
     159  end;
     160end;
     161
     162function TFieldReference.GetValueClass: TValueClass;
     163begin
     164  Result := TValueReference;
     165end;
     166
     167{ TFieldTime }
     168
     169procedure TFieldTime.Assign(Source: TFieldTypeSpecific);
     170begin
     171  if Source is TFieldTime then begin
     172    Min := TFieldTime(Source).Min;
     173    Max := TFieldTime(Source).Max;
     174  end;
     175end;
     176
     177function TFieldTime.GetValueClass: TValueClass;
     178begin
     179  Result := TValueTime;
     180end;
     181
     182{ TFieldDate }
     183
     184procedure TFieldDate.Assign(Source: TFieldTypeSpecific);
     185begin
     186  if Source is TFieldDate then begin
     187    Min := TFieldDate(Source).Min;
     188    Max := TFieldDate(Source).Max;
     189  end;
     190end;
     191
     192function TFieldDate.GetValueClass: TValueClass;
     193begin
     194  Result := TValueDate;
     195end;
     196
    122197
    123198{ TValueFloat }
     
    134209end;
    135210
    136 function TValueFloat.SetString(Value: string): string;
     211procedure TValueFloat.SetString(Value: string);
    137212begin
    138213  Self.Value := StrToFloat(Value);
     
    198273end;
    199274
    200 function TValueBoolean.SetString(Value: string): string;
     275procedure TValueBoolean.SetString(Value: string);
    201276begin
    202277  Self.Value := StrToBool(Value);
     
    216291end;
    217292
    218 function TValueInteger.SetString(Value: string): string;
    219 begin
    220   Self.Value := StrToInt(Value);
     293procedure TValueInteger.SetString(Value: string);
     294var
     295  IntVal: Integer;
     296begin
     297  if TryStrToInt(Value, IntVal) then Self.Value := IntVal;
    221298end;
    222299
     
    225302procedure TFieldDateTime.Assign(Source: TFieldTypeSpecific);
    226303begin
    227   if Source is TFieldDate then begin
    228     Min := TFieldDate(Source).Min;
    229     Max := TFieldDate(Source).Max;
     304  if Source is TFieldDateTime then begin
     305    Min := TFieldDateTime(Source).Min;
     306    Max := TFieldDateTime(Source).Max;
    230307  end;
    231308end;
     
    249326end;
    250327
    251 function TValueDateTime.SetString(Value: string): string;
    252 begin
    253   Self.Value := StrToDateTime(Value);
     328procedure TValueDateTime.SetString(Value: string);
     329begin
     330  Self.Value := SQLToDateTime(Value);
     331//  if not TryStrToDateTime(Value, Self.Value) then begin
     332//  end;
    254333end;
    255334
     
    267346end;
    268347
    269 function TValueString.SetString(Value: string): string;
     348procedure TValueString.SetString(Value: string);
    270349begin
    271350  Self.Value := Value;
  • trunk/UDatabase.pas

    r13 r14  
    1717
    1818  TFieldType = (ftString, ftInteger, ftDateTime, ftBoolean, ftFloat, ftImage,
    19     ftDate, ftTime, ftMapPosition);
     19    ftDate, ftTime, ftMapPosition, ftReference);
    2020
    2121  { TValue }
     
    2424    procedure Assign(Source: TValue); virtual;
    2525    function GetString: string; virtual;
    26     function SetString(Value: string): string; virtual;
     26    procedure SetString(Value: string); virtual;
     27    function GetStringSQL: string; virtual;
     28    procedure SetStringSQL(Value: string); virtual;
    2729  end;
    2830
     
    151153    Id: Integer;
    152154    Name: string;
     155    Title: string;
    153156    FieldType: TFieldType;
    154157    FieldTypeClass: TFieldTypeSpecificClass;
     
    158161
    159162  TDataTypes = class(TObjectList)
    160     function RegisterType(Id: Integer; Name: string; FieldType: TFieldType; FieldTypeClass: TFieldTypeSpecificClass): TDataType;
     163    function RegisterType(Id: Integer; Name, Title: string;
     164      FieldType: TFieldType; FieldTypeClass: TFieldTypeSpecificClass): TDataType;
    161165    function FindByType(FieldType: TFieldType): TDataType;
     166    function FindByName(Name: string): TDataType;
    162167  end;
    163168
     
    272277{ TDataTypes }
    273278
    274 function TDataTypes.RegisterType(Id: Integer; Name: string; FieldType: TFieldType;
    275   FieldTypeClass: TFieldTypeSpecificClass): TDataType;
     279function TDataTypes.RegisterType(Id: Integer; Name, Title: string;
     280  FieldType: TFieldType; FieldTypeClass: TFieldTypeSpecificClass): TDataType;
    276281begin
    277282  Result := TDataType.Create;
    278283  Result.Id := Id;
    279284  Result.Name := Name;
     285  Result.Title := Title;
    280286  Result.FieldType := FieldType;
    281287  Result.FieldTypeClass := FieldTypeClass;
     
    289295  I := 0;
    290296  while (I < Count) and (TDataType(Items[I]).FieldType <> FieldType) do Inc(I);
     297  if I < Count then Result := TDataType(Items[I])
     298    else Result := nil;
     299end;
     300
     301function TDataTypes.FindByName(Name: string): TDataType;
     302var
     303  I: Integer;
     304begin
     305  I := 0;
     306  while (I < Count) and (TDataType(Items[I]).Name <> Name) do Inc(I);
    291307  if I < Count then Result := TDataType(Items[I])
    292308    else Result := nil;
     
    408424end;
    409425
    410 function TValue.SetString(Value: string): string;
    411 begin
    412 
     426procedure TValue.SetString(Value: string);
     427begin
     428
     429end;
     430
     431function TValue.GetStringSQL: string;
     432begin
     433  Result := '';
     434end;
     435
     436procedure TValue.SetStringSQL(Value: string);
     437begin
    413438end;
    414439
     
    470495  NewRecord: TRecord;
    471496  NewValue: TValue;
     497  Index: Integer;
    472498begin
    473499  Records.Clear;
     
    478504    for F := 0 to Fields.Count - 1 do begin
    479505      NewValue := TField(Fields[F]).GetValueClass.Create;
    480       NewValue.SetString(TDictionaryStringString(DbRows[I]).Values[TField(Fields[F]).Name]);
    481       NewRecord.Values.Add(NewValue);
     506      Index := TDictionaryStringString(DbRows[I]).SearchKey(TField(Fields[F]).Name);
     507      if Index <> -1 then begin
     508        NewValue.SetString(TDictionaryStringString(DbRows[I]).Values[TField(Fields[F]).Name]);
     509        NewRecord.Values.Add(NewValue);
     510      end else begin
     511        //NewValue.SetString('');
     512        NewRecord.Values.Add(NewValue);
     513      end;
    482514    end;
    483515    Records.Add(NewRecord);
Note: See TracChangeset for help on using the changeset viewer.