Public Class ShipmentReportViewerNew
    Inherits Functions
    Dim Report As New ShipmentReport

    Protected Sub btnXLS_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnRunReport.Click
        Dim TDataSet As New dsShipmentReport
        Dim TTableAdapter As New dsShipmentReportTableAdapters.ShipmentReportTableAdapter
        Dim connection As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
        Dim StartDate As String = txtStartDate.Text
        Dim EndDate As String = txtEndDate.Text

        TTableAdapter.SelectCommandTimeout = 1800
        TTableAdapter.Connection = connection
        TTableAdapter.FillByDate(TDataSet.ShipmentReportDataTable, StartDate, EndDate)

        Report.SetDataSource(TDataSet)
        'Dim TextField As CrystalDecisions.CrystalReports.Engine.TextObject
        'TextField = Report.ReportDefinition.ReportObjects.Item("txtDateRange")
        'TextField.Text = StartDate & " - " & EndDate
        'TextField = Report.ReportDefinition.ReportObjects.Item("txtDateRange")
        'If det Then
        '    TextField.Text = "Shipment - Detail Report"
        'Else
        '    TextField.Text = "Shipment - Summary Report"
        'End If

        Dim myRDS As New Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", TDataSet.Tables(0))
        ReportViewer1.LocalReport.DataSources.Clear()
        ReportViewer1.LocalReport.DataSources.Add(myRDS)
        ReportViewer1.LocalReport.Refresh()

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Authenticate()

        If Not Page.IsPostBack Then
            txtStartDate.Text = Now.Date
            txtEndDate.Text = Now.Date
        End If
    End Sub


End Class