-
Notifications
You must be signed in to change notification settings - Fork 0
/
uStaffPageAccess.pas
54 lines (45 loc) · 1.34 KB
/
uStaffPageAccess.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
unit uStaffPageAccess;
interface
uses
ComCtrls, SysUtils, Generics.Collections, uLibrary, Dialogs;
const
FILE_NAME = 'PageAccess.txt';
var
PageAccessDictionary : TDictionary<string, string>;
procedure SetUpDictionary;
procedure AccessPages(PageControl : TPageControl; JobTitle : string);
implementation
//-------------------------------------LOADS DATA INTO THE DICTIONARY
procedure SetUpDictionary;
var
tFl : TextFile;
iPos : byte;
sLine, sJobName : string;
begin
PageAccessDictionary := TDictionary<string, string>.Create;
AssignFile(tFl, FILE_NAME);
Reset(tFl);
while NOT EoF(tFl) do
begin
ReadLn(tFl, sLine);
iPos := POS(TEXT_FILE_DELIMETER, sLine);
sJobName := Copy(sLine, 1, iPos - 1);
Delete(sLine, 1, iPos);
PageAccessDictionary.Add(sJobName, sLine);
end;
CloseFile(tFl);
end;
//-------------------------------------CHANGES PAGES TO VISIBLE FOR A
//-------------------------------------SPECIFIC STAFF TYPE
procedure AccessPages(PageControl : TPageControl; JobTitle : string);
var
K : byte;
sPagesToAccess : string;
begin
PageAccessDictionary.TryGetValue(UPPERCASE(JobTitle), sPagesToAccess);
for K := 1 to Length(sPagesToAccess) do
begin
PageControl.Pages[StrToInt(sPagesToAccess[K])].TabVisible := true;
end;
end;
end.