private void btnLogin_Click(object sender, EventArgs e) { try { conn.Open(); string username = txtUser.Text; string password = txtPass.Text; string sql = "select * from NhanVien where userName='******' and passWord='******'"; SqlCommand cmd = new SqlCommand(sql, conn); using (DbDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { Constants.username = reader.GetString(1); Constants.isAdmin = Convert.ToBoolean(reader.GetValue(3)); } this.Hide(); TrangChu trangChu = new TrangChu(); trangChu.Show(); } else { MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu"); } } } catch (Exception ex) { MessageBox.Show("lỗi kết nối"); } finally { conn.Close(); } }