Imports EDSL.Entities
Imports EDSL.DAL
Partial Public Class Login
    Inherits BasePage
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsPostBack = True Then
            Call CheckLogin()
        Else
            Session("LoginCount") = 0
            Dim objMainPage As New dbMainPage
            Dim objMainEntity As New entMainPage

            objMainEntity = objMainPage.GetPageDetails("zoneLogin")
            Me.Title = ConfigurationManager.AppSettings("BrowserTitleCompanyName") & objMainEntity.PageTitle
            divContent.InnerHtml = objMainEntity.PageContent
            Me.MetaName = objMainEntity.PageMetaName
            Me.MetaContent = objMainEntity.PageMetaContent
        End If
    End Sub
    Private Sub CheckLogin()
        If DoLoginCheck() = False Then
            Session("LoginCount") += 1
            If Session("LoginCount") <= 4 Then
                divErrorPanel.InnerHtml = "Invalid username and password, " & (5 - Session("LoginCount")) & " attempts remaining"
            Else
                Call DisableLogin()
                divErrorPanel.InnerHtml = "Invalid username and password, your login has been disabled, please contact your administrator"
            End If
        Else
            Session("LoginCount") = 0
            Response.Redirect("printall.aspx")
        End If
    End Sub
    Private Function DoLoginCheck() As Boolean
        Try
            Dim objMain As New dbMainUser
            Dim objMainEntity As entMainLoginDetails = objMain.LoginCheck(txtUID.Text, txtPwd.Text)
            If objMainEntity.LoginID > 0 Then
                Session("passover") = objMainEntity.LoginID
                Session("hanukkah") = objMainEntity.Firstname & " " & objMainEntity.Surname
                Session("hanukkah") = Trim(Session("hanukkah"))
                Session("ramadan") = objMainEntity.LoginType

                Return True
            Else
                Return False
            End If
        Catch ex As Exception
            Return False
        End Try
    End Function
    Private Sub DisableLogin()

    End Sub
End Class