Public Class Dashboard
    Inherits System.Web.UI.Page

    Property CurrentDriver As Logic.DriverAccount


    Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        Try
            Dim driverId = SessionVars.DriverId(Session)
            If driverId > 0 Then
                CurrentDriver = New Logic.DriverAccount(driverId)
            Else
                If String.IsNullOrEmpty(SessionVars.PostLoginUrl(Session)) Then
                    SessionVars.PostLoginUrl(Session) = Request.Url.ToString()
                End If
                Response.Redirect("/Login.aspx", False)
            End If

            dsHistory.ConnectionString = Logic.Database.ConnectionString
            dsHistory.SelectParameters("accountId").DefaultValue = CurrentDriver.id

            dsCurrent.ConnectionString = Logic.Database.ConnectionString
            dsCurrent.SelectParameters("accountId").DefaultValue = CurrentDriver.id

        Catch ex As Exception
            Dim errorId = Logic.Error.Log(ex)
            Response.Redirect("/Error.aspx?id=" & errorId)
        End Try
    End Sub

    Private Sub repHistory_ItemDataBound(sender As Object, e As EventArgs) Handles repHistory.ItemDataBound
        repHistory.Visible = repHistory.Items.Count > 0
    End Sub

    Private Sub repCurrent_ItemDataBound(sender As Object, e As EventArgs) Handles repCurrent.ItemDataBound
        If repCurrent.Items.Count > 0 Then
            phMessage.Visible = False
        Else
            phMessage.Visible = True
        End If
        repCurrent.Visible = repCurrent.Items.Count > 0
    End Sub

End Class