Imports BVSoftware.BVC.Core Public Class configuration_taxes Inherits BaseAdminPage #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Protected WithEvents DeleteButton As MetaBuilders.WebControls.ConfirmedImageButton Protected WithEvents MetaDescriptionControl As BVSoftware.WebControls.MetaTag Protected WithEvents MetaKeywordsControl As BVSoftware.WebControls.MetaTag Protected WithEvents dgTaxes As System.Web.UI.WebControls.DataGrid Protected WithEvents msg As BVSoftware.WebControls.WebPageMessage Protected WithEvents btnAddTax As System.Web.UI.WebControls.ImageButton Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) Handles MyBase.Load BVC2004Store.CheckThisPage(Security.RolePermission.LoginToAdmin) BVC2004Store.CheckThisPage(Security.RolePermission.AccessSettingsArea) If Not Page.IsPostBack Then MetaKeywordsControl.Content = WebAppSettings.MetaKeywords MetaDescriptionControl.Content = WebAppSettings.MetaDescription End If If Not Page.IsPostBack Then LoadTaxes() End If End Sub Sub LoadTaxes() Try dgTaxes.DataSource = TaxServices.ListTaxes() dgTaxes.DataBind() Catch Ex As Exception msg.ShowException(Ex) End Try End Sub Public Sub dgTaxes_Delete(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgTaxes.DeleteCommand Dim deleteID As String = dgTaxes.DataKeys(e.Item.ItemIndex) TaxServices.DeleteTax(deleteID) LoadTaxes() End Sub Public Sub dgTaxes_PageIndexChanged(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgTaxes.PageIndexChanged dgTaxes.CurrentPageIndex = e.NewPageIndex LoadTaxes() End Sub Private Sub btnAddTax_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnAddTax.Click msg.Clear() Try Dim responseID As Integer = 0 Dim t As New Taxes.Tax t.CountryCode = "en-US" t.RegionID = 0 t.PostalCode = "" t.Rate = 0.0 If t.Save() = True Then responseID = t.ID End If If responseID > 0 Then Response.Redirect("configuration_taxes_edit.aspx?mode=new&id=" & responseID.ToString, True) Else msg.ShowError("Unable to add new tax!") End If Catch Ex As Exception msg.ShowException(Ex) End Try End Sub Private Sub dgTaxes_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgTaxes.ItemDataBound If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then Dim editID As Integer = dgTaxes.DataKeys(e.Item.ItemIndex) Dim t As New Taxes.Tax If t.Load(editID) = True Then Dim CountryInfo As Label = e.Item.FindControl("CountryInfo") Dim RegionInfo As Label = e.Item.FindControl("RegionInfo") Dim PostalCodeInfo As Label = e.Item.FindControl("PostalCodeInfo") Dim TaxTypeInfo As Label = e.Item.FindControl("TaxTypeInfo") Dim RateInfo As Label = e.Item.FindControl("RateInfo") If Not CountryInfo Is Nothing Then Dim c As Content.Country = ContentServices.Countries.GetByCode(t.CountryCode) If Not c Is Nothing Then CountryInfo.Text = c.DisplayName Else CountryInfo.Text = t.CountryCode End If c = Nothing End If If Not RegionInfo Is Nothing Then If t.RegionID > 0 Then Dim r As New Content.Region If r.Load(t.RegionID) = True Then RegionInfo.Text = r.Name Else RegionInfo.Text = t.CountryCode End If r = Nothing Else RegionInfo.Text = "All States/Regions" End If End If If Not PostalCodeInfo Is Nothing Then If t.PostalCode.Trim.Length > 0 Then PostalCodeInfo.Text = t.PostalCode Else PostalCodeInfo.Text = "All Zip/Postal Codes" End If End If If Not TaxTypeInfo Is Nothing Then If t.TaxClass > 0 Then Dim tc As New Taxes.TaxClass If tc.Load(t.TaxClass) = True Then TaxTypeInfo.Text = tc.DisplayName Else TaxTypeInfo.Text = t.TaxClass End If tc = Nothing Else TaxTypeInfo.Text = "All Taxable Items" End If End If If Not RateInfo Is Nothing Then RateInfo.Text = String.Format("{0:p}", t.Rate / 100) End If CountryInfo = Nothing RegionInfo = Nothing PostalCodeInfo = Nothing TaxTypeInfo = Nothing RateInfo = Nothing End If t = Nothing End If End Sub End Class