Imports EDSL.Entities
Imports EDSL.DAL
Partial Public Class CaseStudyEdit2Control
    Inherits System.Web.UI.UserControl
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        txtCaseStudytext.BaseHref = ConfigurationManager.AppSettings("BaseHref") & "CaseStudyAdmin"
        txtCaseStudytext.BasePath = ConfigurationManager.AppSettings("BasePath")
        hypPage1.NavigateUrl = "~/CaseStudyAdmin/edit1.aspx?id=" & Request.QueryString("id")
        hypPage3.NavigateUrl = "~/CaseStudyAdmin/edit3.aspx?id=" & Request.QueryString("id")
        If IsPostBack = False Then
            Call GetDetails(Request.QueryString("id"))
        End If
        btnBack.NavigateUrl = "~/CaseStudyAdmin/edit1.aspx?id=" & txtID.Value

    End Sub
    Private Sub GetDetails(ByVal intCaseStudyID As Integer)
        Dim objMain As New dbMainCaseStudy
        Dim objMainEntity As entMainCaseStudy = objMain.GetItem(intCaseStudyID)

        With objMainEntity
            txtID.Value = .CaseStudyID
            txtCaseStudyHeadline.Text = .CaseStudyHeadline
            txtCaseStudytext.Value = .CaseStudyText
            txtTestimonial.Text = .Testimonial
            txtTestimonialSignature.Text = .TestimonialSignature
        End With
    End Sub
    Protected Sub btnDelete_click(ByVal sender As Object, ByVal e As EventArgs) Handles btnDelete.Click
        Dim objMain As New dbMainCaseStudy
        Response.Redirect("Delete.aspx?id=" & txtID.Value & "&idtext=" & txtCaseStudyHeadline.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 dbMainCaseStudy
        Dim intResultFromSave As Integer
        divErrorPanel.InnerHtml = ""

        intResultFromSave = objMainAdmin.SaveItemPage2(txtID.Value, txtCaseStudytext.Value.ToString, txtTestimonial.Text, txtTestimonialSignature.Text, Session("passover"))
        Select Case intResultFromSave
            Case 0
                divErrorPanel.InnerHtml = "Error saving case study"
            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