====== Sample Code to Select a Tax Schedule ====== Select Tax Schedule is an ASP.net web page on the [[taxengine:integration:code_samples:c_estore_example|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 [[dynamiczip:glossary:Inventory Item]]. * btnScheduleSelect - A button the user can push to run [[taxengine:features: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 [[dynamiczip:glossary: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; } } } } } ---- [[taxengine:integration:code_samples:sample_code|Sample Code]]