User Tools

Site Tools


taxengine:integration:code_samples:select_tax_schedule

Sample Code to Select a Tax Schedule

Select Tax Schedule 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.
  • txtCustomer - A text box which allows the user to enter a GP customer.
  • txtItem - A text box which allows the user to enter a GP Inventory Item.
  • btnScheduleSelect - A button the user can push to run Tax Schedule Selection for the given ZIP Code, customer and inventory item.
  • txtMessage - A read only text box which displays all the cities, counties and state(s) that exist in the given ZIP Code.
  • txtSchedule - A read only text box which displays the selected Tax Schedule ID.

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 WebForm11 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnScheduleSelect_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 = "";
            txtMessage.Text = "";
            txtSchedule.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;
                
                if (txtCustomer.Text != "")
                {
                    txEngn.DocCustomerID = txtCustomer.Text;
                }

                int lineNumber = 1;
                txEngn.LineAdd(lineNumber);
                txEngn.LineItemNumber = txtItem.Text;
                

                try
                {
                    txEngn.LineZip = txtZIPcode.Text;

                    states = txEngn.LineStatesInZip();
                    txtMessage.Text = "States in ZIP: ";
                    foreach (string state in states)
                    {
                        txtMessage.Text = txtMessage.Text + Convert.ToString(state) + ", ";
                    }
                    cities = txEngn.LineCitiesInStateAndZip();
                    txtMessage.Text = txtMessage.Text + "Cities: ";

                    foreach (string city in cities)
                    {
                        txtMessage.Text = txtMessage.Text + Convert.ToString(city) + ", ";
                    }
                    counties = txEngn.LineCountiesInCityStateAndZip();
                    txtMessage.Text = txtMessage.Text + "Counties: ";

                    foreach (string county in counties)
                    {
                        txtMessage.Text = txtMessage.Text + Convert.ToString(county) + ", ";
                    }

                    txEngn.LineInCityLimits = true;
                    txtSchedule.Text = txEngn.LineTaxScheduleID;
                }
                catch (Exception ea)
                {
                    txtMessage.Text = ea.Message;
                }
            }
        }
    }
}

Sample Code

taxengine/integration/code_samples/select_tax_schedule.txt · Last modified: 2015/06/12 20:07 by conni

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki