source: trunk/Modules/Attendance/UModuleAttendance.pas

Last change on this file was 4, checked in by chronos, 12 years ago
File size: 12.5 KB
Line 
1unit UModuleAttendance;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, UModularSystem, UFormList, UFormEdit, Controls,
9 SpecializedList, Forms, ActnList, UDataModel;
10
11type
12
13 { TDataModuleAttendance }
14
15 TDataModuleAttendance = class(TDataModule)
16 AReadFromTerminal: TAction;
17 ActionList1: TActionList;
18 procedure AReadFromTerminalExecute(Sender: TObject);
19 private
20 { private declarations }
21 public
22 { public declarations }
23 end;
24
25 { TModuleAttendance }
26
27 TModuleAttendance = class(TModule)
28 private
29 ModelLog: TDataModel;
30 ViewFormLog: TDataViewForm;
31 ViewListLog: TDataViewList;
32 ModelTerminal: TDataModel;
33 ViewFormTerminal: TDataViewForm;
34 ViewListTerminal: TDataViewList;
35 ModelOperation: TDataModel;
36 ViewFormOperation: TDataViewForm;
37 ViewListOperation: TDataViewList;
38 ModelAttendance: TDataModel;
39 ViewFormAttendance: TDataViewForm;
40 ViewListAttendance: TDataViewList;
41 ModelHoliday: TDataModel;
42 ViewFormHoliday: TDataViewForm;
43 ViewListHoliday: TDataViewList;
44 ModelPassage: TDataModel;
45 ViewFormPassage: TDataViewForm;
46 ViewListPassage: TDataViewList;
47 ModelUser: TDataModel;
48 ViewFormUser: TDataViewForm;
49 ViewListUser: TDataViewList;
50 procedure InitModels;
51 protected
52 procedure DoStart; override;
53 procedure DoStop; override;
54 procedure DoInstall; override;
55 procedure DoUninstall; override;
56 public
57 constructor Create(Owner: TComponent); override;
58 destructor Destroy; override;
59 end;
60
61
62var
63 DataModuleAttendance: TDataModuleAttendance;
64
65implementation
66
67{$R *.lfm}
68
69uses
70 UFormMain, UCore;
71
72resourcestring
73 SAttendance = 'Attendance';
74 SPersonalId = 'Personal Id';
75 SFirstName = 'First name';
76 SSecondName = 'Second name';
77 SEnabled = 'Enabled';
78 SAddress = 'Address';
79 SPort = 'Port';
80 SType = 'Type';
81 SName = 'Name';
82 SFingerPrint = 'Fingerprint';
83 SCardCode = 'Card code';
84 SNote = 'Note';
85 SLogin = 'Login';
86 SPassword = 'Password';
87 STerminal = 'Terminal';
88 SUser = 'User';
89 SDate = 'Date';
90 STime = 'Time';
91 SOperation = 'Operation';
92 SDay = 'Day';
93 SMonth = 'Month';
94 SYear = 'Year';
95 SKeyNumber = 'Key number';
96 SText = 'Text';
97 SPassage = 'Passage';
98 STimeFrom = 'Time from';
99 STimeTo = 'Time to';
100 SHoliday = 'Holiday';
101 SLog = 'Log';
102
103{ TDataModuleAttendance }
104
105procedure TDataModuleAttendance.AReadFromTerminalExecute(Sender: TObject);
106begin
107
108end;
109
110
111{ TModuleAttendance }
112
113procedure TModuleAttendance.InitModels;
114var
115 NewDataView: TDataViewList;
116 NewDataView2: TDataViewForm;
117 NewModel: TDataModel;
118begin
119 ModelUser := TDataModel.Create;
120 with ModelUser do begin
121 with Items do begin
122 AddItem(SEnabled, 'Enabled', dtBoolean);
123 AddItem(SPersonalId, 'PersonalId', dtString);
124 AddItem(SLogin, 'Login', dtString);
125 AddItem(SPassword, 'Password', dtString);
126 AddItem(SFirstName, 'FirstName', dtString);
127 AddItem(SSecondName, 'SecondName', dtString);
128 AddItem(SCardCode, 'CardCode', dtString);
129 AddItem(SFingerPrint, 'FingerPrint', dtString);
130 AddItem(SNote, 'Note', dtText);
131 end;
132 Name := 'User';
133 Caption := SUser;
134 end;
135 ViewListUser := TDataViewList.Create;
136 with ViewListUser do begin
137 with Columns do begin
138 AddItem(SEnabled, 'Enabled', True, 30);
139 AddItem(SPersonalId, 'PersonalId', True, 80);
140 AddItem(SLogin, 'Login', False, 80);
141 AddItem(SPassword, 'Password', False, 80);
142 AddItem(SFirstName, 'FirstName', True, 80);
143 AddItem(SSecondName, 'SecondName', True, 80);
144 AddItem(SCardCode, 'CardCode', True, 80);
145 AddItem(SFingerPrint, 'FingerPrint', True, 80);
146 AddItem(SNote, 'Note', False, 80);
147 end;
148 Name := 'User';
149 Caption := SUser;
150 ImageIndex := 9;
151 end;
152 FormMain.RegisterDataViewList(ViewListUser);
153 ViewFormUser := TDataViewForm.Create;
154 with ViewFormUser do begin
155 Name := 'User';
156 Caption := SUser;
157 with Items do begin
158 AddItem(SEnabled, 'Enabled', ctCheckBox, True, Bounds(1, 0, 1, 1));
159 AddItem(SPersonalId, 'PersonalId', ctSpinEdit, True, Bounds(3, 0, 1, 1));
160 AddItem(SLogin, 'Login', ctEdit, True, Bounds(1, 1, 1, 1));
161 AddItem(SPassword, 'Password', ctEdit, True, Bounds(3, 1, 1, 1));
162 AddItem(SFirstName, 'FirstName', ctEdit, True, Bounds(1, 2, 1, 1));
163 AddItem(SSecondName, 'SecondName', ctEdit, True, Bounds(3, 2, 1, 1));
164 AddItem(SCardCode, 'CardCode', ctEdit, True, Bounds(1, 3, 1, 1));
165 AddItem(SFingerPrint, 'FingerPrint', ctEdit, True, Bounds(3, 3, 1, 1));
166 AddItem(SNote, 'Note', ctMemo, True, Bounds(0, 5, 4, 4), alTop);
167 end;
168 end;
169 FormMain.RegisterDataViewForm(ViewFormUser);
170
171 ViewListPassage := TDataViewList.Create;
172 with ViewListPassage do begin
173 with Columns do begin
174 AddItem(STime, 'Time', True, 150);
175 AddItem(SUser, 'User', True, 80);
176 AddItem(SOperation, 'Operation', True, 80);
177 AddItem(STerminal, 'Terminal', True, 80);
178 end;
179 Name := 'Passage';
180 Caption := SPassage;
181 ImageIndex := 12;
182 end;
183 FormMain.RegisterDataViewList(ViewListPassage);
184 ViewFormPassage := TDataViewForm.Create;
185 with ViewFormPassage do begin
186 with Items do begin
187 AddItem(STime, 'Time', ctDateTime, True, Bounds(1, 0, 1, 1));
188 with AddItem(SUser, 'User', ctReference, True, Bounds(3, 0, 1, 1)) do
189 ReferencedTable := 'User';
190 with AddItem(SOperation, 'Operation', ctReference, True, Bounds(1, 1, 1, 1)) do
191 ReferencedTable := 'Operation';
192 with AddItem(STerminal, 'Terminal', ctReference, True, Bounds(3, 1, 1, 1)) do
193 ReferencedTable := 'Terminal';
194 end;
195 Name := 'Passage';
196 Caption := SPassage;
197 ImageIndex := 12;
198 end;
199 FormMain.RegisterDataViewForm(ViewFormPassage);
200
201 ViewListAttendance := TDataViewList.Create;
202 with ViewListAttendance do begin
203 with Columns do begin
204 AddItem(SDate, 'Date', True, 80);
205 AddItem(SUser, 'User', True, 80);
206 AddItem(STimeFrom, 'TimeFrom', True, 120);
207 AddItem(STimeTo, 'TimeTo', True, 120);
208 end;
209 Name := 'Attendance';
210 Caption := SAttendance;
211 ImageIndex := 14;
212 end;
213 FormMain.RegisterDataViewList(ViewListAttendance);
214 ViewFormAttendance := TDataViewForm.Create;
215 with ViewFormAttendance do begin
216 with Items do begin
217 AddItem(SUser, 'User', ctReference, True, Bounds(1, 0, 1, 1));
218 AddItem(SDate, 'Date', ctDate, True, Bounds(3, 0, 1, 1));
219 AddItem(STimeFrom, 'TimeFrom', ctTime, True, Bounds(1, 1, 1, 1));
220 AddItem(STimeTo, 'TimeTo', ctTime, True, Bounds(3, 1, 1, 1));
221 end;
222 Name := 'Attendance';
223 Caption := SAttendance;
224 ImageIndex := 14;
225 end;
226 FormMain.RegisterDataViewForm(ViewFormAttendance);
227
228 ViewListHoliday := TDataViewList.Create;
229 with ViewListHoliday do begin
230 with Columns do begin
231 AddItem(SEnabled, 'Enabled', True, 30);
232 AddItem(SName, 'Name', True, 300);
233 AddItem(SDay, 'Day', True, 50);
234 AddItem(SMonth, 'Month', True, 50);
235 AddItem(SYear, 'Year', True, 50);
236 end;
237 Name := 'Holiday';
238 Caption := SHoliday;
239 ImageIndex := 10;
240 end;
241 FormMain.RegisterDataViewList(ViewListHoliday);
242 ViewFormHoliday := TDataViewForm.Create;
243 with ViewFormHoliday do begin
244 with Items do begin
245 AddItem(SEnabled, 'Enabled', ctCheckBox, True, Bounds(1, 0, 1, 1));
246 AddItem(SName, 'Name', ctEdit, True, Bounds(3, 0, 1, 1));
247 AddItem(SDay, 'Day', ctSpinEdit, True, Bounds(1, 1, 1, 1));
248 AddItem(SMonth, 'Month', ctSpinEdit, True, Bounds(3, 1, 1, 1));
249 AddItem(SYear, 'Year', ctSpinEdit, True, Bounds(1, 2, 1, 1));
250 end;
251 Name := 'Holiday';
252 Caption := SHoliday;
253 ImageIndex := 10;
254 end;
255 FormMain.RegisterDataViewForm(ViewFormHoliday);
256
257 ViewListOperation := TDataViewList.Create;
258 with ViewListOperation do begin
259 with Columns do begin
260 AddItem(SName, 'Name', True, 100);
261 AddItem(SKeyNumber, 'KeyId', True, 100);
262 end;
263 Name := 'Operation';
264 Caption := SOperation;
265 ImageIndex := 13;
266 end;
267 FormMain.RegisterDataViewList(ViewListOperation);
268 ViewFormOperation := TDataViewForm.Create;
269 with ViewFormOperation do begin
270 with Items do begin
271 AddItem(SName, 'Name', ctEdit, True, Bounds(1, 0, 1, 1));
272 AddItem(SKeyNumber, 'KeyId', ctEdit, True, Bounds(3, 0, 1, 1));
273 end;
274 Name := 'Operation';
275 Caption := SOperation;
276 ImageIndex := 13;
277 end;
278 FormMain.RegisterDataViewForm(ViewFormOperation);
279
280 ViewListTerminal := TDataViewList.Create;
281 with ViewListTerminal do begin
282 with Columns do begin
283 AddItem(SName, 'Name', True, 80);
284 AddItem(SEnabled, 'Enabled', True, 30);
285 AddItem(SAddress, 'Address', True, 120);
286 AddItem(SPort, 'Port', True, 50);
287 with AddItem(SType, 'Type', True, 80) do
288 ReferencedTable := 'TerminalType';
289 AddItem(SNote, 'Note', True, 80);
290 end;
291 Name := 'Terminal';
292 Caption := STerminal;
293 ImageIndex := 8;
294 end;
295 FormMain.RegisterDataViewList(ViewListTerminal);
296 ViewFormTerminal := TDataViewForm.Create;
297 with ViewFormTerminal do begin
298 with Items do begin
299 AddItem(SName, 'Name', ctEdit, True, Bounds(1, 0, 1, 1));
300 AddItem(SEnabled, 'Enabled', ctCheckBox, True, Bounds(3, 0, 1, 1));
301 AddItem(SAddress, 'Address', ctEdit, True, Bounds(1, 1, 1, 1));
302 AddItem(SPort, 'Port', ctSpinEdit, True, Bounds(3, 1, 1, 1));
303 with AddItem(SType, 'Type', ctReference, True, Bounds(1, 2, 1, 1)) do
304 ReferencedTable := 'TerminalType';
305 AddItem(SNote, 'Note', ctMemo, True, Bounds(0, 4, 4, 4), alTop);
306 end;
307 Name := 'Terminal';
308 Caption := STerminal;
309 ImageIndex := 8;
310 end;
311 FormMain.RegisterDataViewForm(ViewFormTerminal);
312
313 ViewListLog := TDataViewList.Create;
314 with ViewListLog do begin
315 with Columns do begin
316 AddItem(STime, 'Time', True, 120);
317 AddItem(SUser, 'User', True, 80);
318 AddItem(SText, 'Text', True, 400);
319 end;
320 Name := 'Log';
321 Caption := SLog;
322 ImageIndex := 11;
323 end;
324 FormMain.RegisterDataViewList(ViewListLog);
325 ViewFormLog := TDataViewForm.Create;
326 with ViewFormLog do begin
327 with Items do begin
328 AddItem(STime, 'Time', ctDateTime, True, Bounds(1, 0, 1, 1));
329 AddItem(SUser, 'User', ctReference, True, Bounds(3, 0, 1, 1));
330 AddItem(SText, 'Text', ctEdit, True, Bounds(1, 1, 1, 1));
331 end;
332 Name := 'Log';
333 Caption := SLog;
334 ImageIndex := 11;
335 end;
336 FormMain.RegisterDataViewForm(ViewFormLog);
337end;
338
339procedure TModuleAttendance.DoStart;
340begin
341 inherited DoStart;
342 Application.Title := SAttendance;
343 FormMain.Caption := SAttendance;
344 DataModuleAttendance := TDataModuleAttendance.Create(FormMain);
345 InitModels;
346end;
347
348procedure TModuleAttendance.DoStop;
349begin
350 FreeAndNil(ModelUser);
351 FormMain.UnregisterDataViewList(ViewListUser);
352 FreeAndNil(ViewListUser);
353 FormMain.UnregisterDataViewForm(ViewFormUser);
354 FreeAndNil(ViewFormUser);
355 FormMain.UnregisterDataViewList(ViewListAttendance);
356 FreeAndNil(ViewListAttendance);
357 FormMain.UnregisterDataViewForm(ViewFormAttendance);
358 FreeAndNil(ViewFormAttendance);
359 FormMain.UnregisterDataViewList(ViewListHoliday);
360 FreeAndNil(ViewListHoliday);
361 FormMain.UnregisterDataViewForm(ViewFormHoliday);
362 FreeAndNil(ViewFormHoliday);
363 FormMain.UnregisterDataViewList(ViewListLog);
364 FreeAndNil(ViewListLog);
365 FormMain.UnregisterDataViewForm(ViewFormLog);
366 FreeAndNil(ViewFormLog);
367 FormMain.UnregisterDataViewList(ViewListOperation);
368 FreeAndNil(ViewListOperation);
369 FormMain.UnregisterDataViewForm(ViewFormOperation);
370 FreeAndNil(ViewFormOperation);
371 FormMain.UnregisterDataViewList(ViewListPassage);
372 FreeAndNil(ViewListPassage);
373 FormMain.UnregisterDataViewForm(ViewFormPassage);
374 FreeAndNil(ViewFormPassage);
375 FormMain.UnregisterDataViewList(ViewListTerminal);
376 FreeAndNil(ViewListTerminal);
377 FormMain.UnregisterDataViewForm(ViewFormTerminal);
378 FreeAndNil(ViewFormTerminal);
379 FreeAndNil(DataModuleAttendance);
380 inherited DoStop;
381end;
382
383procedure TModuleAttendance.DoInstall;
384begin
385 inherited DoInstall;
386end;
387
388procedure TModuleAttendance.DoUninstall;
389begin
390 inherited DoUninstall;
391end;
392
393constructor TModuleAttendance.Create(Owner: TComponent);
394begin
395 inherited Create(Owner);
396 Identification := 'Attendance';
397 Title := SAttendance;
398 Author := 'Chronos';
399 License:= 'GNU/LGPLv3';
400end;
401
402destructor TModuleAttendance.Destroy;
403begin
404 inherited Destroy;
405end;
406
407end.
408
Note: See TracBrowser for help on using the repository browser.