/// <summary> /// List of Country from Cache Data /// </summary> public void BindShippingCountries(bool setValue) { ddlShippingCountry.DataSource = CountryManager.GetActiveCountry(); ddlShippingCountry.DataBind(); if (setValue) { ddlShippingCountry.Items.FindByValue(ConfigHelper.DefaultCountry).Selected = true; } }
protected void Page_Load(object sender, EventArgs e) { //Check Session Validation in BasePage this.BaseLoad(); if (!Page.IsPostBack) { ddlProducts.DataSource = CountryManager.GetActiveCountry(); ddlProducts.DataTextField = "Name"; ddlProducts.DataValueField = "CountryId"; ddlProducts.DataBind(); BindTaxRegion(); } }
protected void Page_Load(object sender, EventArgs e) { //Check Session Validation in BasePage this.BaseLoad(); if (!Page.IsPostBack) { lblSuccess.Text = ResourceHelper.GetResoureValue("LabelSuccess"); lblCancel.Text = ResourceHelper.GetResoureValue("LabelCancel"); ddlProducts.DataSource = CountryManager.GetActiveCountry(); ddlProducts.DataTextField = "Name"; ddlProducts.DataValueField = "CountryId"; ddlProducts.DataBind(); BindTaxRegion(); } }
protected void btnSave_OnClick(object sender, CommandEventArgs e) { if (e.CommandName == "Save") { if (this.dlCountryList.Items.Count > 0) { Dictionary <int, decimal> itemList = new Dictionary <int, decimal>(); foreach (DataListItem lst in dlCountryList.Items) { if ((lst.ItemType == ListItemType.Item) || (lst.ItemType == ListItemType.AlternatingItem)) { int regionId = (int)dlCountryList.DataKeys[lst.ItemIndex]; TextBox txtOrderNo = (TextBox)lst.FindControl("txtOrderNo"); decimal percentage = Convert.ToDecimal(txtOrderNo.Text); itemList.Add(regionId, percentage); } } AdminDAL.SaveCountryTax(itemList); } lblSuccess.Visible = true; lblCancel.Visible = false; } else { ddlProducts.DataSource = CountryManager.GetActiveCountry(); ddlProducts.DataTextField = "Name"; ddlProducts.DataValueField = "CountryId"; ddlProducts.DataBind(); BindTaxRegion(); lblCancel.Visible = true; lblSuccess.Visible = false; } //redirect //Response.Redirect("Main.aspx"); }
public static GetTaxRequest GetTax_Request(int orderId, bool UpdateOrderTax, bool CartTax, ClientCartContext clientData) { string ShippingStateProvinceAbbreviation = ""; // string BillingStateProvinceAbbreviation = ""; List <StateProvince> states = StateManager.GetAllStates(0); XmlNode config = null; config = GetTax_AvalaraConfig(); GetTaxRequest getTaxRequest = new GetTaxRequest(); List <Sku> OrderSkuItems = null; CSWeb.AvaTax.Address address1 = new CSWeb.AvaTax.Address(); address1.AddressCode = "01"; address1.Line1 = config.Attributes["address1Line1"].Value; address1.City = config.Attributes["City"].Value; address1.Region = config.Attributes["Region"].Value; CSWeb.AvaTax.Address address2 = new CSWeb.AvaTax.Address(); address2.AddressCode = "02"; if (orderId > 0 && CartTax == false) { CSBusiness.OrderManagement.Order orderItem = new OrderManager().GetBatchProcessOrder(orderId); getTaxRequest.CustomerCode = orderItem.CustomerId.ToString(); // "ABC4335"; //getTaxRequest.CompanyCode = config.Attributes["companyCode"].Value; getTaxRequest.DocDate = orderItem.CreatedDate.ToString("yyyy-MM-dd"); // "2014-07-23"; address2.Line1 = orderItem.CustomerInfo.ShippingAddress.Address1; // "1999 Avenue of Stars"; // "118 N Clark St"; address2.Line2 = orderItem.CustomerInfo.ShippingAddress.Address2; // "Suite 1830"; // "Suite 100"; // address2.Line3 = "ATTN Accounts Payable"; address2.City = orderItem.CustomerInfo.ShippingAddress.City; // "Los Angeles"; // "Chicago"; StateProvince itemShippingStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(orderItem.CustomerInfo.ShippingAddress.StateProvinceId)); if (itemShippingStateProvince != null) { ShippingStateProvinceAbbreviation = itemShippingStateProvince.Abbreviation.Trim(); } //StateProvince itemBillingStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(orderItem.CustomerInfo.BillingAddress.StateProvinceId)); //if (itemBillingStateProvince != null) //{ // BillingStateProvinceAbbreviation = itemBillingStateProvince.Abbreviation.Trim(); //} address2.Region = ShippingStateProvinceAbbreviation; // "IL"; address2.Country = orderItem.CustomerInfo.ShippingAddress.CountryCode.Trim(); // "US"; address2.PostalCode = orderItem.CustomerInfo.ShippingAddress.ZipPostalCode; // "90067"; // "60602"; OrderSkuItems = orderItem.SkuItems; } else if (CartTax) { StateProvince itemShippingStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(clientData.CustomerInfo.ShippingAddress.StateProvinceId)); if (itemShippingStateProvince != null) { ShippingStateProvinceAbbreviation = itemShippingStateProvince.Abbreviation.Trim(); } getTaxRequest.CustomerCode = "1"; // "ABC4335"; //getTaxRequest.CompanyCode = config.Attributes["companyCode"].Value; getTaxRequest.DocDate = DateTime.Now.ToString("yyyy-MM-dd"); // "2014-07-23"; address2.Line1 = clientData.CustomerInfo.ShippingAddress.Address1; // "1999 Avenue of Stars"; // "118 N Clark St"; address2.Line2 = clientData.CustomerInfo.ShippingAddress.Address2; // "Suite 1830"; // "Suite 100"; // address2.Line3 = "ATTN Accounts Payable"; address2.City = clientData.CustomerInfo.ShippingAddress.City; // "Los Angeles"; // "Chicago"; address2.Region = ShippingStateProvinceAbbreviation; // "IL"; List <Country> countries = CountryManager.GetActiveCountry(); Country ShipCountry = countries.First(x => x.CountryId == clientData.CustomerInfo.ShippingAddress.CountryId); // address2.Country = "US"; // clientData.CustomerInfo.ShippingAddress.CountryCode.Trim(); // "US"; if (itemShippingStateProvince != null) { address2.Country = ShipCountry.Code.Trim(); } else { address2.Country = "US"; } address2.PostalCode = clientData.CustomerInfo.ShippingAddress.ZipPostalCode; // "90067"; // "60602"; OrderSkuItems = clientData.CartInfo.CartItems; } CSWeb.AvaTax.Address[] addresses = { address1, address2 }; getTaxRequest.Addresses = addresses; CSWeb.AvaTax.Line[] lines = new CSWeb.AvaTax.Line[OrderSkuItems.Count]; // orderItem.SkuItems.Count]; int LineNo = 1; foreach (Sku Item in OrderSkuItems) // orderItem.SkuItems) { Item.LoadAttributeValues(); CSWeb.AvaTax.Line line1 = new CSWeb.AvaTax.Line(); if (LineNo < 10) { line1.LineNo = "0" + LineNo.ToString(); } else { line1.LineNo = LineNo.ToString(); } line1.ItemCode = Item.SkuCode; line1.Qty = Item.Quantity; decimal SKUCost = Item.FullPrice * Item.Quantity; // 249.95M; //if (Item.AttributeValues.ContainsKey("isrushshipsku")) //{ // if (Item.AttributeValues["isrushshipsku"].Value.ToString().Equals("1")) // { // if (Item.AttributeValues.ContainsKey("shippingcost_display")) // { // SKUCost = Convert.ToDecimal(Item.AttributeValues["shippingcost_display"].Value.ToString().Trim()); // } // } //} line1.Amount = SKUCost; line1.OriginCode = "01"; line1.DestinationCode = "02"; lines[LineNo - 1] = line1; // Add it Array of Lines LineNo = LineNo + 1; } getTaxRequest.Lines = lines; getTaxRequest.CompanyCode = config.Attributes["companyCode"].Value; return(getTaxRequest); }