private void BtnLogin_Click(object sender, EventArgs e) { string username = txtUsername.Text; string password = txtPassword.Text; if (username == "") { MessageBox.Show("Username can not be empty. Please enter your username."); } else if (password == "") { MessageBox.Show("Password can not be empty. Please enter the password."); } else { dbAcccess acccess = new dbAcccess(); List <adminstrator> adminstrators = acccess.checkAdminstrator(username, password); if (adminstrators.Any()) { foreach (adminstrator admin in adminstrators) { MessageBox.Show(admin.ToString()); } } else { MessageBox.Show("There is no user with the given details. Please provide correct credentials."); } } }