Changeset 14 for trunk/UDataTypes.pas


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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.