Exemple #1
0
        private void buttonValidate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxCardNumber.Text))
            {
                MessageBox.Show("Please enter a valid number!");
                return;
            }

            bool valid = false;

            switch ((string)comboBoxType.SelectedItem)
            {
            case "Luhn Check":
                valid = LuhnChecker.LuhnValidate(textBoxCardNumber.Text);
                break;

            case "Visa":
                valid = LuhnChecker.LuhnValidate(textBoxCardNumber.Text, LuhnChecker.checkType.Visa);
                break;

            default:
                throw new Exception("Something went wrong!");
            }

            MessageBox.Show(valid ? "Valid" : "Not Valid");
        }
Exemple #2
0
 private void buttonComputeCheck_Click(object sender, EventArgs e)
 {
     MessageBox.Show(LuhnChecker.LuhnCreate(textBoxCardNumber.Text, out _).ToString());
 }