cursosr

Blogger Widgets

Selasa, 05 Agustus 2014

Login Casier menggunakan database access

Membuat database pada access , seprti berikut ini :


buat design untuk login casier pada Visual Studio 2010 seperti berikut ini :
untuk design ini ketikkan koding seperti ini :

Public Class frmlogin
    Dim conString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\UASMELIAMELIA\UASMELIAMELIA\bin\Debug\dbPos.accdb"
    Dim kon As New OleDb.OleDbConnection(ConString)
    Dim cmd As New OleDb.OleDbCommand
    Dim dr As OleDb.OleDbDataReader
    Dim OPH As Boolean = False
   
    Private Sub frmlogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub txtinput_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtinput.TextChanged
        txtinput.Focus()

    End Sub

    Private Sub btnceklis_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnceklis.Click
        Dim idUser As String = txtinput.Text.Trim


        Dim sql As String = "SELECT*FROM Login " & _
                            "WHERE idUser ='" & idUser & "'"
        kon.Open()
        cmd.CommandText = sql
        cmd.Connection = kon
        dr = cmd.ExecuteReader
        Dim nama As String = Nothing
        Dim privilages As Byte = 0
        'Dim a As String = Nothing
        'Select Case a
        '    Case 0
        '        lblprivileges = 0

        'End Select
        If dr.HasRows Then
            While dr.Read

                nama = dr.Item("namaUser").ToString.Trim
                privilages = dr.Item("privilegesUser").Trim
            End While
            'lbllog()
            menuutama.Show()
            menuutama.btncashier.Enabled = False
            menuutama.btnadmin.Enabled = False


            Select Case privilages
                Case 0
                    menuutama.btncashier.Enabled = True
                Case 1
                    menuutama.btnadmin.Enabled = True


            End Select
            menuutama.lblnama.Text = "Main Form For " & nama
            menuutama.Lbllogin.Text = "Log In As : " & nama
            menuutama.lblprivileges.Text = "Privileges : " & privilages
            menuutama.lbltime.Text = "Log At :" & Now
            Me.Close()

        Else
            txtinput.Text = "INVALID !!!"


        End If
        kon.Close()


    End Sub

    Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
        If OPH = True Or txtinput.Text = "0" Then
            txtinput.Text = "1"
            OPH = False
        Else
            txtinput.Text = txtinput.Text + "1"
        End If
    End Sub

    Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
        If OPH = True Or txtinput.Text = "0" Then
            txtinput.Text = "1"
            OPH = False
        Else
            txtinput.Text = txtinput.Text + "2"
        End If
    End Sub

    Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
        If OPH = True Or txtinput.Text = "0" Then
            txtinput.Text = "1"
            OPH = False
        Else
            txtinput.Text = txtinput.Text + "3"
        End If
    End Sub

    Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
        If OPH = True Or txtinput.Text = "0" Then
            txtinput.Text = "1"
            OPH = False
        Else
            txtinput.Text = txtinput.Text + "4"
        End If
    End Sub

    Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
        If OPH = True Or txtinput.Text = "0" Then
            txtinput.Text = "1"
            OPH = False
        Else
            txtinput.Text = txtinput.Text + "5"
        End If
    End Sub

    Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
        If OPH = True Or txtinput.Text = "0" Then
            txtinput.Text = "1"
            OPH = False
        Else
            txtinput.Text = txtinput.Text + "6"
        End If
    End Sub

    Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
        If OPH = True Or txtinput.Text = "0" Then
            txtinput.Text = "1"
            OPH = False
        Else
            txtinput.Text = txtinput.Text + "7"
        End If
    End Sub

    Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
        If OPH = True Or txtinput.Text = "0" Then
            txtinput.Text = "1"
            OPH = False
        Else
            txtinput.Text = txtinput.Text + "8"
        End If
    End Sub

    Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
        If OPH = True Or txtinput.Text = "0" Then
            txtinput.Text = "1"
            OPH = False
        Else
            txtinput.Text = txtinput.Text + "9"
        End If
    End Sub

    Private Sub btnminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnminus.Click
        If OPH = True Or txtinput.Text = "0" Then
            txtinput.Text = "1"
            OPH = False
        Else
            txtinput.Text = txtinput.Text + "-"
        End If
    End Sub

    Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
        If OPH = True Or txtinput.Text = "0" Then
            txtinput.Text = "1"
            OPH = False
        Else
            txtinput.Text = txtinput.Text + "0"
        End If
    End Sub

    Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
        'Dim jml As Byte
        'Dim bil As Integer
        'Dim angka As Byte
        'jml = Len(bil)
        'If jml > 0 Then
        '    bil = (bil, jml - 1)
        '    bil = Left(bil, jml - 1)
        '    Angka = bil
        'End If
        txtinput.Clear()
    End Sub

    Private Sub picexite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picexite.Click
        Me.Close()
    End Sub
End Class
setelah itu buat design menu utama pada visual studio 2010seprti ini :
 
Ketikan koding seperti
Public Class menuutama


    Private Sub btncashier_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncashier.Click
        MsgBox("Super User can access this Button !!!", vbInformation)
    End Sub

    Private Sub piclogut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles piclogut.Click
        frmlogin.Show()
    End Sub

    Private Sub picexite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picexite.Click

        Me.Close()
    End Sub

    Private Sub btnadmin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadmin.Click
        MsgBox("Super User can access this Button !!!", vbInformation)
    End Sub

  
End Class

Tidak ada komentar:

Posting Komentar