Imports System.Data.OleDb
Imports AcggDoc.Acgg.dbClass

Namespace Acgg
    Public Class Login
        Inherits System.Web.UI.Page

#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 Button1 As System.Web.UI.WebControls.Button
        Protected WithEvents Label1 As System.Web.UI.WebControls.Label
        Protected WithEvents Label2 As System.Web.UI.WebControls.Label
        Protected WithEvents txtUserId As System.Web.UI.WebControls.TextBox
        Protected WithEvents txtPwd As System.Web.UI.WebControls.TextBox
        Protected WithEvents cmdOk As System.Web.UI.WebControls.Button
        Protected WithEvents Label14 As System.Web.UI.WebControls.Label

        '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
        Dim sConnString As String

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here
            'sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=" & Server.MapPath("AcggDoc.mdb") & ";UID=;PASSWORD="
            sConnString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Database Password=;Data Source=" & Server.MapPath("AcggDoc.mdb") & ";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:System database=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False"
        End Sub

        Private Sub cmdOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOk.Click

            Dim objDBClass As Acgg.dbClass
            Dim intCat As Integer
            Session("UserCat") = 0

            'objDBClass.strConn = sConnString.ToString()
            'Dim i As Integer = objDBClass.OpenDB()
            'objDBClass.OpenDB()
            intCat = objDBClass.AuthenticateUser(txtUserId.Text, txtPwd.Text)

            If intCat <> 0 Then
                Session("UserCat") = intCat
                Session("UserId") = txtUserId.Text
                Response.Redirect("Index.asp")
            Else
                Response.Write("Authentication Failed.")
            End If
        End Sub
    End Class
End Namespace
