private void txtPassword_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (txtUsername.Text == "" && txtPassword.Text != "") { MessageBox.Show("Vui lòng nhập tên đăng nhập", "Thông báo"); } if (txtPassword.Text == "" && txtUsername.Text != "") { MessageBox.Show("Vui lòng nhập mật khẩu", "Thông báo"); } if (txtUsername.Text == "" && txtPassword.Text == "") { MessageBox.Show("Vui lòng nhập đầy đủ thông tin", "Thong báo"); } if ((txtUsername.Text == "admin" && txtPassword.Text == "123456789")) { fmHome fmHome = new fmHome(); MessageBox.Show("Đăng nhập thành công", "Thông báo"); this.Hide(); fmHome.Show(); } else { MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu"); } } }
private void btnLogin_Click(object sender, EventArgs e) { string userName = txtUser.Text; string passWord = txtPassword.Text; if (Login(userName, passWord)) { fmHome fmHome = new fmHome(); MessageBox.Show("Đăng nhập thành công"); this.Hide(); fmHome.Show(); } else { MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu", "Thông báo"); } }
private void txtPassword_KeyDown(object sender, KeyEventArgs e) { //khi bấm enter sẽ tự động bấm button đăng nhập if (e.KeyCode == Keys.Enter) { string userName = txtUser.Text; string passWord = txtPassword.Text; if (Login(userName, passWord)) { fmHome fmHome = new fmHome(); this.Hide(); fmHome.Show(); } else { MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu", "Thông báo"); } } }