Imports System.Data.SqlClient
Public Class FrmLogin

    Private Sub btn_Login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
       
    End Sub

    Private Sub btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Application.Exit()
    End Sub

    Private Sub FrmLogin_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

    End Sub

   

    Private Sub FrmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub btn_Login_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Login.Click
        If Me.txtname.Text.Length = 0 Then
            MsgBox("Please enter username...", MsgBoxStyle.Exclamation, "WARNING")
            Exit Sub
        ElseIf Me.Password.Text.Length = 0 Then
            MsgBox("Please enter password....", MsgBoxStyle.Exclamation, "WARNING")
            Exit Sub
        Else
            Try
                Call opencon()
                Dim myda As New SqlDataAdapter
                With myda
                    .SelectCommand = New SqlCommand
                    .SelectCommand.CommandText = "SELECT * FROM login WHERE username LIKE '%%" & Me.txtname.Text & "%%' AND password LIKE '%%" & Me.Password.Text & "%%' "
                    .SelectCommand.Connection = con
                End With
                Dim dr As New DataSet
                myda.Fill(dr, "myTable")
                If dr.Tables("myTable").Rows.Count > 0 Then
                    logger = txtname.Text
                    Me.txtname.Clear()
                    Password.Clear()
                    Me.Hide()

                    Form1.Enabled = True
                    Form1.MenuStrip1.Enabled = True
                    Form2.Enabled = True
                Else
                    MsgBox("Please Verify Your Username and Password...", MsgBoxStyle.Exclamation, "WARNING")
                    Me.txtname.Focus()
                    Me.txtname.SelectAll()
                End If
                Call closecon()
            Catch ex As Exception
                MsgBox(ex.Message)
                Call closecon()
            End Try
        End If

    End Sub

    Private Sub btn_cancel_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cancel.Click
        Application.Exit()
    End Sub
End Class