private void TryLogin() { if (Core.Server.Integration.Connected()) { Student user = Core.Server.Integration.ExecuteGetStudent(textBox1.Text); Teacher user2 = Core.Server.Integration.ExecuteGetTeacher(textBox1.Text); if (user != null) { // student exists // check if password is correct if (textBox2.Text == user.Password) { if (openForm != null) { openForm.Close(); } // password is correct StudentForm form = new StudentForm(user); // open student form form.Show(); // minimize login this.WindowState = FormWindowState.Minimized; } else { errorText.Text = "Incorrect Password"; } } else if (user2 != null) { // teacher exists // check if password is correct if (textBox2.Text == user2.Password) { if (openForm != null) { openForm.Close(); } // password is correct TeacherForm form = new TeacherForm(user2); // open teacher form form.Show(); // minimize login this.WindowState = FormWindowState.Minimized; } else { errorText.Text = "Incorrect Uassword"; } } else { errorText.Text = "Invalid Username"; } } else { errorText.Text = "Check Connection"; } }