Imports BVSoftware.BVC.Core Imports BVSoftware.Utilities Public Class content_CategoryPage Inherits BaseAdminPage #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Protected WithEvents MetaDescriptionControl As BVSoftware.WebControls.MetaTag Protected WithEvents MetaKeywordsControl As BVSoftware.WebControls.MetaTag Protected WithEvents lstCol1 As System.Web.UI.WebControls.DropDownList Protected WithEvents dgCol1 As System.Web.UI.WebControls.DataGrid Protected WithEvents btnNew1 As System.Web.UI.WebControls.ImageButton 'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceholderDeclaration As System.Object 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.AccessContentArea) If Not Page.IsPostBack Then MetaKeywordsControl.Content = WebAppSettings.MetaKeywords MetaDescriptionControl.Content = WebAppSettings.MetaDescription LoadColumns() End If End Sub Private Sub LoadColumns() Try Me.dgCol1.DataSource = ContentServices.HomepageBlocks.GetByColumn(4) Me.dgCol1.DataBind() Catch ex As Exception Trace.Warn(ex.Message) End Try End Sub Private Sub dgCol1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgCol1.ItemDataBound If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then Dim block As Content.HomepageBlock = e.Item.DataItem If Not block Is Nothing Then Select Case block.BlockType Case Content.HomepageBlockType.CategoryGrid Try If block.Items.Length > 0 Then Dim cols1 As Integer = 1 cols1 = CInt(block.BlockContent) e.Item.Cells(1).Controls.Add(New LiteralControl("")) Dim colCounter1 As Integer = 0 For j As Integer = 0 To block.Items.Length - 1 colCounter1 += 1 If colCounter1 > cols1 Then e.Item.Cells(1).Controls.Add(New LiteralControl("")) colCounter1 = 1 End If e.Item.Cells(1).Controls.Add(New LiteralControl("")) Next While colCounter1 < cols1 colCounter1 += 1 e.Item.Cells(1).Controls.Add(New LiteralControl("")) End While e.Item.Cells(1).Controls.Add(New LiteralControl("
")) Dim cg As New UIControls.SingleCategoryDisplay cg.EnableViewState = False cg.LoadCategory(block.Items(j).ItemContent) e.Item.Cells(1).Controls.Add(cg) cg = Nothing e.Item.Cells(1).Controls.Add(New LiteralControl(" 
")) End If Catch ex As Exception End Try Case Content.HomepageBlockType.CustomHTML e.Item.Cells(1).Text = "HTML Rotator" Try Dim lbl As New System.Web.UI.WebControls.Label lbl.EnableViewState = False If block.Items.Length > 0 Then Dim index2 As Integer = RandomNumbers.RandomInteger(block.Items.Length - 1, 0) lbl.Text = block.Items(index2).ItemContent End If e.Item.Cells(1).Controls.Add(lbl) lbl = Nothing Catch ex As Exception End Try Case Content.HomepageBlockType.MailingListSignup Try Dim mlsu As New UIControls.MailingListSignupForm mlsu.ListID = block.BlockContent e.Item.Cells(1).Controls.Add(mlsu) mlsu = Nothing Catch ex As Exception End Try Case Content.HomepageBlockType.ProductGrid e.Item.Cells(1).Text = "Product Grid" Try If block.Items.Length > 0 Then Dim cols As Integer = 1 cols = CInt(block.BlockContent) e.Item.Cells(1).Controls.Add(New LiteralControl("")) Dim colCounter As Integer = 0 For l As Integer = 0 To block.Items.Length - 1 colCounter += 1 If colCounter > cols Then e.Item.Cells(1).Controls.Add(New LiteralControl("")) colCounter = 1 End If e.Item.Cells(1).Controls.Add(New LiteralControl("")) Next While colCounter < cols colCounter += 1 e.Item.Cells(1).Controls.Add(New LiteralControl("")) End While e.Item.Cells(1).Controls.Add(New LiteralControl("
")) Dim pg As New UIControls.SingleProductDisplay pg.EnableViewState = False pg.LoadProduct(block.Items(l).ItemContent) e.Item.Cells(1).Controls.Add(pg) pg = Nothing e.Item.Cells(1).Controls.Add(New LiteralControl(" 
")) End If Catch ex As Exception End Try Case Content.HomepageBlockType.SingleCategory e.Item.Cells(1).Text = "Category Rotator" Try If block.Items.Length > 0 Then Dim index5 As Integer = RandomNumbers.RandomInteger(block.Items.Length - 1, 0) Dim sc As New UIControls.SingleCategoryDisplay sc.EnableViewState = False sc.UseTinyImages = True sc.LoadCategory(block.Items(index5).ItemContent) e.Item.Cells(1).Controls.Add(sc) sc = Nothing End If Catch ex As Exception End Try Case Content.HomepageBlockType.SingleProduct e.Item.Cells(1).Text = "Product Rotator" Try If block.Items.Length > 0 Then Dim index6 As Integer = RandomNumbers.RandomInteger(block.Items.Length - 1, 0) Dim sp As New UIControls.SingleProductDisplay sp.EnableViewState = False sp.UseTinyImages = True sp.LoadProduct(block.Items(index6).ItemContent) e.Item.Cells(1).Controls.Add(sp) sp = Nothing End If Catch ex As Exception End Try Case Content.HomepageBlockType.SearchBox Try Dim sbf As New UIControls.SearchBoxForm e.Item.Cells(1).Controls.Add(sbf) sbf = Nothing Catch ex As Exception End Try Case Content.HomepageBlockType.CategoryList Dim catList As New UIControls.CategoryList e.Item.Cells(1).Controls.Add(catList) catList = Nothing Case Content.HomepageBlockType.CategoryList2 Dim catList As New UIControls.CategoryList2 e.Item.Cells(1).Controls.Add(catList) catList = Nothing End Select End If End If End Sub Private Sub dgCol1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCol1.UpdateCommand Dim blockID As Integer = dgCol1.DataKeys(e.Item.ItemIndex) If blockID > 0 Then ContentServices.HomepageBlocks.MoveUp(blockID, 4) End If LoadColumns() End Sub Private Sub dgCol1_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCol1.CancelCommand Dim blockID As Integer = dgCol1.DataKeys(e.Item.ItemIndex) If blockID > 0 Then ContentServices.HomepageBlocks.MoveDown(blockID, 4) End If LoadColumns() End Sub Private Sub dgCol1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCol1.EditCommand Dim blockID As Integer = dgCol1.DataKeys(e.Item.ItemIndex) If blockID > 0 Then Response.Redirect("content_Homepage_EditBlock.aspx?id=" & blockID & "&RURL=content_CategoryPage.aspx") End If End Sub Private Sub dgCol1_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCol1.DeleteCommand Dim blockID As Integer = dgCol1.DataKeys(e.Item.ItemIndex) If blockID > 0 Then ContentServices.HomepageBlocks.Delete(blockID) End If LoadColumns() End Sub Private Sub btnNew1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnNew1.Click NewBlock(4, lstCol1.SelectedValue) End Sub Private Sub NewBlock(ByVal columnNumber As Integer, ByVal blockType As Content.HomepageBlockType) Dim b As New Content.HomepageBlock b.ColumnNumber = columnNumber If blockType = Content.HomepageBlockType.MailingListSignup Then b.BlockContent = 0 ' List ID Else b.BlockContent = 2 End If b.BlockType = blockType If ContentServices.HomepageBlocks.CreateNew(b) = True Then Try If b.BlockType = Content.HomepageBlockType.CustomHTML Then Dim hbi As New Content.HomepageBlockItem hbi.BlockID = b.ID hbi.ItemContent = "Your HTML Goes Here" ContentServices.HomepageBlocks.AddItemToBlock(hbi, b.ID) End If Catch ex As Exception End Try Response.Redirect("content_Homepage_EditBlock.aspx?id=" & b.ID & "&DOC=1" & "&RURL=content_CategoryPage.aspx") Else LoadColumns() End If End Sub Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) End Sub End Class