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

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


FORM 1

Imports MySql.Data.MySqlClient

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        connection()
    End Sub

    Private Sub GunaButton1_Click(sender As Object, e As EventArgs) Handles GunaButton1.Click
        SignIn()
    End Sub

    Private Sub GunaButton3_Click(sender As Object, e As EventArgs) Handles GunaButton3.Click

    End Sub

    Private Sub GunaGoogleSwitch1_CheckedChanged(sender As Object, e As EventArgs) Handles GunaGoogleSwitch1.CheckedChanged
        Try
            If GunaGoogleSwitch1.Checked = True Then
                GunaTextBox2.UseSystemPasswordChar = False
                GunaTextBox2.PasswordChar = ""
            ElseIf GunaGoogleSwitch1.Checked = False Then
                GunaTextBox2.UseSystemPasswordChar = True
                GunaTextBox2.PasswordChar = "●"
            Else
                MsgBox("Please Restart the Application to solve this problem!", MsgBoxStyle.OkOnly + MsgBoxStyle.Critical)
                Application.Exit()
            End If
        Catch ex As Exception

        End Try
    End Sub

    Private Sub GunaButton2_Click(sender As Object, e As EventArgs) Handles GunaButton2.Click
        Try

            If MsgBox("Are you sure you want to Exit?", MsgBoxStyle.YesNo + MsgBoxStyle.Question) = MsgBoxResult.Yes Then
                Application.Exit()
            End If
        Catch ex As Exception

        End Try
    End Sub

    Private Sub GunaTextBox1_TextChanged(sender As Object, e As EventArgs) Handles GunaTextBox1.TextChanged
        Try
            Dim byt As Byte() = System.Text.Encoding.UTF8.GetBytes(GunaTextBox1.Text)
            sUsername = Convert.ToBase64String(byt)
        Catch ex As Exception
           
        End Try
    End Sub

    Private Sub GunaTextBox2_TextChanged(sender As Object, e As EventArgs) Handles GunaTextBox2.TextChanged
        Try
            Dim byt As Byte() = System.Text.Encoding.UTF8.GetBytes(GunaTextBox2.Text)
            sPassword = Convert.ToBase64String(byt)

        Catch ex As Exception

        End Try
    End Sub


    Public Sub SignIn()

        Try
            con.Close()
            connection()
            Dim command As New MySqlCommand("SELECT `ID` FROM `Users` WHERE `Username` = @username AND `Password` = @password", con)
            command.Parameters.Add("@username", MySqlDbType.VarChar).Value = sUsername
            command.Parameters.Add("@password", MySqlDbType.VarChar).Value = sPassword
            Dim adapter As New MySqlDataAdapter(command)
            Dim table As New DataTable()
            adapter.Fill(table)

            If table.Rows.Count = 0 Then
                MessageBox.Show("Invalid Username Or Password")
            Else
                Me.Hide()
                Form2.Show()
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

End Class


MODULE 1

Imports mysql.Data.MySqlClient
Module Module1

    Public sUsername As String
    Public sPassword As String
    Public sMaster As String
    Public cm As New MySqlCommand
    Public con As New MySqlConnection
    Public dr As MySqlDataReader
    Public list As ListViewItem
    Public Reader As MySqlDataReader


    Sub connection()
        Try
            con = New MySqlConnection("datasource=localhost;port=3306;username=root;password=password;database=Myserver")
            con.Open()
        Catch ex As Exception
            MsgBox("Failed to connet to the Server !", MsgBoxStyle.Critical)

        End Try

    End Sub


    Sub showform(ByVal Panel As Form)

        Try

            Form2.GunaShadowPanel3.Controls.Clear()
            Panel.TopLevel = False
            Form2.GunaShadowPanel3.Controls.Add(Panel)
            Panel.Show()

        Catch ex As Exception

        End Try

    End Sub

    Sub NumbersOnly(ByVal e As System.Windows.Forms.KeyPressEventArgs)

        If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Then

        Else
            e.Handled = True
            MsgBox("Numbers Only !", MsgBoxStyle.OkOnly + MsgBoxStyle.Critical)
        End If


    End Sub


End Module


Comments

Popular posts from this blog

QR CODE SCANNER (Emgu CV ) VB.NET

Simple Lottery Game (Guna UI) VB.NET