Imports RGBC_Promotions.SystemFunctions
Imports RGBC_Promotions.ProjectFunctions
Imports RGBC_Promotions.db


Partial Public Class Index
   Inherits System.Web.UI.Page


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

      FormsAuthentication.SignOut()
      Session.Clear()

      If Not Page.IsPostBack Then
         If Request.QueryString("M") = "1" Then
            lblMessage.Text = "Your Session has expired and you have been logged out."
         End If
      End If

   End Sub

   Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLogin.Click
      Dim s As String
      Dim dr As DataRow

      s = db.CleanString(Request.LogonUserIdentity.Name.ToUpper())
      lblMessage.Text = s & "<br>"

      Try
         If LogginUser(Request, Session) Then
            Response.Redirect("Home.aspx", False)
         Else
            lblMessage.Text &= "<i>Insufficient Access.</i><BR>Login is controlled through the Active Directory, <BR>Please contact the system administrator if your require access."
            FormsAuthentication.SignOut()
            Session.Item("USER") = Nothing
         End If
      Catch ex As Exception
         lblMessage.Text &= "<i>An error has occured, please contact the system administrator.</i><BR>" & ex.Message & ex.StackTrace

         FormsAuthentication.SignOut()
         Session.Item("USER") = Nothing
      Finally

      End Try

   End Sub

End Class
