private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Please Enter Your Credit Card Number", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Focus(); return; } else if (textBox1.TextLength < 16) { MessageBox.Show("Credit card number must contain 16 digits", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Focus(); return; } else if (textBox1.TextLength > 16) { MessageBox.Show("Credit card number must contain 16 digits", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Focus(); return; } else if (testForNonNumeric.IsMatch(textBox1.Text)) { MessageBox.Show("Credit card number must contain digits only", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Focus(); return; } if (comboBox1.SelectedIndex == -1) //Nothing selected { MessageBox.Show("Please enter credit card expiry date", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboBox1.Focus(); return; } if (comboBox2.SelectedIndex == -1) //Nothing selected { MessageBox.Show("Please enter credit card expiry date", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboBox2.Focus(); return; } if (Convert.ToInt32(comboBox1.SelectedItem) < 10 && Convert.ToInt32(comboBox2.SelectedItem) == 15) { MessageBox.Show("Credit Card is expired", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboBox1.Focus(); return; } else if (textBox3.Text == "") { MessageBox.Show("Please Enter Your CVV Number", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox3.Focus(); return; } else if (textBox3.TextLength < 3) { MessageBox.Show("CVV number must contain 3 digits", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox3.Focus(); return; } else if (textBox3.TextLength > 3) { MessageBox.Show("CVV number must contain 3 digits", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox3.Focus(); return; } else if (testForNonNumeric.IsMatch(textBox3.Text)) { MessageBox.Show("CVV number must contain digits only", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox3.Focus(); return; } else { payment = PopulateObject(aBooking); aBooking.DepositPaid = "true"; bookingController.Edit(aBooking); paymentController.ADD(payment); MessageBox.Show("Your payment has been verified", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); ConfirmationForm cf = new ConfirmationForm(aGuest, aBooking); cf.StartPosition = FormStartPosition.CenterParent; cf.Show(); this.Hide(); } }