private void btnCancelDrill_Click(object sender, EventArgs e) { this.Hide(); frmHomePage HomePage = new frmHomePage(Student.UserId); HomePage.ShowDialog(); }
//Show Home page private void btnLogin_Click(object sender, EventArgs e) { string userId = txtUsername.Text; string pwd = txtPassword.Text; Person person = new Person(); person = StudentDB.StudentLogin(userId, pwd); //If a user is found from the student DB then the homepage will launch for the student. if (person != null) { if (person.userRole == "Student" || person.userRole == "student") { //MessageBox.Show("person role:" + person.userRole); this.Hide(); frmHomePage HomePage = new frmHomePage(person.userId); HomePage.ShowDialog(); this.Show(); } else if (person.userRole == "Teacher") { this.Hide(); this.Show(); } } else { MessageBox.Show("Incorrect password, or username. Please try again"); } }
private void btnSubmitAnswer_Click(object sender, EventArgs e) { try { double answer = Convert.ToDouble(txtAnswer.Text); bool isCorrect = Drill.CheckAnswer(answer); if (!isCorrect && Drill.NumberOfAttempts > 0) { MessageBox.Show("Incorrect answer.\n\nTry again.", "Incorrect answer."); } else if (!isCorrect) { if (Drill.NumberOfAttempts > 0) { MessageBox.Show("Incorrect, please try again.", "Incorrect Answer"); } else { MessageBox.Show($"Incorrect answer.\n\nThe correct answer is: {Drill.Question.Answer}", "Incorrect Answer"); txtAnswer.Text = ""; Drill.GetNextQuestion(); txtQuestion.Text = Drill.Question.NewQuestion; } } else { MessageBox.Show("Correct!", "Correct Answer"); txtAnswer.Text = ""; Drill.GetNextQuestion(); txtQuestion.Text = Drill.Question.NewQuestion; txtAnswer.Focus(); } } catch (FormatException) { MessageBox.Show("Please enter a number.", e.GetType().ToString()); } catch (Exception f) { MessageBox.Show(f.Message); // I am not understanding what the Activity History class is for, so I'm not sure how to call this method DrillDB.AddCompletedDrill(Drill, Student); this.Hide(); frmHomePage HomePage = new frmHomePage(Student.UserId); HomePage.ShowDialog(); } }