-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLogin.cs
56 lines (50 loc) · 1.5 KB
/
Login.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
namespace EmployeeManagementSystem
{
public partial class Login : System.Windows.Forms.Form
{
public Login()
{
InitializeComponent();
}
private void loginBtn_Click(object sender, EventArgs e)
{
string usr = username.Text;
string pwd = password.Text;
bool isValid = false;
foreach (User i in Program.userList.GetAllUsers())
{
if (i.Username == usr && i.Password == pwd)
{
isValid = true;
Auth.currentUser = i;
break;
}
}
if (isValid)
{
Auth.isLoggedIn = true;
if (usr == "admin" && pwd == "admin")
{
var adminForm = new AdminForm();
this.Hide();
adminForm.Show();
}
else
{
this.Hide();
var empForm = new EmployeeForm();
empForm.Show();
}
username.Clear();
password.Clear();
// proceed to the next page
}
else
{
MessageBox.Show("Invalid username or password. Please try again.", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
username.Clear();
password.Clear();
}
}
}
}