Esempio n. 1
0
        //
        // checkVat
        //
        private void simpleButton_Click(object sender, EventArgs e)
        {
            requestLabel.Text     = optionLabelText;
            this.Height           = 233;
            textBoxOutput.Visible = false;
            try
            {
                if (countryComboBox.SelectedItem != null && vatNumberTextBox.Text.Length >= 9)
                {
                    simpleButton.Enabled = false;
                    this.Cursor          = Cursors.WaitCursor;
                    VatModel viesVAT = CheckService.getDetails(countryCode, vatNumber);

                    if (viesVAT.Valid)
                    {
                        MessageBox.Show(
                            "VAT Number: " + viesVAT.VatNumber + "\n" + "Member State: " + viesVAT.CountryCode + "\n" + "is " + (viesVAT.Valid == true ? "VALID" : "INVALID") + "\n" +
                            "Name: " + viesVAT.Name + "\n" + "Address: " + viesVAT.Address,
                            "Results from EU VIES VAT Services",
                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        MessageBox.Show(
                            "The VAT Number: " + viesVAT.VatNumber + "\n" + "Member State: " + viesVAT.CountryCode + " is " + (viesVAT.Valid == true ? "VALID" : "INVALID"),
                            "VAT Number Validation",
                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show(
                        "Member State or VAT Number is incorect.",
                        "Warning",
                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "The service has responded with an error. " + ex.Message,
                    "Service error occurred",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                simpleButton.Enabled = true;
                this.Cursor          = Cursors.Default;
            }
        }
Esempio n. 2
0
        //
        // checkVatApprox
        //
        private void advancedButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (countryComboBox.SelectedItem != null &&
                    vatNumberTextBox.Text.Length >= 9 &&
                    countryRequesterComboBox.SelectedItem != null &&
                    vatNumberRequesterTextBox.Text.Length >= 9)
                {
                    advancedButton.Enabled = false;
                    this.Cursor            = Cursors.WaitCursor;

                    VatModelApprox viesVAT = CheckService.getDetails(countryCode, vatNumber, requesterCountryCode, requesterVatNumber);

                    if (viesVAT.Valid)
                    {
                        this.Height        = 400;
                        textBoxOutput.Text = viesVAT.MakeText();
                    }
                    else
                    {
                        this.Height        = 400;
                        textBoxOutput.Text = viesVAT.MakeText();
                    }
                    XmlDoc = viesVAT.MakeXml();
                    textBoxOutput.Visible = true;
                }
                else
                {
                    MessageBox.Show(
                        "Input parameters are incorrect.",
                        "Warning",
                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "The service has responded with an error. " + ex.Message,
                    "Service error occurred",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                advancedButton.Enabled = true;
                this.Cursor            = Cursors.Default;
            }
        }