Exemplo n.º 1
0
        private void CreateNewRound()
        {
            if (txt_Motion.ReadOnly)
            {
                txt_Motion.ReadOnly = false;
                txt_Motion.Text     = string.Empty;
                dgv_Round.Visible   = false;

                MessageBox.Show("Enter the motion for debate in this round");
                return;
            }

            string motion = txt_Motion.Text;

            if (string.IsNullOrWhiteSpace(motion))
            {
                MessageBox.Show("Please enter a motion for debate in this round");
                return;
            }

            if (_context.Speakers.Count(s => s.Active) % 6 != 0)
            {
                MessageBox.Show(string.Format("There are an incorrect number of speakers active to draw a round. You require either {0} or {1} and you currently have {2}", Math.Floor(((decimal)_context.Speakers.Count(s => s.Active) / 6 - 1) * 6), Math.Ceiling(((decimal)_context.Speakers.Count(s => s.Active) / 6 + 1) * 6), _context.Speakers.Count(s => s.Active)));
                return;
            }

            if (_context.Speakers.Count / 6 > _context.Venues.Count(v => v.Active))
            {
                MessageBox.Show(string.Format("There are not enough venues active to draw a round. You require {0} and you currently have {1}.", _context.Speakers.Count(s => s.Active) / 6, _context.Venues.Count(v => v.Active)));
                return;
            }

            bool  isPowerPaired = chk_Powerpair.Checked;
            Round round         = RoundHelper.DrawRound(_tournament, motion, isPowerPaired);

            LoadRounds();
            cmb_Rounds.SelectedIndex = cmb_Rounds.Items.Count - 1;
            LoadRound();
        }