Imports CAMS_ADMIN
Imports CAMS_BL
Imports System.Data
Imports System.Text

Public Class frmPrintWorkOffline
    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
    Protected WithEvents dgResults As System.Web.UI.WebControls.DataGrid

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    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
        Dim oUser As EC_User = Me.GetUserFromSession

        FillReport()

        Response.ContentType = "application/vnd.ms-excel"
        Response.Charset = ""
        Dim sFileName As String = "WorkOffline_" & Today.Day & Today.Month & Today.Year & "_" & oUser.Abbreviation
        Response.AppendHeader("content-disposition", "attachment; filename=" & sFileName & ".xls")
        Me.EnableViewState = False

    End Sub

    Private Sub FillReport()
        Dim oCC_Case As New CC_Case
        Dim dsResults As DataSet
        Dim oUser As EC_User = Me.GetUserFromSession

        Try
            dsResults = oCC_Case.GetWorkOffline(oUser.UserID, oUser.AccessGroup)
        Catch ex As Exception
            dsResults = Nothing
        Finally
            dgResults.DataSource = dsResults
            dgResults.DataBind()
        End Try

    End Sub

    Private Sub dgResults_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgResults.ItemDataBound
        If e.Item.ItemType <> ListItemType.Header Then
            Dim drv As DataRowView = e.Item.DataItem

            If Not drv Is Nothing Then
                e.Item.Cells(0).Text = "&nbsp;" & drv("CASEID")
            End If

        End If
    End Sub
End Class
