Imports BVSoftware.BVC.Core Public Class products_categories_delete Inherits BaseAdminPage Protected WithEvents lblCategoryName As System.Web.UI.WebControls.Label Protected WithEvents btnCancel As System.Web.UI.WebControls.ImageButton Protected WithEvents btnDelete As System.Web.UI.WebControls.ImageButton Protected WithEvents MetaDescriptionControl As BVSoftware.WebControls.MetaTag Protected WithEvents msg As BVSoftware.WebControls.WebPageMessage Protected WithEvents MetaKeywordsControl As BVSoftware.WebControls.MetaTag #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 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load BVC2004Store.CheckThisPage(Security.RolePermission.LoginToAdmin) BVC2004Store.CheckThisPage(Security.RolePermission.AccessProductArea) If Not Page.IsPostBack Then MetaKeywordsControl.Content = WebAppSettings.MetaKeywords MetaDescriptionControl.Content = WebAppSettings.MetaDescription End If btnDelete.Visible = True msg.Clear() msg.MessageMode = BVSoftware.WebControls.WebPageMessageMode.Question ViewState("returnID") = Request.Params("retID") Dim sDeleteID As String sDeleteID = Request.Params("id") If sDeleteID = Nothing Then Response.Redirect("products_categories.aspx", True) Else ViewState("CategoryID") = sDeleteID Dim c As Catalog.Category c = CatalogServices.Categories.GetCategory(sDeleteID) If Not c Is Nothing Then Dim dtSubs As DataTable dtSubs = CatalogServices.Categories.ListChildCategories(c.ID) If dtSubs.Rows.Count() > 0 Then lblCategoryName.Text = "Delete " & c.Name & "?" msg.ShowWarning("Please delete sub categories first.") btnDelete.Visible = False Else If CatalogServices.Categories.GetItemCount(c) > 0 Then lblCategoryName.Text = "Delete " lblCategoryName.Text += c.Name lblCategoryName.Text += " ?" msg.ShowQuestion(" This category has " & _ "" & _ CatalogServices.Categories.GetItemCount(c).ToString & _ " items assigned to it.") Else CatalogServices.Categories.DeleteCategory(sDeleteID) Response.Redirect("products_categories.aspx?CategoryID=" & ViewState("returnID")) End If End If Else Response.Redirect("products_categories.aspx") End If End If End Sub Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnCancel.Click Response.Redirect("products_categories.aspx") End Sub Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnDelete.Click CatalogServices.Categories.DeleteCategory(ViewState("CategoryID")) Response.Redirect("products_categories.aspx?CategoryID=" & ViewState("returnID")) End Sub End Class