Imports EDSL.Entities
Imports EDSL.DAL

Partial Public Class ProductControl
    Inherits System.Web.UI.UserControl
    Dim intLimit As Integer
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim objMainProduct As entMainProduct
        objMainProduct = GetProduct(Request.QueryString("pid"), Request.QueryString("cid"))


        Dim func As New miscFunctions
        With objMainProduct

            Dim categoryList As String
            categoryList = .CategoryTrail

            CType(Me.Parent.FindControl("breadcrumb"), Breadcrumb).SetProductLinks(.ProductName, categoryList)

            divContent.InnerHtml = .ProductDesc2

            Dim cpl As ContentPlaceHolder = TryCast(Page.Master.FindControl("ContentPlaceHolder1"), ContentPlaceHolder)
            Dim lbl As Label = TryCast(cpl.FindControl("labelPageTitle"), Label)
            lbl.Text = .ProductName
            If .ThumbImage <> "" Then
                imgProduct.ImageUrl += .ThumbImage.ToString()
            Else
                imgProduct.Visible = False
            End If

            'Find div on master page
            Dim masterPage As main = DirectCast(Me.Page.Master, main)
            masterPage.BodyTag.Attributes.Add("class", .DropDownValue.ToString())


            'Build enquire button
            hplContactUs.NavigateUrl += "?cid=" + Request.QueryString("cid") & "&pid=" & .ProductID.ToString()
            hplContactUs.Text += " " + .ProductName.ToString()

            'Unique extra bullet list for additional products
            If Request.QueryString("pid") = 3 Or Request.QueryString("pid") = 18 Then
                divExtraProductList.Visible = True

            End If

        End With


    End Sub
    
    Private Function GetProduct(ByVal intProductID As Integer, ByVal intCategoryID As Integer) As entMainProduct
        Dim objMain As New dbMainProduct
        Dim objMainProduct As entMainProduct = objMain.GetItemShowOnWebsite(intProductID, intCategoryID)
        Return objMainProduct
    End Function
End Class
