-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMainApplication.~pas
112 lines (95 loc) · 2.51 KB
/
MainApplication.~pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
unit MainApplication;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TOperativeUnit, ComCtrls, StdCtrls;
procedure Append(item : TElemType); stdcall
external 'LinkedList.dll' name 'Append';
procedure WriteEach; stdcall
external 'LinkedList.dll' name 'WriteEach';
procedure Seed; stdcall
external 'LinkedList.dll' name 'Seed';
procedure WriteToFile; stdcall
external 'LinkedList.dll' name 'WriteToFile';
procedure ReadFromFile; stdcall
external 'LinkedList.dll' name 'ReadFromFile';
function GetHead : PElem; stdcall
external 'LinkedList.dll' name 'GetHead';
function EqualTOperatives : PElem; stdcall
external 'LinkedList.dll' name 'EqualTOperatives';
type
TMainForm = class(TForm)
lvOperatives: TListView;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
edtFirstName: TEdit;
edtLastName: TEdit;
edtNickName: TEdit;
dtpBirthDate: TDateTimePicker;
edtBirthPlace: TEdit;
Label5: TLabel;
btnAddOperative: TButton;
procedure FormCreate(Sender: TObject);
procedure btnAddOperativeClick(Sender: TObject);
private
procedure FillListBox;
function ValidateAdd : Bool;
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
function TMainForm.ValidateAdd : Bool;
begin
Result := (Length(edtFirstName.Text) > 0) and
(Length(edtLastName.Text) > 0) and
(Length(edtNickName.Text) > 0) and
(Length(edtBirthPlace.Text) > 0);
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
ReadFromFile;
FillListBox;
end;
procedure TMainForm.FillListBox;
var
iter : PElem;
item : TListItem;
begin
lvOperatives.Items.Clear;
iter := GetHead;
while iter <> nil do
begin
item := lvOperatives.Items.Add;
item.Caption := iter^.Val.FirstName;
item.SubItems.Add(iter^.Val.LastName);
item.SubItems.Add(iter^.Val.NickName);
item.SubItems.Add(DateToStr(iter^.Val.DateOfBirth));
item.SubItems.Add(iter^.Val.BirthPlace);
iter := iter^.Next;
end;
end;
procedure TMainForm.btnAddOperativeClick(Sender: TObject);
var
row : TOperative;
begin
if not ValidateAdd then
begin
ShowMessage('Podane dane są nieprawidłowe');
Exit;
end;
row.FirstName := edtFirstName.Text;
row.LastName := edtLastName.Text;
row.NickName := edtNickName.Text;
row.DateOfBirth := dtpBirthDate.Date;
row.BirthPlace := edtBirthPlace.Text;
Append(row);
WriteToFile;
FillListBox;
end;
end.