コード例 #1
0
        //various checks for a coreectly filled out form
        private void submitButton_Click(object sender, EventArgs e)
        {
            if (!fn_watermarked)
            {
                MessageBox.Show("Please enter your first name.", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (!ln_watermarked)
            {
                MessageBox.Show("Please enter your last name.", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (dayComboBox.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a day.", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (monthComboBox.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a month.", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (yearComboBox.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a year.", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (genderComboBox.SelectedIndex == -1)
            {
                MessageBox.Show("Please select your gender.", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (termsCheckBox.Checked == false)
            {
                MessageBox.Show("Please accept the Terms & Conditions.", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (DateTime.Today.Year - ( int )yearComboBox.SelectedItem < 18)
            {
                MessageBox.Show("You must be over 18 to Play.", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                string first_name = wordFormatter(firstNameTextBox.Text);
                string last_name  = wordFormatter(lastNameTextBox.Text);
                string gender     = string.Empty;
                int    age        = DateTime.Today.Year - ( int )yearComboBox.SelectedItem;

                StringBuilder dialog = new StringBuilder();

                if (genderComboBox.SelectedIndex == 0)
                {
                    gender = "He";
                }
                else
                {
                    gender = "She";
                }

                dialog.Append("The current player is " + first_name + " " + last_name + ".\n");
                dialog.Append(gender + " is " + age.ToString() + " years of age.\n");
                dialog.Append(gender + " has accepted the Terms and Conditions of Play.");

                MessageBox.Show(dialog.ToString(), "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.Hide();
                Form2 form2 = new Form2();
                form2.ShowDialog();
                this.Close();
            }
        }