Ejemplo n.º 1
0
        private void SignUpButton_Click(object sender, EventArgs e)
        {
            string errors = "";

            if (string.IsNullOrWhiteSpace(NameTextBox.Text))
            {
                errors += "Name is empty.\n";
            }
            if (string.IsNullOrEmpty(FirstEventComboBox.Text))
            {
                errors += "Please choose the first event.\n";
            }
            if (string.IsNullOrEmpty(SecondEventComboBox.Text))
            {
                errors += "Please choose the second event.\n";
            }
            if (errors != "")
            {
                MessageBox.Show(errors, "Notification", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            try
            {
                Enum.TryParse(FirstEventComboBox.Text, out Event event1);
                Enum.TryParse(SecondEventComboBox.Text, out Event event2);
                Controller.AddParticipant(NameTextBox.Text, Convert.ToInt32(AgeSpinner.Value), event1, event2);
                MessageBox.Show("Registration complete", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }