Example #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);
        }
Example #2
0
        private async void modifyVinButton_Click(object sender, EventArgs e)
        {
            try
            {
                Response <uint> osidResponse = await this.vehicle.QueryOperatingSystemId();

                if (osidResponse.Status != ResponseStatus.Success)
                {
                    this.AddUserMessage("Operating system query failed: " + osidResponse.Status);
                    return;
                }

                PcmInfo info = new PcmInfo(osidResponse.Value);

                var vinResponse = await this.vehicle.QueryVin();

                if (vinResponse.Status != ResponseStatus.Success)
                {
                    this.AddUserMessage("VIN query failed: " + vinResponse.Status.ToString());
                    return;
                }

                DialogBoxes.VinForm vinForm = new DialogBoxes.VinForm();
                vinForm.Vin = vinResponse.Value;
                DialogResult dialogResult = vinForm.ShowDialog();

                if (dialogResult == DialogResult.OK)
                {
                    Response <bool> unlocked = await this.vehicle.UnlockEcu(info.KeyAlgorithm);

                    if (unlocked.Value)
                    {
                        Response <bool> vinmodified = await this.vehicle.UpdateVin(vinForm.Vin.Trim());

                        if (vinmodified.Value)
                        {
                            this.AddUserMessage("VIN successfully updated to " + vinForm.Vin);
                            MessageBox.Show("VIN updated to " + vinForm.Vin + " successfully.", "Good news.", MessageBoxButtons.OK);
                        }
                        else
                        {
                            MessageBox.Show("Unable to change the VIN to " + vinForm.Vin + ". Error: " + vinmodified.Status, "Bad news.", MessageBoxButtons.OK);
                        }
                    }
                    else
                    {
                    }
                }
            }
            catch (Exception exception)
            {
                this.AddUserMessage("VIN change failed: " + exception.ToString());
            }
        }