CapDemo.Open_Game.team_checkQuestionPM C# (CSharp) Метод

team_checkQuestionPM() приватный Метод

private team_checkQuestionPM ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
Результат void
        void team_checkQuestionPM(object sender, EventArgs e)
        {
            int idPlayerUC = (e as MyEventArgs).IDPlayerUC;
            foreach (Team TeamCS in flp_Team.Controls)
            {
                if (TeamCS.IdPlayerUC == idPlayerUC)
                {
                     DialogResult dr = MessageBox.Show("Are you sure to use Question PM?", "Game Choice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                     if (dr == DialogResult.Yes)
                     {
                         try
                         {
                             List<Phase> ListPhase;
                             Phase.IDContest = iDContest;
                             ListPhase = PhaseBL.GetPhasePM(Phase);
                             IDPhasePM = ListPhase.ElementAt(0).IDPhase;
                             int countTeamChallenged = 0;
                             //count team is challenged
                             foreach (Team teamCS in flp_Team.Controls)
                             {
                                 if (teamCS.chk_Challenged.Checked == true)
                                 {
                                     countTeamChallenged++;
                                 }
                             }
                             //show question have challenge choice
                             if (CheckChallengeChoice == true)
                             {
                                 if (countTeamChallenged == 0 || countTeamChallenged > NumofChallenge)
                                 {
                                     if (countTeamChallenged == 0)
                                     {
                                         MessageBox.Show("Please selected challenged team!");
                                         TeamCS.chk_QuestionPM.Checked = false;
                                     }
                                     else
                                     {
                                         MessageBox.Show("Maxmimum number of team will be challenged is " + NumofChallenge);
                                         TeamCS.chk_QuestionPM.Checked = false;
                                     }
                                 }
                                 else
                                 {
                                     foreach (Team teamCS in flp_Team.Controls)
                                     {
                                         if (Convert.ToInt32(teamCS.lbl_Sequence.Text) == sequenceplayer(records.ElementAt(team).IDPlayer))
                                         {

                                             //show question by id phase
                                             if (ShowQuestionByIDPhase(IDPhasePM) == true)
                                             {
                                                 teamCS.gb_team.Visible = false;
            ///////
                                                 records.ElementAt(team).PM = false;
                                                 //Record
                                                 Record Restore = new Record();
                                                 Restore.PM_I = 0;
                                                 Restore.IDPlayer = records.ElementAt(team).IDPlayer;
                                                 Restore.IDContest = iDContest;
                                                 RecordBL.UpdatePM(Restore);

                                                 CheckQuestionPM = true;
                                                 //show audience screen
                                                 lblHint.Text = guideline[3].ToString();
                                                 audience.tbc_ShowGame.SelectedTab = audience.tab_ShowQuestion;
                                                 //sound show question
                                                 try
                                                 {
                                                     axWindowsMediaPlayer1.URL = (Directory.GetCurrentDirectory()) + "\\Sound\\HienThiCauHoi.wav";
                                                     axWindowsMediaPlayer1.Ctlcontrols.play();
                                                 }
                                                 catch (Exception)
                                                 {
                                                 }

                                                 //axWindowsMediaPlayer1.settings.setMode("Loop", true);
                                                 step++;
                                             }
                                             else
                                             {
                                                 MessageBox.Show("Run out of questions PM. Please choose questions in phase");
                                                 OutOfQuestion();
                                             }

                                         }
                                     }
                                 }
                             }
                             else
                             {//show question don't have challenge choice
                                 foreach (Team teamCS in flp_Team.Controls)
                                 {
                                     if (Convert.ToInt32(teamCS.lbl_Sequence.Text) == sequenceplayer(records.ElementAt(team).IDPlayer))
                                     {

                                         //show question by id phase
                                         if (ShowQuestionByIDPhase(IDPhasePM) == true)
                                         {
                                             if (records.ElementAt(team).Support == false)
                                             {
                                                 teamCS.gb_team.Visible = false;
                                                 teamCS.chk_Support.Visible = false;
                                             }
                                             else
                                             {
                                                 teamCS.chk_Support.Visible = true;
                                             }
                                             teamCS.chk_QuestionPM.Visible = false;
                                             teamCS.chk_defy.Visible = false;
            ///////
                                             records.ElementAt(team).PM = false;
                                             //Record
                                             Record Restore = new Record();
                                             Restore.PM_I = 0;
                                             Restore.IDPlayer = records.ElementAt(team).IDPlayer;
                                             Restore.IDContest = iDContest;
                                             RecordBL.UpdatePM(Restore);

                                             CheckQuestionPM = true;
                                             pb_Play.Enabled = true;
                                             //show audience screen
                                             lblHint.Text = guideline[3].ToString();
                                             audience.tbc_ShowGame.SelectedTab = audience.tab_ShowQuestion;
                                             //sound show question
                                             try
                                             {
                                                 axWindowsMediaPlayer1.URL = (Directory.GetCurrentDirectory()) + "\\Sound\\HienThiCauHoi.wav";
                                                 axWindowsMediaPlayer1.Ctlcontrols.play();
                                             }
                                             catch (Exception)
                                             {
                                             }
                                             step++;
                                         }
                                         else
                                         {
                                             MessageBox.Show("Run out of questions PM. Please choose questions in phase");
                                             OutOfQuestion();
                                         }

                                     }
                                 }
                             }
                         }
                         catch (Exception)
                         {
                             MessageBox.Show("Question is not set up in game. Please choose question in phase");
                             TeamCS.chk_QuestionPM.Checked = false;
                         }

                     }
                     else
                     {
                         TeamCS.chk_QuestionPM.Checked = false;
                     }
                }
            }
        }