Пример #1
0
        /// <summary>
        /// Validate the VIN.
        /// </summary>
        private bool IsLegal()
        {
            bool isLegal = true;

            if (this.vinBox.Text.Length == 17)
            {
                this.prompt.Text = "The VIN is 17 characters long. Good!";
            }
            else
            {
                this.prompt.Text = $"The VIN must be 17 characters long. This is {this.vinBox.Text.Length}.";
                isLegal          = false;
            }

            if (VinForm.IsAlphaNumeric(this.vinBox.Text))
            {
                this.prompt2.Text = "The VIN contains only letters and numbers. Good!";
            }
            else
            {
                this.prompt2.Text = "The VIN must contain only letters and numbers.";
                isLegal           = false;
            }

            return(isLegal);
        }
Пример #2
0
        /// <summary>
        /// Validate the VIN.
        /// </summary>
        private bool IsLegal()
        {
            if (this.vinBox.Text.Length != 17)
            {
                this.prompt.Text = $"The VIN must be 17 characters long! This is {this.vinBox.Text.Length}.";
                return(false);
            }

            if (!VinForm.IsAlphaNumeric(this.vinBox.Text))
            {
                this.prompt.Text = "The VIN must contain only letters and numbers.";
                return(false);
            }

            this.vinBox.Text = this.vinBox.Text.ToUpper();

            if (IsVinChecksumOK(this.vinBox.Text))
            {
                this.prompt.Text = "The VIN is valid. Good!";
                return(true);
            }

            return(false);
        }