private void Rightbtn_Click(object sender, EventArgs e) { timer1.Stop(); if (!string.IsNullOrEmpty(BuzzPressTeamlbl.Text)) { int questionnid = Convert.ToInt32(questionidlabel.Text); int LevelId = Convert.ToInt32(Level.Split(',')[1]); int RoundId = Convert.ToInt32(Round.Split(',')[1]); var checkforattamt = _attamtedQuestionsService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId && x.QuestionId == questionnid && x.AcademicYear == Program.CurrAcademicYear).ToList(); if (checkforattamt.Count() == 0) { AttamtedQuestions attamtedQuestions = new AttamtedQuestions(); attamtedQuestions.QuestionId = Convert.ToInt32(questionidlabel.Text); attamtedQuestions.LevelId = Convert.ToInt32(Level.Split(',')[1]); attamtedQuestions.RoundId = Convert.ToInt32(Round.Split(',')[1]); attamtedQuestions.Marks = 10; attamtedQuestions.TeamId = _quizTeamService.GetAll().Where(x => x.Name == BuzzPressTeamlbl.Text).Select(x => x.Id).FirstOrDefault(); attamtedQuestions.TeamName = BuzzPressTeamlbl.Text; attamtedQuestions.AcademicYear = AcademicYearlabel.Text; attamtedQuestions.IsTrue = true; attamtedQuestions.CreatedBy = "Admin"; attamtedQuestions.CreatedDate = DateTime.Now; _attamtedQuestionsService.Add(attamtedQuestions); _attamtedQuestionsService.Save(); QuizTeam quizTeam = _quizTeamService.FindBy(x => x.Id == attamtedQuestions.TeamId).FirstOrDefault(); quizTeam.Marks += attamtedQuestions.Marks; _quizTeamService.Edit(quizTeam); _quizTeamService.Save(); SuccessForm success = new SuccessForm(); success.Text = "Correct answer"; success.ShowDialog(); CalculateMarks(); } else { MessageBox.Show("You have already attempted this question, please go to next question", "Alert"); } } else { MessageBox.Show("Plese select team name", "Alert"); } }
private void ShowAnswerbtn_Click(object sender, EventArgs e) { timer1.Stop(); int questionnid = Convert.ToInt32(questionidlabel.Text); int LevelId = Convert.ToInt32(Level.Split(',')[1]); int RoundId = Convert.ToInt32(Round.Split(',')[1]); var checkforattamt = _attamtedQuestionsService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId && x.QuestionId == questionnid && x.AcademicYear == Program.CurrAcademicYear).ToList(); if (checkforattamt.Count() == 0) { AttamtedQuestions attamtedQuestions = new AttamtedQuestions(); attamtedQuestions.QuestionId = Convert.ToInt32(questionidlabel.Text); attamtedQuestions.LevelId = Convert.ToInt32(Level.Split(',')[1]); attamtedQuestions.RoundId = Convert.ToInt32(Round.Split(',')[1]); if (CorrecttextBox.Text != "" && WrongtextBox.Text != "") { attamtedQuestions.Marks = Convert.ToInt32(CorrecttextBox.Text) * 10 + Convert.ToInt32(WrongtextBox.Text) * (-5); } attamtedQuestions.TeamId = _quizTeamService.GetAll().Where(x => x.Name == TeanNamelabel.Text).Select(x => x.Id).FirstOrDefault(); attamtedQuestions.TeamName = TeanNamelabel.Text; attamtedQuestions.AcademicYear = AcademicYearlabel.Text; attamtedQuestions.IsTrue = true; attamtedQuestions.CreatedBy = "Admin"; attamtedQuestions.CreatedDate = DateTime.Now; _attamtedQuestionsService.Add(attamtedQuestions); _attamtedQuestionsService.Save(); QuizTeam quizTeam = _quizTeamService.FindBy(x => x.Id == attamtedQuestions.TeamId).FirstOrDefault(); quizTeam.Marks += attamtedQuestions.Marks; _quizTeamService.Edit(quizTeam); _quizTeamService.Save(); CalculateMarks(); } else { MessageBox.Show("You have already attempted this question, please go to next question", "Alert"); } }
private void button2_Click(object sender, EventArgs e) { var attemptQuestions = _attamtedQuestionsService.GetAll().ToList(); foreach (var item in attemptQuestions) { item.Marks = 0; _attamtedQuestionsService.Edit(item); _attamtedQuestionsService.Save(); } ChooseTeam2comboBox.SelectedValue = 0; ChooseTeam1comboBox.SelectedValue = 0; ChooseTeam3comboBox.SelectedValue = 0; ChooseTeam4comboBox.SelectedValue = 0; DScorelabel.Visible = false; BScorelabel.Visible = false; AScorelabel.Visible = false; CScorelabel.Visible = false; }