Changeset 14 for trunk/UDataTypes.pas
- Timestamp:
- Mar 22, 2018, 7:59:13 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UDataTypes.pas
r13 r14 6 6 7 7 uses 8 Classes, SysUtils, UDatabase, Contnrs ;8 Classes, SysUtils, UDatabase, Contnrs, USqlDatabase; 9 9 10 10 type … … 15 15 procedure Assign(Source: TValue); override; 16 16 function GetString: string; override; 17 function SetString(Value: string): string; override;17 procedure SetString(Value: string); override; 18 18 end; 19 19 … … 24 24 procedure Assign(Source: TValue); override; 25 25 function GetString: string; override; 26 function SetString(Value: string): string; override;26 procedure SetString(Value: string); override; 27 27 end; 28 28 … … 33 33 procedure Assign(Source: TValue); override; 34 34 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) 36 46 end; 37 47 … … 42 52 procedure Assign(Source: TValue); override; 43 53 function GetString: string; override; 44 function SetString(Value: string): string; override;54 procedure SetString(Value: string); override; 45 55 end; 46 56 … … 51 61 procedure Assign(Source: TValue); override; 52 62 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) 54 69 end; 55 70 … … 94 109 Min: TDate; 95 110 Max: TDate; 96 end; 111 procedure Assign(Source: TFieldTypeSpecific); override; 112 function GetValueClass: TValueClass; override; 113 end; 114 115 { TFieldTime } 97 116 98 117 TFieldTime = class(TFieldTypeSpecific) 99 118 Min: TTime; 100 119 Max: TTime; 120 procedure Assign(Source: TFieldTypeSpecific); override; 121 function GetValueClass: TValueClass; override; 101 122 end; 102 123 … … 106 127 end; 107 128 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 108 138 { TFieldBoolean } 109 139 … … 120 150 implementation 121 151 152 { TFieldReference } 153 154 procedure TFieldReference.Assign(Source: TFieldTypeSpecific); 155 begin 156 if Source is TFieldReference then begin 157 Id := TFieldReference(Source).Id; 158 TableName := TFieldReference(Source).TableName; 159 end; 160 end; 161 162 function TFieldReference.GetValueClass: TValueClass; 163 begin 164 Result := TValueReference; 165 end; 166 167 { TFieldTime } 168 169 procedure TFieldTime.Assign(Source: TFieldTypeSpecific); 170 begin 171 if Source is TFieldTime then begin 172 Min := TFieldTime(Source).Min; 173 Max := TFieldTime(Source).Max; 174 end; 175 end; 176 177 function TFieldTime.GetValueClass: TValueClass; 178 begin 179 Result := TValueTime; 180 end; 181 182 { TFieldDate } 183 184 procedure TFieldDate.Assign(Source: TFieldTypeSpecific); 185 begin 186 if Source is TFieldDate then begin 187 Min := TFieldDate(Source).Min; 188 Max := TFieldDate(Source).Max; 189 end; 190 end; 191 192 function TFieldDate.GetValueClass: TValueClass; 193 begin 194 Result := TValueDate; 195 end; 196 122 197 123 198 { TValueFloat } … … 134 209 end; 135 210 136 function TValueFloat.SetString(Value: string): string;211 procedure TValueFloat.SetString(Value: string); 137 212 begin 138 213 Self.Value := StrToFloat(Value); … … 198 273 end; 199 274 200 function TValueBoolean.SetString(Value: string): string;275 procedure TValueBoolean.SetString(Value: string); 201 276 begin 202 277 Self.Value := StrToBool(Value); … … 216 291 end; 217 292 218 function TValueInteger.SetString(Value: string): string; 219 begin 220 Self.Value := StrToInt(Value); 293 procedure TValueInteger.SetString(Value: string); 294 var 295 IntVal: Integer; 296 begin 297 if TryStrToInt(Value, IntVal) then Self.Value := IntVal; 221 298 end; 222 299 … … 225 302 procedure TFieldDateTime.Assign(Source: TFieldTypeSpecific); 226 303 begin 227 if Source is TFieldDate then begin228 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; 230 307 end; 231 308 end; … … 249 326 end; 250 327 251 function TValueDateTime.SetString(Value: string): string; 252 begin 253 Self.Value := StrToDateTime(Value); 328 procedure TValueDateTime.SetString(Value: string); 329 begin 330 Self.Value := SQLToDateTime(Value); 331 // if not TryStrToDateTime(Value, Self.Value) then begin 332 // end; 254 333 end; 255 334 … … 267 346 end; 268 347 269 function TValueString.SetString(Value: string): string;348 procedure TValueString.SetString(Value: string); 270 349 begin 271 350 Self.Value := Value;
Note:
See TracChangeset
for help on using the changeset viewer.