-
Notifications
You must be signed in to change notification settings - Fork 0
/
fLogin.cs
134 lines (121 loc) · 4.14 KB
/
fLogin.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
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;
namespace Thuc_Tap_CSDL
{
public partial class fLogin : Form
{
public fLogin()
{
InitializeComponent();
}
//string username = "admin";
//string password = "admin";
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btnMiniMize_Click(object sender, EventArgs e)
{
WindowState = FormWindowState.Minimized;
}
private void lblExit_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Application.Exit();
}
private void txtUser_Enter(object sender, EventArgs e)
{
if(txtUser.Text == "Tên đăng nhập")
{
txtUser.Text = "";
txtUser.ForeColor = Color.FromArgb(0, 134, 75);
}
}
private void txtUser_Leave(object sender, EventArgs e)
{
if(txtUser.Text == "")
{
txtUser.Text = "Tên đăng nhập";
txtUser.ForeColor = Color.Silver;
}
}
private void txtPassword_Enter(object sender, EventArgs e)
{
if(txtPassword.Text == "Mật khẩu")
{
txtPassword.Text = "";
txtPassword.UseSystemPasswordChar = true;
txtPassword.ForeColor = Color.FromArgb(0, 134, 75);
}
}
private void txtPassword_Leave(object sender, EventArgs e)
{
if(txtPassword.Text == "")
{
txtPassword.Text = "Mật khẩu";
txtPassword.UseSystemPasswordChar = false;
txtPassword.ForeColor = Color.Silver;
}
}
private void ptrEyes_Click(object sender, EventArgs e)
{
if(txtPassword.Text != "Mật khẩu")
{
if (txtPassword.UseSystemPasswordChar)
{
txtPassword.UseSystemPasswordChar = false;
//ptrEyes.BackgroundImage = Image.FromFile(Application.StartupPath + "\\Resources\\eyeopen.ico");
}
else
{
txtPassword.UseSystemPasswordChar = true;
//ptrEyes.BackgroundImage = Image.FromFile(Application.StartupPath + "\\Resources\\eyeclose.ico");
}
}
}
private void btnLogin_Click(object sender, EventArgs e)
{
if((txtUser.Text == "admin" && txtPassword.Text == "admin") || (txtUser.Text == "staff" && txtPassword.Text == "staff"))
{
this.Hide();
fMain fmain = new fMain(txtUser.Text);
fmain.ShowDialog();
this.Show();
txtUser.Text = "Tên đăng nhập";
txtUser.ForeColor = Color.Silver;
txtPassword.Text = "Mật khẩu";
txtPassword.UseSystemPasswordChar = false;
txtPassword.ForeColor = Color.Silver;
lblFailLogin.Text = "";
txtUser.Focus();
}
else
{
txtUser.Text = "Tên đăng nhập";
txtUser.ForeColor = Color.Silver;
txtPassword.Text = "Mật khẩu";
txtPassword.UseSystemPasswordChar = false;
txtPassword.ForeColor = Color.Silver;
lblFailLogin.Text = "Đăng nhập thất bại";
txtUser.Focus();
}
}
private void Form1_Load(object sender, EventArgs e)
{
txtUser.Focus();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if(MessageBox.Show("Thoát ứng dụng?", "Thông báo", MessageBoxButtons.OKCancel) != DialogResult.OK)
{
e.Cancel = true;
}
}
}
}