-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainUnit.pas
220 lines (193 loc) · 6.83 KB
/
MainUnit.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
Unit MainUnit;
Interface
Uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Forms,
Vcl.Dialogs, Vcl.StdCtrls, Vcl.Menus, Vcl.ComCtrls, Vcl.ExtCtrls,
Vcl.Controls;
Type
TMainForm = Class(TForm)
MainMenu: TMainMenu;
MMHelp: TMenuItem;
LabelProgramName: TLabel;
ButtonVacancyList: TButton;
ButtonCandidateList: TButton;
ButtonExit: TButton;
MMInstruction: TMenuItem;
MMSeparator: TMenuItem;
MMProgramInfo: TMenuItem;
Procedure ButtonVacancyListClick(Sender: TObject);
Procedure ButtonCandidateListClick(Sender: TObject);
Procedure FormCloseQuery(Sender: TObject; Var CanClose: Boolean);
Procedure ButtonExitClick(Sender: TObject);
Procedure MMInstructionClick(Sender: TObject);
Procedure MMProgramInfoClick(Sender: TObject);
Procedure FormResize(Sender: TObject);
End;
Const
MAXLEN = 20;
MINSALARY = 1;
MAXSALARY = 99_999;
MINVACATION = 1;
MAXVACATION = 99;
MINWORKAGE = 14;
MAXWORKAGE = 99;
MAXRECORDAMOUNT = 100;
CANDIDATEFILEEXT = '.can';
VACANCYFILEEXT = '.vac';
NULL = #0;
BACKSPACE = #8;
Function IsFileExtCorrect(Path: String; Const EXT: String): Boolean;
Procedure ClearListView(ListView: TListView);
Procedure StrEditKeyPress(LEdit: TLabeledEdit; Var Key: Char;
Const MAXLENGTH: Integer);
Procedure IntEditKeyPress(LEdit: TLabeledEdit; Var Key: Char;
Const MAX: Integer);
Function IsNumCorrect(Value: Integer;
Const MINVALUE, MAXVALUE: Integer): Boolean;
Function IsStrEditCorrect(LEdit: TLabeledEdit): Boolean;
Function IsIntEditCorrect(LEdit: TLabeledEdit;
Const MINVALUE, MAXVALUE: Integer): Boolean;
Procedure ShowInstruction();
Procedure ShowProgramInfo();
Procedure SelectItemInListView(I: Integer; ListView: TListView);
Var
MainForm: TMainForm;
Implementation
{$R *.dfm}
Uses VacancyListUnit, CandidateListUnit;
Function IsStrEditCorrect(LEdit: TLabeledEdit): Boolean;
Begin
IsStrEditCorrect := (Length(LEdit.Text) > 0) And
(Length(LEdit.Text) < MAXLEN + 1);
End;
Function IsNumCorrect(Value: Integer;
Const MINVALUE, MAXVALUE: Integer): Boolean;
Begin
IsNumCorrect := (Value > MINVALUE - 1) And (Value < MAXVALUE + 1);
End;
Function IsIntEditCorrect(LEdit: TLabeledEdit;
Const MINVALUE, MAXVALUE: Integer): Boolean;
Var
Value: Integer;
Begin
IsIntEditCorrect := TryStrToInt(LEdit.Text, Value) And
IsNumCorrect(Value, MINVALUE, MAXVALUE);
End;
Procedure StrEditKeyPress(LEdit: TLabeledEdit; Var Key: Char;
Const MAXLENGTH: Integer);
Begin
If (Key <> BACKSPACE) And Not(Length(LEdit.Text) < MAXLENGTH) Then
Key := NULL;
End;
Procedure IntEditKeyPress(LEdit: TLabeledEdit; Var Key: Char;
Const MAX: Integer);
Begin
If (Key <> BACKSPACE) And
Not(Length(LEdit.Text) < Length(IntToStr(MAX))) Then
Key := NULL
Else If (LEdit.SelStart = 0) And (Key = '0') Then
Key := NULL
Else If (Length(LEdit.Text) > 0) And (StrToInt(LEdit.Text) = 0) And
(LEdit.SelStart <> 0) And (Key <> BACKSPACE) Then
Key := NULL;
End;
Procedure SelectItemInListView(I: Integer; ListView: TListView);
Begin
ListView.Selected := ListView.Items[I];
ListView.Items[I].MakeVisible(False);
End;
Procedure ClearListView(ListView: TListView);
Begin
While ListView.Items.Count <> 0 Do
ListView.Items[0].Delete;
End;
Procedure TMainForm.ButtonCandidateListClick(Sender: TObject);
Begin
MainForm.Visible := False;
CandidateListForm.ShowModal;
End;
Procedure TMainForm.ButtonExitClick(Sender: TObject);
Begin
Close;
End;
Procedure TMainForm.ButtonVacancyListClick(Sender: TObject);
Begin
MainForm.Visible := False;
VacancyListForm.ShowModal;
End;
Procedure TMainForm.FormCloseQuery(Sender: TObject; Var CanClose: Boolean);
Var
ButtonSelected: Integer;
Begin
If Not IsVacancyListSaved Then
Begin
ButtonSelected := Application.MessageBox
('Âû õîòèòå ñîõðàíèòü èçìåíåíèÿ â ñïèñêå âàêàíñèé?', 'Âûõîä',
MB_YESNOCANCEL + MB_ICONQUESTION);
If ButtonSelected = MrYes Then
Begin
VacancyListForm.MMSaveFile.Click;
If Not IsVacancyListSaved Then
Close;
End
Else
CanClose := IsCandidateListSaved And (ButtonSelected = MrNo);
IsVacancyListSaved := True;
End;
If Not IsCandidateListSaved Then
Begin
ButtonSelected := Application.MessageBox
('Âû õîòèòå ñîõðàíèòü èçìåíåíèÿ â ñïèñêå êàíäèäàòîâ?', 'Âûõîä',
MB_YESNOCANCEL + MB_ICONQUESTION);
If ButtonSelected = MrYes Then
Begin
CandidateListForm.MMSaveFile.Click;
If Not IsCandidateListSaved Then
Close;
End
Else
CanClose := ButtonSelected = MrNo;
IsCandidateListSaved := True;
End;
End;
Procedure TMainForm.FormResize(Sender: TObject);
Begin
Left := (Screen.Width - Width) Div 2;
Top := (Screen.Height - Height) Div 2;
End;
Procedure ShowInstruction();
Begin
Application.MessageBox
('1. Äëÿ äîáàâëåíèÿ çàïèñè â ñïèñîê íàæìèòå íà êíîïêó "Äîáàâèòü", è ââåäèòå òðåáóþùóþñÿ èíôîðìàöèþ.'#13#10
+ '2. Äëÿ ðåäàêòèðîâàíèÿ çàïèñè íàæìèòå äâàæäû íà íóæíóþ ñòðîêó ñïèñêà.'#13#10
+ '3. Äëÿ óäàëåíèÿ çàïèñè âûáåðèòå åå â ñïèñêå è íàæìèòå íà êíîïêó "Óäàëèòü".'#13#10
+ '4. Äëÿ ïîäáîðà êàíäèäàòîâ äëÿ âàêàíñèè âûáåðèòå íóæíóþ âàêàíñèþ â ñïèñêå è íàæìèòå íà êíîïêó "Ïîäîáðàòü êàíäèäàòîâ".'#13#10
+ '5. Äëÿ ïðîñìîòðà äåôèöèòíûõ ñïåöèàëèñòîâ íàæìèòå ñîîòâåòñòâóþùóþ êíîïêó â îêíå ñïèñêà ñ êàíäèäàòàìè.'#13#10
+ '6. Ìàêñèìàëüíîå êîëè÷åñòâî çàïèñåé â êàæäîì ñïèñêå - 100.'#13#10 +
'7. Äëÿ âîçâðàùåíèÿ â ãëàâíîå ìåíþ çàêðîéòå îêíî ñî ñïèñêîì èëè íàæìèòå Esc.'#13#10 + '8. Ôîðìàò äëÿ ôàéëîâ ñ âàêàíñèÿìè: *.vac.'#13#10 +
'9. Ôîðìàò äëÿ ôàéëîâ ñ êàíäèäàòàìè: *.can.', 'Èíñòðóêöèÿ', MB_OK);
End;
Procedure ShowProgramInfo();
Begin
Application.MessageBox('Áèðæà òðóäà'#13#10 +
'Ðàçðàáîò÷èê: Ãîðîäêî Êñåíèÿ Åâãåíüåâíà, 351005'#13#10 +
'Ó÷åáíàÿ ïðàêòèêà (îçíàêîìèòåëüíàÿ), âàðèàíò 15'#13#10 + 'ÁÃÓÈÐ 2024',
'Î ïðîãðàììå', MB_OK);
End;
Procedure TMainForm.MMInstructionClick(Sender: TObject);
Begin
ShowInstruction();
End;
Procedure TMainForm.MMProgramInfoClick(Sender: TObject);
Begin
ShowProgramInfo();
End;
Function IsFileExtCorrect(Path: String; Const EXT: String): Boolean;
Begin
If ExtractFileExt(Path) <> EXT Then
Application.MessageBox(PWideChar('Ôàéë äîëæåí èìåòü ðàçðåøåíèå ' + EXT +
'!'), 'Îøèáêà', MB_ICONERROR);
IsFileExtCorrect := ExtractFileExt(Path) = EXT;
End;
End.