Ejemplo n.º 1
0
    public static SqlString VAT_VIES_INFO(SqlString VAT_number)
    {
        string    input  = VAT_number.ToString();
        SqlString output = new SqlString();

        if (input.Length < 4)
        {
            output = "!ERROR: Input Number Invalid";
            return(output);
        }

        string input_country = input.Substring(0, 2);
        string input_number  = input.Substring(2);

        try
        {
            VIESCheckVatService.IVIESCheckVatService iCheckVatService = VIESCheckVatService.VIESCheckServiceFactory.getService(ServiceType.SOAP);
            VIESCheckVatService.VIESVatModel         vatModel         = iCheckVatService.getDetailVAT(input_country, input_number);

            if (vatModel.Valid)
            {
                output = vatModel.Name + "/" + vatModel.Address + "/" + vatModel.RequestDate;
            }
            else
            {
                output = "";
            }
        }
        catch (Exception ex)
        {
            output = "!ERROR: " + ex.Message;
        }

        return(output);
    }
    public static SqlInt16 VAT_VIES_VALIDITY(SqlString VAT_number)
    {
        string   input  = VAT_number.ToString();
        SqlInt16 output = new SqlInt16();

        if (input.Length < 4)
        {
            output = -2;
            return(output);
        }

        string input_country = input.Substring(0, 2);
        string input_number  = input.Substring(2);



        try
        {
            VIESCheckVatService.IVIESCheckVatService iCheckVatService = VIESCheckVatService.VIESCheckServiceFactory.getService(ServiceType.SOAP);
            VIESCheckVatService.VIESVatModel         vatModel         = iCheckVatService.getDetailVAT(input_country, input_number);

            output = Convert.ToInt16(vatModel.Valid);
        }
        catch (Exception ex)
        {
            output = -1;
        }

        return(output);
    }
Ejemplo n.º 3
0
        private void button_Verify_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                if (row.Cells[0].Value == null)
                {
                    continue;
                }
                try
                {
                    string input = row.Cells[0].Value.ToString();

                    if (input.Length >= 4)
                    {
                        string input_country = input.Substring(0, 2);
                        string input_number  = input.Substring(2);

                        VIESCheckVatService.IVIESCheckVatService iCheckVatService = VIESCheckVatService.VIESCheckServiceFactory.getService(ServiceType.SOAP);
                        VIESCheckVatService.VIESVatModel         vatModel         = iCheckVatService.getDetailVAT(input_country, input_number);
                        O
                        row.Cells[1].Value = vatModel.Valid;
                        row.Cells[2].Value = vatModel.Name;
                        row.Cells[3].Value = vatModel.Address;
                        row.Cells[4].Value = vatModel.RequestDate;
                        row.Cells[5].Value = "Success";
                    }
                }

                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    row.Cells[5].Value = ex.Message;
                }
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            try
            {
                VIESCheckVatService.IVIESCheckVatService iCheckVatService = VIESCheckVatService.VIESCheckServiceFactory.getService(ServiceType.SOAP);

                while (true)
                {
                    Console.WriteLine("VAT Country?");
                    string VAT_country = Console.ReadLine();
                    Console.WriteLine("VAT Number?");
                    string VAT_number = Console.ReadLine();

                    VIESCheckVatService.VIESVatModel vatModel = iCheckVatService.getDetailVAT(VAT_country, VAT_number);

                    Console.Out.WriteLine("Valid: " + vatModel.Valid);
                    Console.Out.WriteLine("County Code: " + vatModel.CountryCode);
                    Console.Out.WriteLine("VAT Number: " + vatModel.VatNumber);
                    Console.Out.WriteLine("Request Date: " + vatModel.RequestDate);
                    Console.Out.WriteLine("Org. Name: " + vatModel.Name);
                    Console.Out.WriteLine("Org. Address: " + vatModel.Address);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(
                    "The service has responded with an error. " + ex.Message,
                    "Service error occurred");
                Console.ReadKey();
            }
        }
        void BtnVerifyVATClick(object sender, System.EventArgs e)
        {
            try {
                if (comboMemberState.SelectedItem != null && textBoxVatNumber.Text.Length >= 11)
                {
                    btnVerifyVAT.Enabled = false;
                    this.Cursor          = Cursors.WaitCursor;

                    VIESCheckVatService.IVIESCheckVatService iCheckVatService =
                        VIESCheckVatService.VIESCheckServiceFactory.getService(ServiceType.SOAP);
                    VIESCheckVatService.VIESVatModel vatModel = iCheckVatService.getDetailVAT(comboMemberState.SelectedItem.ToString().Split('-')[0], textBoxVatNumber.Text);

                    treeViewResult.Nodes.Clear();
                    TreeNode rootResultsNode;
                    rootResultsNode = treeViewResult.Nodes.Add("Results from EU VIES VAT Services");
                    rootResultsNode.Nodes.Add("Result: " + vatModel.Valid);

                    if (vatModel.Valid)
                    {
                        treeViewResult.Nodes[0].FirstNode.ForeColor = Color.Green;
                        rootResultsNode.Nodes.Add("County Code: " + vatModel.CountryCode);
                        rootResultsNode.Nodes.Add("VAT Number: " + vatModel.VatNumber);
                        rootResultsNode.Nodes.Add("Request Date: " + vatModel.RequestDate);
                        rootResultsNode.Nodes.Add("Org. Name: " + vatModel.Name);
                        rootResultsNode.Nodes.Add("Org. Address: " + vatModel.Address);
                    }
                    else
                    {
                        rootResultsNode.FirstNode.ForeColor = Color.Red;
                    }

                    rootResultsNode.ExpandAll();
                }
                else
                {
                    MessageBox.Show(
                        "The two required parameters are required.",
                        "Required parameters",
                        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 {
                btnVerifyVAT.Enabled = true;
                this.Cursor          = Cursors.Default;
            }
        }