Public Class frmLogin

    Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
        If Trim(txtUsuario.Text) = "" Or Trim(txtSenha.Text) = "" Then
            MsgBox("Informe as suas credenciais para Login!", vbExclamation, "Dados Inválidos !")
        Else
            Dim sql As String
            sql = "SELECT * FROM Usuarios WHERE usuario = '" & txtUsuario.Text & "' AND senha = '" & txtSenha.Text & "'"
            Dim dt As DataTable = DalHelper.GetDataTable(sql)
            Try
                If Not dt.Rows.Count > 0 Then
                    MsgBox("Login Falhou!", vbCritical, "Login inválido")
                    txtUsuario.Text = ""
                    txtSenha.Text = ""
                    txtSenha.Focus()
                Else
                    MsgBox("Login realizado com Sucesso", vbInformation, "Login")
                    Me.Hide()
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End If
    End Sub

    Private Sub btnCancela_Click(sender As Object, e As EventArgs) Handles btnCancela.Click
        If (MessageBox.Show("Deseja Encerrar ?", "Encerrar", MessageBoxButtons.YesNo) = DialogResult.Yes) Then
            Application.Exit()
        End If
    End Sub
End Class
