Simple Login | Electronic Billing System VB.NET

Simple Login |  Electronic Billing System VB.NET


FORM 1
Imports System.Data.OleDb
Imports System.Media

Public Class Register

    Dim path = System.Windows.Forms.Application.StartupPath
    Dim LogOnsound As String
    Dim MyPlayer As New SoundPlayer()

    Private Sub Cancel_Click(sender As Object, e As EventArgs) Handles Cancel.Click
        Me.Hide()
        Loginfrm.Show()

    End Sub

    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.CheckState = CheckState.Checked Then
            PasswordTextBox.UseSystemPasswordChar = False
        End If
        If CheckBox1.CheckState = CheckState.Unchecked Then
            PasswordTextBox.UseSystemPasswordChar = True
        End If
    End Sub

    Private Sub OK_Click(sender As Object, e As EventArgs) Handles OK.Click
        Dim user, pass As String
        user = UsernameTextBox.Text
        pass = PasswordTextBox.Text



        Dim connection1 As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Credentials.mdb;")

        Dim command As New OleDbCommand("SELECT [ID] FROM [Staff] WHERE [usernameField] = username AND [passwordField] = password", connection1)

        Dim usernameParam As New OleDbParameter("username", UsernameTextBox.Text)
        Dim passwordParam As New OleDbParameter("password", PasswordTextBox.Text)

        command.Parameters.Add(usernameParam)
        command.Parameters.Add(passwordParam)

        command.Connection.Open()
        Dim reader As OleDbDataReader = command.ExecuteReader()
        If reader.HasRows Then
            MessageBox.Show("User Exist")
            MyPlayer.SoundLocation = path & LogOnsound
            PasswordTextBox.Text = ""
            UsernameTextBox.Text = ""


        ElseIf user = "" Or pass = "" Then
            MsgBox("Please Fill The Boxs", , "Error")
        Else

            Dim connection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Credentials.mdb;"
            Using myconnection As New OleDbConnection(connection)
                myconnection.Open()

                Dim sqlq As String = "INSERT INTO [staff] ([username], [password]) VALUES (@user, @pass)"
                Using cmd As New OleDbCommand(sqlq, myconnection)
                    cmd.Parameters.AddWithValue("@usernme", user)
                    cmd.Parameters.AddWithValue("@passwrd", pass)
                    cmd.ExecuteNonQuery()
                    MsgBox("User Registered!", , "register")
                    user = ""
                    pass = ""
                End Using
            End Using
        End If
        command.Connection.Close()




    End Sub
End Class

Comments

Popular posts from this blog

QR CODE SCANNER (Emgu CV ) VB.NET

Simple Modern Login (Guna UI, Mysql) VB.NET

Simple Lottery Game (Guna UI) VB.NET