Public Class frmZollprogrammeDurchsuchen

    Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL

    Private Sub btnSuche_Click(sender As Object, e As EventArgs) Handles btnSuche.Click
       initSrch
    End Sub
    Sub initSrch()
        Dim eori = MyTextBox1.Text.Replace("*", "%")

        Dim sqlStr = "SELECT TOP 5 '', [zbant].zbant_beznr ,zbant_anmeori,zbant_anmkd,zbadz_name1, baslnd_alpha, zbadz_plz, zbadz_ort,zbant_adat,[zbant].basman_nl  FROM [atlas].[dbo].[zbant]  INNER JOIN   zbadz ON zbant.basman_nr=zbadz.basman_nr And zbant.basman_nl=zbadz.basman_nl And zbant.zbant_beznr=zbadz.zbant_beznr And zbant.zbant_regnr=zbadz.zbant_regnr And zbant.zbant_korant=zbadz.zbant_korant And zbadz.zbadz_typ='3' where [zbant_anmeori] like '" & eori & "'"
        If cbx.Checked Then
            sqlStr &= " UNION "
            sqlStr &= "SELECT TOP 5 'HISTORY', zbhant.zbant_beznr ,zbant_anmeori,zbant_anmkd,zbadz_name1, baslnd_alpha, zbadz_plz, zbadz_ort,zbant_adat,zbhant.basman_nl  FROM [atlas].[dbo].[zbhant] INNER JOIN   zbhadz ON zbhant.basman_nr=zbhadz.basman_nr And zbhant.basman_nl=zbhadz.basman_nl And zbhant.zbant_beznr=zbhadz.zbant_beznr And zbhant.zbant_regnr=zbhadz.zbant_regnr And zbhant.zbant_korant=zbhadz.zbant_korant And zbhadz.zbadz_typ='3' where [zbant_anmeori] like '" & eori & "'"
        End If

        dgvBluJay.DataSource = SQL.loadDgvBySql(sqlStr & " ORDER BY zbant_adat desc", If(VERAG_PROG_ALLGEMEIN.cAllgemein.NIEDERLASSUNG = "SBG", "ATLAS_SBG", "ATLAS"))
        dgvBluJay.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
        dgvBluJay.ClearSelection()

        Dim sqlStr2 = "SELECT top 5 LRN,zsAnmRefs.GeaendertAm as Datum,TIN,Na, Pst, Cty, Ctry ,CRN   FROM zsAnmRefs INNER JOIN zsAnmConorTra ON zsAnmConorTra.AnmID=zsAnmRefs.AnmID and zsAnmConorTra.LizenzNr=zsAnmRefs.LizenzNr  and zsAnmConorTra.OperatorID=zsAnmRefs.OperatorID  and zsAnmConorTra.VorgangID=zsAnmRefs.VorgangID WHERE TIN LIKE '" & eori & "' ORDER BY zsAnmRefs.GeaendertAm DESC"
        dgvEzoll.DataSource = SQL.loadDgvBySql(sqlStr2, "EZOLL")
        dgvEzoll.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
        dgvEzoll.ClearSelection()
    End Sub

    Private Sub MyTextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyTextBox1.KeyDown
        If e.KeyCode = Keys.Return Then
            initSrch()
        End If
    End Sub

    Private Sub frmZollprogrammeDurchsuchen_Load(sender As Object, e As EventArgs) Handles Me.Load
        cboArt.Items.Clear()
        cboArt.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("EZA", "EZA"))
        cboArt.changeItem("EZA")
    End Sub
End Class