Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int Teamcount = 0;
                if (LevelcomboBox.SelectedValue.ToString() == "0")
                {
                    throw new Exception("Please select quiz level");
                }

                if (RoundcomboBox.SelectedValue.ToString() == "0")
                {
                    throw new Exception("Please select quiz level");
                }

                Program.Level = LevelcomboBox.Text + "," + LevelcomboBox.SelectedValue.ToString();
                Program.Round = RoundcomboBox.Text + "," + RoundcomboBox.SelectedValue.ToString();

                if (ChooseTeam1comboBox.SelectedValue.ToString() != "0")
                {
                    Teamcount = Teamcount + 1;
                }

                if (ChooseTeam2comboBox.SelectedValue.ToString() != "0")
                {
                    Teamcount = Teamcount + 1;
                }

                if (ChooseTeam3comboBox.SelectedValue.ToString() != "0")
                {
                    Teamcount = Teamcount + 1;
                }

                if (ChooseTeam4comboBox.SelectedValue.ToString() != "0")
                {
                    Teamcount = Teamcount + 1;
                }

                if (Teamcount < 2)
                {
                    throw new Exception("Please choose at least 2 teams to start quiz");
                }

                if ((ChooseTeam1comboBox.Text == ChooseTeam2comboBox.Text) ||
                    (ChooseTeam1comboBox.Text == ChooseTeam3comboBox.Text) ||
                    (ChooseTeam1comboBox.Text == ChooseTeam4comboBox.Text) ||
                    (ChooseTeam2comboBox.Text == ChooseTeam3comboBox.Text) ||
                    (ChooseTeam2comboBox.Text == ChooseTeam4comboBox.Text) ||
                    (ChooseTeam3comboBox.Text == ChooseTeam2comboBox.Text) ||
                    (ChooseTeam3comboBox.Text == ChooseTeam4comboBox.Text) ||
                    (ChooseTeam4comboBox.Text == ChooseTeam3comboBox.Text) ||
                    (ChooseTeam4comboBox.Text == ChooseTeam2comboBox.Text))
                {
                    throw new Exception("Please choose four different teams");
                }


                if (ChooseTeam1comboBox.SelectedValue.ToString() != "0")
                {
                    Program.TeamA = ChooseTeam1comboBox.Text;
                }
                else
                {
                    Program.TeamA = string.Empty;
                }

                if (ChooseTeam2comboBox.SelectedValue.ToString() != "0")
                {
                    Program.TeamB = ChooseTeam2comboBox.Text;
                }
                else
                {
                    Program.TeamB = string.Empty;
                }

                if (ChooseTeam3comboBox.SelectedValue.ToString() != "0")
                {
                    Program.TeamC = ChooseTeam3comboBox.Text;
                }
                else
                {
                    Program.TeamC = string.Empty;
                }

                if (ChooseTeam4comboBox.SelectedValue.ToString() != "0")
                {
                    Program.TeamD = ChooseTeam4comboBox.Text;
                }
                else
                {
                    Program.TeamD = string.Empty;
                }

                Program.NoOfQuestion = _quizRoundService.GetAll().Where(x => x.Name == RoundcomboBox.Text).Select(x => x.NoOfQuestions).FirstOrDefault();

                if (LevelcomboBox.Text == "Level1" && RoundcomboBox.Text == "Round1")
                {
                    Form2 Question = new Form2();
                    Question.Text = "Question";
                    Question.Show();
                }

                if (LevelcomboBox.Text == "Level1" && RoundcomboBox.Text == "Round2")
                {
                    Level1Round2Form Question = new Level1Round2Form();
                    Question.Text = "Question";
                    Question.Show();
                }

                if (LevelcomboBox.Text == "Level1" && RoundcomboBox.Text == "Round3")
                {
                    Level1Round3Form Question = new Level1Round3Form();
                    Question.Text = "Question";
                    Question.Show();
                }

                if (LevelcomboBox.Text == "Level1" && RoundcomboBox.Text == "Round4")
                {
                    Level1Round4Form Question = new Level1Round4Form();
                    Question.Text = "Question";
                    Question.Show();
                }

                if (LevelcomboBox.Text == "Level1" && RoundcomboBox.Text == "tie Breaker")
                {
                    Level1Round4Form Question = new Level1Round4Form();
                    Question.Text = "Question";
                    Question.Show();
                }

                if (LevelcomboBox.Text == "Level2" && RoundcomboBox.Text == "Round1")
                {
                    Form2 Question = new Form2();
                    Question.Text = "Question";
                    Question.Show();
                }

                if (LevelcomboBox.Text == "Level2" && RoundcomboBox.Text == "Round2")
                {
                    Level2Round2Form Question = new Level2Round2Form();
                    Question.Text = "Question";
                    Question.Show();
                }

                if (LevelcomboBox.Text == "Level2" && RoundcomboBox.Text == "Round3")
                {
                    Level2Round3Form Question = new Level2Round3Form();
                    Question.Text = "Question";
                    Question.Show();
                }

                if (LevelcomboBox.Text == "Level2" && RoundcomboBox.Text == "Round4")
                {
                    Level2Round4Form Question = new Level2Round4Form();
                    Question.Text = "Question";
                    Question.Show();
                }

                if (LevelcomboBox.Text == "Level2" && RoundcomboBox.Text == "tie Breaker")
                {
                    Level1Round4Form Question = new Level1Round4Form();
                    Question.Text = "Question";
                    Question.Show();
                }


                if (LevelcomboBox.Text == "Level3" && RoundcomboBox.Text == "Round1")
                {
                    Form2 Question = new Form2();
                    Question.Text = "Question";
                    Question.Show();
                }

                if (LevelcomboBox.Text == "Level3" && RoundcomboBox.Text == "Round2")
                {
                    Level3Round2Form Question = new Level3Round2Form();
                    Question.Text = "Question";
                    Question.Show();
                }

                if (LevelcomboBox.Text == "Level3" && RoundcomboBox.Text == "Round3")
                {
                    Level3Round3Form Question = new Level3Round3Form();
                    Question.Text = "Question";
                    Question.Show();
                }

                if (LevelcomboBox.Text == "Level3" && RoundcomboBox.Text == "Round4")
                {
                    Level2Round4Form Question = new Level2Round4Form();
                    Question.Text = "Question";
                    Question.Show();
                }

                if (LevelcomboBox.Text == "Level3" && RoundcomboBox.Text == "tie Breaker")
                {
                    Level1Round4Form Question = new Level1Round4Form();
                    Question.Text = "Question";
                    Question.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message");
            }
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool   IsDisable    = false;
            string AcademicYear = Program.CurrAcademicYear;
            int    LevelId      = Convert.ToInt32(Level.Split(',')[1]);
            int    RoundId      = Convert.ToInt32(Round.Split(',')[1]);

            var NoOfQuestionPerTeam = _noQuesPerLeavelRoundService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId).Select(x => x.NoOfQuestion).FirstOrDefault();

            if (NoOfQuestionPerTeam != 0)
            {
                if (!String.IsNullOrEmpty(Program.TeamA))
                {
                    int TeamId          = _quizTeamService.GetAll().Where(x => x.Name == Program.TeamA).Select(x => x.Id).FirstOrDefault();
                    var NoOfAttemptQues = _attamtedQuestionsService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId && x.TeamId == TeamId && x.AcademicYear == AcademicYear).ToList();

                    if (NoOfAttemptQues.Count() == NoOfQuestionPerTeam)
                    {
                        IsDisable = true;
                    }
                    else
                    {
                        IsDisable = false;
                    }
                }

                if (!String.IsNullOrEmpty(Program.TeamB))
                {
                    int TeamId          = _quizTeamService.GetAll().Where(x => x.Name == Program.TeamB).Select(x => x.Id).FirstOrDefault();
                    var NoOfAttemptQues = _attamtedQuestionsService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId && x.TeamId == TeamId && x.AcademicYear == AcademicYear).ToList();

                    if (NoOfAttemptQues.Count() == NoOfQuestionPerTeam)
                    {
                        IsDisable = true;
                    }
                    else
                    {
                        IsDisable = false;
                    }
                }

                if (!String.IsNullOrEmpty(Program.TeamC))
                {
                    int TeamId          = _quizTeamService.GetAll().Where(x => x.Name == Program.TeamC).Select(x => x.Id).FirstOrDefault();
                    var NoOfAttemptQues = _attamtedQuestionsService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId && x.TeamId == TeamId && x.AcademicYear == AcademicYear).ToList();

                    if (NoOfAttemptQues.Count() == NoOfQuestionPerTeam)
                    {
                        IsDisable = true;
                    }
                    else
                    {
                        IsDisable = false;
                    }
                }

                if (!String.IsNullOrEmpty(Program.TeamD))
                {
                    int TeamId          = _quizTeamService.GetAll().Where(x => x.Name == Program.TeamD).Select(x => x.Id).FirstOrDefault();
                    var NoOfAttemptQues = _attamtedQuestionsService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId && x.TeamId == TeamId && x.AcademicYear == AcademicYear).ToList();

                    if (NoOfAttemptQues.Count() == NoOfQuestionPerTeam)
                    {
                        IsDisable = true;
                    }
                    else
                    {
                        IsDisable = false;
                    }
                }
            }

            if (IsDisable == true && Round.Split(',')[0] != "tie Breaker")
            {
                button1.Enabled = false;

                NexrRoundForm nextRoundForm = new NexrRoundForm();
                nextRoundForm.LevelROundLbl.Text = Level.Split(',')[0] + " " + Round.Split(',')[0] + " finished , Please click on next button";
                nextRoundForm.ShowDialog();
                this.Close();

                Program.Level = Level.Split(',')[0] + "," + LevelId.ToString();
                Program.Round = "Round3," + _quizRoundService.GetAll().Where(x => x.Name == "Round3").Select(x => x.Id).FirstOrDefault().ToString();

                Level3Round3Form Question = new Level3Round3Form();
                Question.Text = "Question";
                Question.Show();
            }
            else
            {
                GetQuestion();
            }
        }