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 button1_Click(object sender, EventArgs e) { try { FormValidate(); QuizTeam quizTeam = GetTeamObject(teamId); if (teamId == 0) { quizTeam.Id = 0; quizTeam.CreatedBy = "Admin"; quizTeam.CreatedDate = DateTime.Now; _quizTeamService.Add(quizTeam); } else { quizTeam.UpdatedBy = "Admin"; quizTeam.UpdatedDate = DateTime.Now; _quizTeamService.Edit(quizTeam); } _quizTeamService.Save(); this.Close(); Program.teamListForm.GetTeams(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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"); } }