Imports CAMS_ADMIN
Imports CAMS_BL
Imports System.Data
Imports System.Text
Imports System.Globalization

Public Class frmHome
    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 pnlCaseSumm As System.Web.UI.WebControls.Panel
    Protected WithEvents pnlMyWorkingCases As System.Web.UI.WebControls.Panel
    Protected WithEvents lblTotNormal As System.Web.UI.WebControls.Label
    Protected WithEvents lblTotAtt As System.Web.UI.WebControls.Label
    Protected WithEvents lblTotImAtt As System.Web.UI.WebControls.Label
    Protected WithEvents lblTotClosed As System.Web.UI.WebControls.Label
    Protected WithEvents lblTotCanc As System.Web.UI.WebControls.Label
    Protected WithEvents lblAGNormal As System.Web.UI.WebControls.Label
    Protected WithEvents lblAGAtt As System.Web.UI.WebControls.Label
    Protected WithEvents lblAGImAtt As System.Web.UI.WebControls.Label
    Protected WithEvents lblTitleCS As System.Web.UI.WebControls.Label
    Protected WithEvents lblTitleMyWC As System.Web.UI.WebControls.Label
    Protected WithEvents btnSCases As System.Web.UI.WebControls.Button
    Protected WithEvents Image1 As System.Web.UI.WebControls.Image
    Protected WithEvents Image2 As System.Web.UI.WebControls.Image
    Protected WithEvents Image3 As System.Web.UI.WebControls.Image
    Protected WithEvents Image4 As System.Web.UI.WebControls.Image
    Protected WithEvents Image5 As System.Web.UI.WebControls.Image
    Protected WithEvents Image6 As System.Web.UI.WebControls.Image
    Protected WithEvents Image7 As System.Web.UI.WebControls.Image
    Protected WithEvents Image8 As System.Web.UI.WebControls.Image
    Protected WithEvents lblMessage As System.Web.UI.WebControls.Label
    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 strDateFormat As String = "dd/MM/yyyy"
    Private strDateFormat2 As String = "dd/MM/yyyy HH:mm"

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        mnuCams.CurrentGroup = Constants.MENU_HOME_ID
        mnuCams.CurrentItem = Constants.MENU_HOME_ID

        Dim oCC_Case As New CC_Case
        Dim oEC_User As EC_User = Me.GetUserFromSession

        If Not oEC_User Is Nothing Then
            If oEC_User.AccessGroup <> Constants.CONST_ACCESSGROUP_HA And oEC_User.AccessGroup <> Constants.CONST_ACCESSGROUP_TA Then
                lblTitleMyWC.Visible = False
                pnlMyWorkingCases.Visible = False
            Else
                Me.lblAGNormal.Text = oCC_Case.GetNumberCases(oEC_User.AccessGroup, Constants.CONST_CASESTATUS_NORMAL, oEC_User.UserID).ToString
                Me.lblAGAtt.Text = oCC_Case.GetNumberCases(oEC_User.AccessGroup, Constants.CONST_CASESTATUS_ATTENTION, oEC_User.UserID).ToString
                Me.lblAGImAtt.Text = oCC_Case.GetNumberCases(oEC_User.AccessGroup, Constants.CONST_CASESTATUS_IMMATTENTION, oEC_User.UserID).ToString
            End If

            Me.lblTotNormal.Text = oCC_Case.GetNumberCases(oEC_User.AccessGroup, Constants.CONST_CASESTATUS_NORMAL).ToString
            Me.lblTotAtt.Text = oCC_Case.GetNumberCases(oEC_User.AccessGroup, Constants.CONST_CASESTATUS_ATTENTION).ToString
            Me.lblTotImAtt.Text = oCC_Case.GetNumberCases(oEC_User.AccessGroup, Constants.CONST_CASESTATUS_IMMATTENTION).ToString
            Me.lblTotCanc.Text = oCC_Case.GetNumberCases(oEC_User.AccessGroup, Constants.CONST_CASESTATUS_CANCELLED).ToString
            Me.lblTotClosed.Text = oCC_Case.GetNumberCases(oEC_User.AccessGroup, Constants.CONST_CASESTATUS_CLOSED).ToString
        End If

        'Added by Vanessa Ayala
        Dim dsResult As DataSet = oCC_Case.GetBatchInf
        If Not dsResult Is Nothing Then
            If Not dsResult.Tables(0).Rows.Count = 0 Then
                Me.lblMessage.CssClass = "PAGE_CONTROL_TEXT"
                Dim strFech As String = ""
                strFech = Convert.ToDateTime(dsResult.Tables(0).Rows(0)(0)).ToString(strDateFormat2)
                'Me.lblMessage.Text = "Case status change process run on: " & dsResult.Tables(0).Rows(0)(0).ToString & " - " & dsResult.Tables(0).Rows(0)(1).ToString & " Cases had their status changed."
                Me.lblMessage.Text = "Case status change process run on: " & strFech & " - " & dsResult.Tables(0).Rows(0)(1).ToString & " Cases had their status changed."
            Else
                Me.lblMessage.CssClass = "PAGE_ERROR_MSG"
                Me.lblMessage.Text = "Case status change process run on : " & Date.Today.ToString(strDateFormat) & ". The process did not run as scheduled, please contact your IT support."
            End If
        End If
        'End Added

        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("if(pag.document.all.lblPath!=null)pag.document.all.lblPath.innerHTML='Home';")
            stbOutput.Append("</script>")
            Response.Write(stbOutput.ToString)
        End If

    End Sub

    Private Sub btnSCases_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSCases.Click
        Dim strAppPath As String = Me.ApplicationPath
        Dim strDest As String

        If strAppPath.EndsWith("/") Then
            strDest = strAppPath & "Search/frmAllCases.aspx"
        Else
            strDest = strAppPath & "/Search/frmAllCases.aspx"
        End If

        Me.Response.Redirect(strDest, True)
    End Sub
End Class
