User Tools

Site Tools


taxengine:integration:code_samples:zip_code_entry

Table of Contents

Zip Code Entry

ZIP Code Entry is an ASP.net web page on the eStore Example

Fields

  • txtZIPcode - A text box which allows the user to enter a U.S. ZIP Code.
  • btnZIPaddressing - A button the user can push to run ZipAddressing for the given ZIP Code.
  • txtCities - A read only text box which displays all the cities that exist in the given ZIP Code.
  • txtCounties - A read only text box which displays all the counties that exist in the given ZIP Code.
  • txtStates - A read only text box which displays the state(s) that exist in the given ZIP Code.

Code

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using KampData.TaxEngine;
using System.Runtime.InteropServices;
namespace eStoreExample
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void btnZIPaddressing_Click(object sender, EventArgs e)
        {
            ////Please enter your SQL login for "sa"
            string server = "SQLServerComputerName\\SQLinstance";
            string userId = "sa";
            string password = "P@ssw0rd";
            string companyDatabase = "TWO";
 

            bool abort = false;
            ArrayList cities = new ArrayList();
            ArrayList counties = new ArrayList();
            ArrayList states = new ArrayList();
          
            string loginMessage = "";
            txtCities.Text = "";
            txtCounties.Text = "";
            txtStates.Text = "";
            TaxEngine txEngn = new TaxEngine();
            try
            {
                loginMessage = txEngn.Login(server, userId, password, companyDatabase);
            }
            catch (Exception ea)
            {
                loginMessage = ea.Message;
            }
            if (loginMessage != "")
            {
                //txtMessage.Text = loginMessage;
                abort = true;
            }
            if (!abort)
            {
                string docNumber = "001";
                Int16 docType = -1;
                string module = "SOP";
                txEngn.Document(docNumber, docType, module);
                txEngn.DocTransactionType = TransactionType.Sales;
                
                int lineNumber = 1;
                txEngn.LineAdd(lineNumber);
               try
                {
                    txEngn.LineZip = txtZIPcode.Text;
                    states = txEngn.LineStatesInZip();
                    foreach (string state in states)
                    {
                        txtStates.Text = txtStates.Text + Convert.ToString(state) + ", ";
                    }
                    cities = txEngn.LineCitiesInStateAndZip();
                    foreach (string city in cities)
                    {
                        txtCities.Text = txtCities.Text + Convert.ToString(city) + ", ";
                    }
                    counties = txEngn.LineCountiesInCityStateAndZip();
                    foreach (string county in counties)
                    {
                        txtCounties.Text = txtCounties.Text + Convert.ToString(county) + ", ";
                    }            
                }
                catch (Exception ea)
                {
                    txtStates.Text = ea.Message;
                }    
            }
        }
    }
}

Sample Code

taxengine/integration/code_samples/zip_code_entry.txt · Last modified: 2016/09/22 17:19 by conni