-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathu_Welcome.pas
170 lines (120 loc) · 3.39 KB
/
u_Welcome.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
unit u_Welcome;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls, Vcl.Buttons,
Vcl.Imaging.jpeg, Vcl.WinXCtrls;
type
TfrmWelcome = class(TForm)
RelativePanel1: TRelativePanel;
imgBackground: TImage;
pnlNext: TPanel;
stHeading: TStaticText;
btnCreateT: TBitBtn;
btnPastT: TBitBtn;
btnLogout: TBitBtn;
btnManageT: TBitBtn;
btnTournamentUsers: TBitBtn;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnLogoutClick(Sender: TObject);
procedure btnCreateTClick(Sender: TObject);
procedure btnManageTClick(Sender: TObject);
procedure btnTournamentUsersClick(Sender: TObject);
// Fix for multi forums.
procedure CreateParams(var Params: TCreateParams); override;
procedure btnPastTClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmWelcome: TfrmWelcome;
implementation
{$R *.dfm}
uses u_Functions, u_Application, u_DatabaseConnection, u_TManage, u_PManage,
u_LTournament;
procedure TfrmWelcome.btnCreateTClick(Sender: TObject);
var
sInput: String;
begin
// Grab Tournament name from user.
sInput := InputBox('Create tournament:', 'Name:', '');
// Check input.
if (sInput = NullAsStringValue) then
begin
ShowMessage('Please enter a name.');
Exit;
end;
// Ready database.
frmDatabaseConnection.tblTournaments.First;
// Lets see if the tournament exists.
while NOT(frmDatabaseConnection.tblTournaments.Eof) do
begin
if (frmDatabaseConnection.tblTournaments['T_Name'] = sInput) then
begin
ShowMessage('Tourament with this name already exists.');
Exit;
end;
// Next.
frmDatabaseConnection.tblTournaments.Next;
end;
// Tournament doesnt exist, let us create it.
frmDatabaseConnection.tblTournaments.Insert;
frmDatabaseConnection.tblTournaments['T_Name'] := sInput;
frmDatabaseConnection.tblTournaments.Post;
ShowMessage('Tournament Created!');
// Update data.
frmDatabaseConnection.tblTournaments.Refresh;
end;
procedure TfrmWelcome.btnLogoutClick(Sender: TObject);
begin
// Close form and clean.
frmWelcome.Hide;
frmApplication.Show;
sUsername := '';
sPassword := '';
end;
procedure TfrmWelcome.btnManageTClick(Sender: TObject);
begin
// Move.
frmWelcome.Hide;
frmTManage.Show;
end;
procedure TfrmWelcome.btnPastTClick(Sender: TObject);
begin
// Move.
frmWelcome.Hide;
frmPastLoad.Show;
end;
procedure TfrmWelcome.btnTournamentUsersClick(Sender: TObject);
begin
// Move.
frmWelcome.Hide;
frmPManage.Show;
end;
procedure TfrmWelcome.CreateParams(var Params: TCreateParams);
begin
inherited;
// Set style sheet so windows knows its another "window".
Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
Params.WndParent := GetDesktopWindow;
end;
procedure TfrmWelcome.FormClose(Sender: TObject; var Action: TCloseAction);
begin
// Fix multi form issues.
Application.Terminate;
end;
procedure TfrmWelcome.FormShow(Sender: TObject);
begin
// Disable window resize.
frmWelcome.BorderStyle := bsDialog;
frmWelcome.BorderIcons := BorderIcons;
// Centre
TFunctions.sizeCentre(frmWelcome);
// Set form title.
frmWelcome.Caption := 'Welcome ' + sUsername;
end;
end.