-
Notifications
You must be signed in to change notification settings - Fork 0
/
Staff_Dashboard.cs
302 lines (257 loc) · 9.66 KB
/
Staff_Dashboard.cs
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Data.SqlClient;
namespace Walmart_OMS
{
public partial class Staff_Dashboard : Form
{
private Form currentChildForm;
private void OpenChildForm(Form childForm)
{
if (currentChildForm != null)
currentChildForm.Close();
currentChildForm = childForm;
childForm.TopLevel = false;
childForm.FormBorderStyle = FormBorderStyle.None;
childForm.Dock = DockStyle.Fill;
panelCf.Controls.Add(childForm);
panelCf.Tag = childForm;
childForm.BringToFront();
childForm.Show();
lbl_title.Text = childForm.Text;
}
public Staff_Dashboard()
{
InitializeComponent();
//Form control
this.Text = string.Empty;
this.ControlBox = false;
this.DoubleBuffered = false;
this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea;
}
SqlConnection con;
SqlCommand cmd;
SqlDataReader dr;
private void Staff_Dashboard_Load(object sender, EventArgs e)
{
con = new SqlConnection("Data Source=HANSANA-3501;Initial Catalog=WalmartOMS_DB;Integrated Security=True");
try
{
con.Open();
cmd = new SqlCommand("SELECT First_Name FROM All_Staff WHERE EID = '" + Staff_Login.EID + "'", con);
string fname = cmd.ExecuteScalar().ToString();
cmd = new SqlCommand("SELECT Last_Name FROM All_Staff WHERE EID = '" + Staff_Login.EID + "'", con);
string lname = cmd.ExecuteScalar().ToString();
con.Close();
lbl_username.Text = fname + " " + lname;
lbl_userid.Text = Staff_Login.EID;
timer1.Start();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btn_exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btn_orders_Click(object sender, EventArgs e)
{
panel_nav.Height = btn_orders.Height;
panel_nav.Top = btn_orders.Top;
panel_nav.Left = btn_orders.Left;
btn_orders.BackColor = Color.FromArgb(46, 51, 73);
OpenChildForm(new Orders_Staff_());
}
private void btn_leave_Click(object sender, EventArgs e)
{
panel_nav.Height = btn_leave.Height;
panel_nav.Top = btn_leave.Top;
panel_nav.Left = btn_leave.Left;
btn_leave.BackColor = Color.FromArgb(46, 51, 73);
OpenChildForm(new Leave());
}
private void btn_settings_Click(object sender, EventArgs e)
{
panel_nav.Height = btn_settings.Height;
panel_nav.Top = btn_settings.Top;
panel_nav.Left = btn_settings.Left;
btn_settings.BackColor = Color.FromArgb(46, 51, 73);
OpenChildForm(new Settings_Staff());
}
private void btn_adminP_Click(object sender, EventArgs e)
{
panel_nav.Height = btn_adminP.Height;
panel_nav.Top = btn_adminP.Top;
panel_nav.Left = btn_adminP.Left;
btn_adminP.BackColor = Color.FromArgb(46, 51, 73);
try
{
con.Open();
cmd = new SqlCommand("SELECT * FROM Super_Admins WHERE EID = '" + Staff_Login.EID + "'", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
dr.Close();
OpenChildForm(new Admin_Panel());
}
else
{
dr.Close();
cmd = new SqlCommand("SELECT * FROM Admins WHERE EID = '" + Staff_Login.EID + "'", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
dr.Close();
OpenChildForm(new Admin_Panel());
}
else
{
dr.Close();
if (currentChildForm != null)
currentChildForm.Close();
MessageBox.Show("You cannot view this tab, You're not an Admin", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
con.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btn_helpdesk_Click(object sender, EventArgs e)
{
panel_nav.Height = btn_helpdesk.Height;
panel_nav.Top = btn_helpdesk.Top;
panel_nav.Left = btn_helpdesk.Left;
btn_helpdesk.BackColor = Color.FromArgb(46, 51, 73);
try
{
con.Open();
cmd = new SqlCommand("SELECT * FROM Super_Admins WHERE EID = '" + Staff_Login.EID + "'", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
dr.Close();
OpenChildForm(new Help_Desk_Admin_());
}
else
{
dr.Close();
cmd = new SqlCommand("SELECT * FROM Admins WHERE EID = '" + Staff_Login.EID + "'", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
dr.Close();
OpenChildForm(new Help_Desk_Admin_());
}
else
{
dr.Close();
cmd = new SqlCommand("SELECT * FROM Staff WHERE EID = '" + Staff_Login.EID + "'", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
dr.Close();
OpenChildForm(new Help_Desk());
}
else
{
dr.Close();
MessageBox.Show("Invalid User", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
con.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btn_logout_Click(object sender, EventArgs e)
{
panel_nav.Height = btn_logout.Height;
panel_nav.Top = btn_logout.Top;
panel_nav.Left = btn_logout.Left;
btn_logout.BackColor = Color.FromArgb(46, 51, 73);
this.Close();
Staff_Login sl = new Staff_Login();
sl.Show();
}
private void btn_orders_Leave(object sender, EventArgs e)
{
btn_orders.BackColor = Color.FromArgb(24, 30, 54);
}
private void btn_leave_Leave(object sender, EventArgs e)
{
btn_leave.BackColor = Color.FromArgb(24, 30, 54);
}
private void btn_settings_Leave(object sender, EventArgs e)
{
btn_settings.BackColor = Color.FromArgb(24, 30, 54);
}
private void btn_adminP_Leave(object sender, EventArgs e)
{
btn_adminP.BackColor = Color.FromArgb(24, 30, 54);
}
private void btn_helpdesk_Leave(object sender, EventArgs e)
{
btn_helpdesk.BackColor = Color.FromArgb(24, 30, 54);
}
private void btn_logout_Leave(object sender, EventArgs e)
{
btn_logout.BackColor = Color.FromArgb(24, 30, 54);
}
private void btn_maximize_Click(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Normal)
{
WindowState = FormWindowState.Maximized;
}
else
{
WindowState = FormWindowState.Normal;
}
}
private void btn_minimize_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
private void btn_version_Click(object sender, EventArgs e)
{
App_Version av = new App_Version();
av.Show();
}
//Drag FORM DLL
[DllImport("user32.DLL", EntryPoint = "ReleaseCapture")]
private extern static void ReleaseCapture();
[DllImport("user32.DLL", EntryPoint = "SendMessage")]
private extern static void SendMessage(System.IntPtr hWnd, int wMsg, int wParam, int lParam);
private void panel_title_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, 0x112, 0xf012, 0);
}
private void timer1_Tick(object sender, EventArgs e)
{
lbl_time.Text = DateTime.Now.ToLongTimeString();
lbl_date.Text = DateTime.Now.ToLongDateString();
}
private void pB_profile_Click(object sender, EventArgs e)
{
pB_intro.Visible = true;
pB_intro.BringToFront();
}
}
}