Imports DevComponents.DotNetBar.Controls

Public Class FrmRegistrosListar
    Dim filtrarOcupado As Boolean = False
    Public Sub Filtrar()
        If filtrarOcupado = True Then Exit Sub
        Try
            filtrarOcupado = True
            Dim conexion As New Conexion(conexionLocal)
            Dim manejador As New ClsRegistrosListar(conexion)
            Dim miTabla As New DataTable
            Dim argumentos As New RegistrosListarArgumentos With {.FiltroUniversal = TxtBuscar.Text}

            miTabla = manejador.Listar(argumentos)

            DgvRegistros.DataSource = miTabla
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        Finally
            filtrarOcupado = False
        End Try
    End Sub

    Private Sub FrmRegistroListar_Load(sender As Object, e As EventArgs) Handles Me.Load
        DgvRegistros.AutoGenerateColumns = False
        TxtBuscar.Text = Date.Now.ToString("dd-MM-yyyy")
        Filtrar()
    End Sub

    Private Sub _KeyPress(sender As Object, e As KeyPressEventArgs) Handles TxtBuscar.KeyPress
        If e.KeyChar = Chr(13) Then
            Filtrar()
            e.Handled = True
            Exit Sub
        End If
    End Sub

    Private Sub TxtBuscar_MouseLeave(sender As Object, e As EventArgs) Handles TxtBuscar.MouseLeave
        Filtrar()
    End Sub

    Private Sub TxtBuscar_Click(sender As Object, e As EventArgs) Handles TxtBuscar.Click
        Filtrar()
    End Sub
End Class