Table of Contents

Zip Code Entry

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

Fields

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