source: trunk/DataTypes.pas

Last change on this file was 32, checked in by chronos, 6 months ago
  • Modified: Removed U prefix from units names.
  • Modified: Use TFormEx for all forms.
File size: 7.4 KB
Line 
1unit DataTypes;
2
3interface
4
5uses
6 Classes, SysUtils, DbEngine, USqlDatabase;
7
8type
9 { TValueString }
10
11 TValueString = class(TValue)
12 Value: string;
13 procedure Assign(Source: TValue); override;
14 function GetString: string; override;
15 procedure SetString(Value: string); override;
16 end;
17
18 { TValueInteger }
19
20 TValueInteger = class(TValue)
21 Value: Integer;
22 procedure Assign(Source: TValue); override;
23 function GetString: string; override;
24 procedure SetString(Value: string); override;
25 end;
26
27 { TValueDateTime }
28
29 TValueDateTime = class(TValue)
30 Value: TDateTime;
31 procedure Assign(Source: TValue); override;
32 function GetString: string; override;
33 procedure SetString(Value: string); override;
34 end;
35
36 { TValueDate }
37
38 TValueDate = class(TValueDateTime)
39 end;
40
41 { TValueTime }
42
43 TValueTime = class(TValueDateTime)
44 end;
45
46 { TValueBoolean }
47
48 TValueBoolean = class(TValue)
49 Value: Boolean;
50 procedure Assign(Source: TValue); override;
51 function GetString: string; override;
52 procedure SetString(Value: string); override;
53 end;
54
55 { TValueFloat }
56
57 TValueFloat = class(TValue)
58 Value: Double;
59 procedure Assign(Source: TValue); override;
60 function GetString: string; override;
61 procedure SetString(Value: string); override;
62 end;
63
64 { TValueReference }
65
66 TValueReference = class(TValueInteger)
67 end;
68
69 { TFieldString }
70
71 TFieldString = class(TFieldTypeSpecific)
72 DefaultValue: string;
73 procedure Assign(Source: TFieldTypeSpecific); override;
74 function GetValueClass: TValueClass; override;
75 end;
76
77 { TFieldInteger }
78
79 TFieldInteger = class(TFieldTypeSpecific)
80 Min: Integer;
81 Max: Integer;
82 DefaultValue: Integer;
83 procedure Assign(Source: TFieldTypeSpecific); override;
84 function GetValueClass: TValueClass; override;
85 end;
86
87 { TFieldFloat }
88
89 TFieldFloat = class(TFieldTypeSpecific)
90 Min: Double;
91 Max: Double;
92 DefaultValue: Double;
93 procedure Assign(Source: TFieldTypeSpecific); override;
94 function GetValueClass: TValueClass; override;
95 end;
96
97 { TFieldDateTime }
98
99 TFieldDateTime = class(TFieldTypeSpecific)
100 Min: TDateTime;
101 Max: TDateTime;
102 procedure Assign(Source: TFieldTypeSpecific); override;
103 function GetValueClass: TValueClass; override;
104 end;
105
106 TFieldDate = class(TFieldTypeSpecific)
107 Min: TDate;
108 Max: TDate;
109 procedure Assign(Source: TFieldTypeSpecific); override;
110 function GetValueClass: TValueClass; override;
111 end;
112
113 { TFieldTime }
114
115 TFieldTime = class(TFieldTypeSpecific)
116 Min: TTime;
117 Max: TTime;
118 procedure Assign(Source: TFieldTypeSpecific); override;
119 function GetValueClass: TValueClass; override;
120 end;
121
122 TFieldImage = class(TFieldTypeSpecific)
123 MinSize: TPoint;
124 MaxSize: TPoint;
125 end;
126
127 { TFieldReference }
128
129 TFieldReference = class(TFieldTypeSpecific)
130 TableName: string;
131 Id: Integer;
132 procedure Assign(Source: TFieldTypeSpecific); override;
133 function GetValueClass: TValueClass; override;
134 end;
135
136 { TFieldBoolean }
137
138 TFieldBoolean = class(TFieldTypeSpecific)
139 DefaultValue: Boolean;
140 procedure Assign(Source: TFieldTypeSpecific); override;
141 function GetValueClass: TValueClass; override;
142 end;
143
144 TFieldMapPosition = class(TFieldTypeSpecific)
145 end;
146
147
148implementation
149
150{ TFieldReference }
151
152procedure TFieldReference.Assign(Source: TFieldTypeSpecific);
153begin
154 if Source is TFieldReference then begin
155 Id := TFieldReference(Source).Id;
156 TableName := TFieldReference(Source).TableName;
157 end;
158end;
159
160function TFieldReference.GetValueClass: TValueClass;
161begin
162 Result := TValueReference;
163end;
164
165{ TFieldTime }
166
167procedure TFieldTime.Assign(Source: TFieldTypeSpecific);
168begin
169 if Source is TFieldTime then begin
170 Min := TFieldTime(Source).Min;
171 Max := TFieldTime(Source).Max;
172 end;
173end;
174
175function TFieldTime.GetValueClass: TValueClass;
176begin
177 Result := TValueTime;
178end;
179
180{ TFieldDate }
181
182procedure TFieldDate.Assign(Source: TFieldTypeSpecific);
183begin
184 if Source is TFieldDate then begin
185 Min := TFieldDate(Source).Min;
186 Max := TFieldDate(Source).Max;
187 end;
188end;
189
190function TFieldDate.GetValueClass: TValueClass;
191begin
192 Result := TValueDate;
193end;
194
195{ TValueFloat }
196
197procedure TValueFloat.Assign(Source: TValue);
198begin
199 if Source is TValueFloat then
200 Value := TValueFloat(Source).Value;
201end;
202
203function TValueFloat.GetString: string;
204begin
205 Result := FloatToStr(Value);
206end;
207
208procedure TValueFloat.SetString(Value: string);
209begin
210 Self.Value := StrToFloat(Value);
211end;
212
213{ TFieldBoolean }
214
215procedure TFieldBoolean.Assign(Source: TFieldTypeSpecific);
216begin
217 if Source is TFieldBoolean then begin
218 DefaultValue := TFieldBoolean(Source).DefaultValue;
219 end;
220end;
221
222function TFieldBoolean.GetValueClass: TValueClass;
223begin
224 Result := TValueBoolean;
225end;
226
227{ TFieldFloat }
228
229procedure TFieldFloat.Assign(Source: TFieldTypeSpecific);
230begin
231 if Source is TFieldFloat then begin
232 DefaultValue:= TFieldFloat(Source).DefaultValue;
233 Min:= TFieldFloat(Source).Min;
234 Max:= TFieldFloat(Source).Max;
235 end;
236end;
237
238function TFieldFloat.GetValueClass: TValueClass;
239begin
240 Result := TValueFloat;
241end;
242
243{ TFieldInteger }
244
245procedure TFieldInteger.Assign(Source: TFieldTypeSpecific);
246begin
247 if Source is TFieldInteger then begin
248 DefaultValue:= TFieldInteger(Source).DefaultValue;
249 Min:= TFieldInteger(Source).Min;
250 Max:= TFieldInteger(Source).Max;
251 end;
252end;
253
254function TFieldInteger.GetValueClass: TValueClass;
255begin
256 Result := TValueInteger;
257end;
258
259{ TValueBoolean }
260
261procedure TValueBoolean.Assign(Source: TValue);
262begin
263 if Source is TValueBoolean then
264 Value := TValueBoolean(Source).Value;
265end;
266
267function TValueBoolean.GetString: string;
268begin
269 Result := BoolToStr(Value);
270end;
271
272procedure TValueBoolean.SetString(Value: string);
273begin
274 Self.Value := StrToBool(Value);
275end;
276
277{ TValueInteger }
278
279procedure TValueInteger.Assign(Source: TValue);
280begin
281 if Source is TValueInteger then
282 Value := TValueInteger(Source).Value;
283end;
284
285function TValueInteger.GetString: string;
286begin
287 Result := IntToStr(Value);
288end;
289
290procedure TValueInteger.SetString(Value: string);
291var
292 IntVal: Integer;
293begin
294 if TryStrToInt(Value, IntVal) then Self.Value := IntVal;
295end;
296
297{ TFieldDateTime }
298
299procedure TFieldDateTime.Assign(Source: TFieldTypeSpecific);
300begin
301 if Source is TFieldDateTime then begin
302 Min := TFieldDateTime(Source).Min;
303 Max := TFieldDateTime(Source).Max;
304 end;
305end;
306
307function TFieldDateTime.GetValueClass: TValueClass;
308begin
309 Result := TValueDateTime;
310end;
311
312{ TValueDateTime }
313
314procedure TValueDateTime.Assign(Source: TValue);
315begin
316 if Source is TValueDateTime then
317 Value := TValueDateTime(Source).Value;
318end;
319
320function TValueDateTime.GetString: string;
321begin
322 Result := DateTimeToStr(Value);
323end;
324
325procedure TValueDateTime.SetString(Value: string);
326begin
327 Self.Value := SQLToDateTime(Value);
328// if not TryStrToDateTime(Value, Self.Value) then begin
329// end;
330end;
331
332{ TValueString }
333
334procedure TValueString.Assign(Source: TValue);
335begin
336 if Source is TValueString then
337 Value := TValueString(Source).Value;
338end;
339
340function TValueString.GetString: string;
341begin
342 Result := Value;
343end;
344
345procedure TValueString.SetString(Value: string);
346begin
347 Self.Value := Value;
348end;
349
350{ TFieldString }
351
352procedure TFieldString.Assign(Source: TFieldTypeSpecific);
353begin
354 if Source is TFieldString then
355 DefaultValue:= TFieldString(Source).DefaultValue;
356end;
357
358function TFieldString.GetValueClass: TValueClass;
359begin
360 Result := TValueString;
361end;
362
363end.
364
Note: See TracBrowser for help on using the repository browser.