Imports System.Data.OleDb
Public Class LoginFrm

    Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click

        Try
            Dim cn As New OleDbConnection("Provider=Microsoft.Ace.Oledb.12.0; Data Source=" & My.Application.Info.DirectoryPath.ToString() & "\BackUp\Printmaker11.Accdb;")
            cn.Open()


            If txtUserID.Text = "" Or txtpassword.Text = "" Then
                MessageBox.Show("Please Enter UserID an Password", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information)
                txtUserID.Focus()
                Exit Sub
            End If

            Dim dr1 As OleDbDataReader
            Dim com As New OleDbCommand
            com.CommandText = "select [UserID],[Pass] from userinfo where userid = '" & txtUserID.Text & "'"
            com.Connection = cn
            If cn.State = ConnectionState.Closed Then cn.Open()
            dr1 = com.ExecuteReader
            If dr1.Read Then
                If UCase(dr1(1)) = UCase(txtpassword.Text) Then

                    Dim obj As New Home
                    obj.Show()
                    Me.Hide()


                Else
                    MessageBox.Show("Password is wrong", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning)
                    txtpassword.Focus()
                End If
            Else
                MessageBox.Show("UserID is wrong", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning)
                txtUserID.Focus()
                Exit Sub
            End If
            dr1.Close()
            cn.Close()
        Catch ex As Exception
            MsgBox(ex.Message(), MsgBoxStyle.Critical, "Login Error...")
        End Try
    End Sub

    Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
        End
    End Sub
End Class