Imports EDSL.Entities
Imports EDSL.DAL
Partial Public Class ProductEdit2Control
    Inherits System.Web.UI.UserControl
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        hypPage1.NavigateUrl = "~/ProductAdmin/edit1.aspx?id=" & Request.QueryString("id")

        txtProductDesc1.BaseHref = ConfigurationManager.AppSettings("BaseHref") & "PageEdit"
        txtProductDesc1.BasePath = ConfigurationManager.AppSettings("BasePath")
        txtProductDesc2.BaseHref = ConfigurationManager.AppSettings("BaseHref") & "PageEdit"
        txtProductDesc2.BasePath = ConfigurationManager.AppSettings("BasePath")

        If IsPostBack = False Then
            Call GetDetails(Request.QueryString("id"))
        End If
        btnBack.NavigateUrl = "~/ProductAdmin/edit1.aspx?id=" & txtID.Value

    End Sub
    Private Sub GetDetails(ByVal intProductID As Integer)
        Dim objMain As New dbMainProduct
        Dim objMainEntity As entMainProduct = objMain.GetItem(intProductID)
        txtID.Value = objMainEntity.ProductID
        txtProductName.Text = objMainEntity.ProductName

        txtProductDesc1.Value = objMainEntity.ProductDesc1
        txtProductDesc2.Value = objMainEntity.ProductDesc2
        txtProductDesc3.Text = objMainEntity.ProductDesc3
    End Sub
    Protected Sub btnDelete_click(ByVal sender As Object, ByVal e As EventArgs) Handles btnDelete.Click
        Dim objMain As New dbMainProduct
        Response.Redirect("Delete.aspx?id=" & txtID.Value & "&idtext=" & txtProductName.Text & "&r=e")
    End Sub
    Protected Sub btnSave_click(ByVal sender As Object, ByVal e As EventArgs) Handles btnExit.Click, btnSaveNext.Click
        Dim clsMisc As New miscFunctions
        Dim objGlobals As New TheGlobals
        Dim objMainAdmin As New dbMainProduct
        Dim intResultFromSave As Integer
        divErrorPanel.InnerHtml = ""
        intResultFromSave = objMainAdmin.SaveItemPage2(txtID.Value, txtProductDesc1.Value, txtProductDesc2.Value, txtProductDesc3.Text, Session("passover"))
        Select Case intResultFromSave
            Case 0
                divErrorPanel.InnerHtml = "Error saving product"
            Case Else
                If sender.id = "btnBack" Then
                    Response.Redirect("edit1.aspx?id=" & txtID.Value)
                ElseIf sender.id = "btnExit" Then
                    Response.Redirect("list.aspx")
                Else ' Next
                    Response.Redirect("edit3.aspx?id=" & txtID.Value)
                End If
        End Select
    End Sub
End Class
