Imports CAMS_ADMIN
Imports CAMS_BL
Imports System.Data
Imports System.Text

Public Class frmByCaseId
    Inherits CAMSBasePage

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object
    Protected WithEvents txtCaseId As System.Web.UI.WebControls.TextBox
    Protected WithEvents lblValCaseId As System.Web.UI.WebControls.Label
    Protected WithEvents hdEvent As System.Web.UI.HtmlControls.HtmlInputHidden
    Protected WithEvents mnuCams As Menu

    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
        'Access Validation to page
        If Not Me.IsPostBack Then
            Dim oEC_User As EC_User = Me.GetUserFromSession

            If Not oEC_User Is Nothing Then
                If Me.HasAccessTo(Me.GetControlID("frmByCaseId.aspx"), oEC_User.AccessGroup) = False Then
                    Me.RedirectToMsgPage(Constants.CONST_ERROR_ACCESSDENIED_TOPAGE)
                End If
            End If

        End If
        'End Access Validation

        mnuCams.CurrentGroup = Constants.MENU_SEARCH_ID
        mnuCams.CurrentItem = Constants.MENU_SEARCH_CASEBYID_ID

        txtCaseId.Attributes.Add("onkeypress", "javascript:if(event.keyCode==13)fnSearch();")

        If IsPostBack Then
            If hdEvent.Value = "search" Then
                Search()
            ElseIf hdEvent.Value = "cancel" Then
                SetCancel()
            End If

        End If

        'Added by Raul Callupe
        If Me.IsPostBack = False Then
            Dim stbOutput As New StringBuilder
            stbOutput.Append("<script language='Javascript'>")
            stbOutput.Append("var pag = window.parent.frames(0);")
            stbOutput.Append("pag.document.all.lblPath.innerHTML='Search/Case by ID'")
            stbOutput.Append("</script>")
            Response.Write(stbOutput.ToString)
        End If
        'End Added
    End Sub

    Private Sub SetCancel()

        Me.RedirectToHome()

    End Sub

    Private Sub Search()
        Dim oCC_Case As New CC_Case

        If oCC_Case.CaseExists(txtCaseId.Text.Trim) Then
            Me.Response.Redirect(Me.ApplicationPath & "/New/frmCase.aspx?action=u&caseid=" & txtCaseId.Text.Trim, True)
        Else
            lblValCaseId.Text = "Invalid Case ID"
            lblValCaseId.Visible = True
        End If

    End Sub

End Class
