Imports System.Data.OleDb
Imports System.Object
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim OleDBC As New OleDbCommand
        Dim OleDBDR As OleDbDataReader
        With OleDBC
            .Connection = conn
            .CommandText = "SELECT * FROM tblUsers " & _
            "WHERE UserID='" & _
            ComboBox1.Text & "' AND " & _
            "Upass='" & _
            TextBox1.Text & "'"
        End With

        OleDBDR = OleDBC.ExecuteReader
        OleDBDR.Read()

        If OleDBDR.HasRows Then
            If OleDBDR.Item(0) = "Admin" Then
                Me.Hide()
                frmMenuAdmin.Show()
            Else
                Me.Hide()
                frmMenuCashier.Show()
            End If
        Else
            Call ShowError()
            ComboBox1.Text = ""
            TextBox1.Text = ""
            TextBox1.Focus()
        End If
        

    End Sub
    Private Sub loadUserList()
        Dim OleDBC As New OleDbCommand
        Dim OleDBDR As OleDbDataReader
        With OleDBC
            .Connection = conn
            .CommandText = "SELECT UserID FROM tblUsers"
        End With
        OleDBDR = OleDBC.ExecuteReader
        ComboBox1.Items.Clear()
        If OleDBDR.HasRows Then
            While OleDBDR.Read
                ComboBox1.Items.Add(OleDBDR.Item(0))
            End While
        End If
    End Sub

    Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call connectDatabase()
        Call loadUserList()
        ComboBox1.Text = ""
        TextBox1.Clear()

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub
End Class