
Imports System.Data
Imports System.Web.UI.HtmlControls

Partial Class CustomsAviso_Default
    Inherits System.Web.UI.Page
    Dim datevon As DateTime
    Dim datebis As DateTime
    Dim Kdnrtext As String
    Dim Absender As String = ""
    Dim Empfaenger As String = ""
    Dim LKWNR As String = ""
    Dim KDNAFNR As String = ""
    Dim dt As DataTable
    Dim Art As String = ""
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Page.UnobtrusiveValidationMode = UnobtrusiveValidationMode.WebForms
        DataBind()
        tbl_Header_row.TableSection = TableRowSection.TableHeader
        ' MsgBox(datebis)
        If (Page.IsPostBack And normaltable.EnableViewState = False) Then
            normaltable.EnableViewState = True
            If rbt_Alle.Checked = True Then
                lbl_von.Visible = True
                lbl_bis.Visible = True
                valDateRange_1.Enabled = True
                valDateRange_2.Enabled = True
                pickdate1.Visible = True
                pickdate2.Visible = True
            ElseIf rbt_Freig.Checked = True Then
                lbl_von.Visible = True
                lbl_bis.Visible = True
                valDateRange_1.Enabled = True
                valDateRange_2.Enabled = True
                pickdate1.Visible = True
                pickdate2.Visible = True
            Else
                lbl_von.Visible = False
                lbl_bis.Visible = False
                valDateRange_1.Enabled = False
                valDateRange_2.Enabled = False
                pickdate1.Visible = False
                pickdate2.Visible = False
            End If
            'Mobil
            If rbt_Alle_M.Checked = True Then
                lbl_von.Visible = True
                lbl_bis.Visible = True
                valDateRange_1.Enabled = True
                valDateRange_2.Enabled = True
                pickdate1.Visible = True
                pickdate2.Visible = True
            ElseIf rbt_Freig_M.Checked = True Then
                lbl_von.Visible = True
                lbl_bis.Visible = True
                valDateRange_1.Enabled = True
                valDateRange_2.Enabled = True
                pickdate1.Visible = True
                pickdate2.Visible = True
            Else
                lbl_von.Visible = False
                lbl_bis.Visible = False
                valDateRange_1.Enabled = False
                valDateRange_2.Enabled = False
                pickdate1.Visible = False
                pickdate2.Visible = False
            End If

            datevon = Date.Parse(pickdate1.Text)
            datebis = Date.Parse(pickdate2.Text)
        Else
            normaltable.EnableViewState = True
            Dim erster = New Date(Now().Year, Now().Month, 1)
            Dim ersterdat = erster.Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString
            pickdate1.Text = erster.Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString
            ' MsgBox(ersterdat)
            datevon = ersterdat
            datebis = Date.Parse(Now().Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString).ToString
            pickdate2.Text = Date.Parse(Now().Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString).ToString

            If txt_LKWNr.Text = "" Then
                regexval_txt_LKW.Enabled = False
            Else
                regexval_txt_LKW.Enabled = True
            End If
        End If
    End Sub

    Protected Sub LogOutBtn1_Click(sender As Object, e As EventArgs)
        Response.Redirect("../login/Logout.aspx", True)
    End Sub
    Protected Sub LogOutBtn2_Click(sender As Object, e As EventArgs)
        Response.Redirect("../login/Logout.aspx", True)
    End Sub

    Protected Sub initcells(tr As TableRow, t1 As TableCell, t2 As TableCell, t3 As TableCell, t4 As TableCell, t5 As TableCell, t6 As TableCell, t7 As TableCell, t8 As TableCell, th1 As TableHeaderCell, th2 As TableHeaderCell, th3 As TableHeaderCell, th4 As TableHeaderCell, th5 As TableHeaderCell, th6 As TableHeaderCell, th7 As TableHeaderCell, th8 As TableHeaderCell)
        Dim white As Drawing.Color = Drawing.Color.White
        Dim schwarz As Drawing.Color = Drawing.Color.Black
        Dim darkgrau As Drawing.Color = Drawing.Color.DarkGray
        Dim darkblue = Drawing.Color.FromArgb(4, 51, 129)

        tr.BackColor = white
        If t1.Text = "" Then
            t1.BackColor = white
            t1.ForeColor = schwarz
        Else
            t1.BackColor = white
            t1.ForeColor = schwarz
        End If
        If t2.Text = "Erfasst" Then
            t2.BackColor = Drawing.Color.HotPink
            t2.ForeColor = white
        ElseIf t2.Text = "Nicht eingetroffen" Then
            t2.BackColor = Drawing.Color.Black
            t2.ForeColor = white
        ElseIf t2.Text = "Ankunft" Then
            t2.BackColor = Drawing.Color.DarkBlue
            t2.ForeColor = white
        ElseIf t2.Text = "Vorbereitet" Then
            t2.BackColor = System.Drawing.Color.Brown
            t2.ForeColor = white
        ElseIf t2.Text = "Vorgeschrieben" Then
            t2.BackColor = Drawing.Color.Purple
            t2.ForeColor = white
        ElseIf t2.Text = "Freigabe" Then
            t2.BackColor = Drawing.Color.Green
            t2.ForeColor = white
        ElseIf t2.Text = "Undefiniert" Then
            t2.BackColor = Drawing.Color.DarkGray
            t2.ForeColor = white
        Else
            t2.BackColor = Drawing.Color.Red
            t2.ForeColor = white
        End If
        If t3.Text = "" Then
            t3.BackColor = white
            t3.ForeColor = schwarz
        Else
            t3.BackColor = white
            t3.ForeColor = schwarz
        End If
        If t4.Text = "" Then
            t4.BackColor = white
            t4.ForeColor = schwarz
        Else
            t4.BackColor = white
            t4.ForeColor = schwarz
        End If
        If t5.Text = "" Then
            t5.BackColor = white
            t5.ForeColor = schwarz
        Else
            t5.BackColor = white
            t5.ForeColor = schwarz
        End If
        If t6.Text = "" Then
            t6.BackColor = white
            t6.ForeColor = schwarz
        Else
            t6.BackColor = white
            t6.ForeColor = schwarz
        End If
        If t7.Text = "" Then
            t7.BackColor = white
            t7.ForeColor = schwarz
        Else
            t7.BackColor = white
            t7.ForeColor = schwarz
        End If
        If t8.Text = "" Then
            t8.BackColor = white
            t8.ForeColor = schwarz
        Else
            t8.BackColor = white
            t8.ForeColor = schwarz
        End If
        th1.Font.Bold = True
        th1.BackColor = darkblue
        th1.ForeColor = white
        th2.Font.Bold = True
        th2.BackColor = darkblue
        th2.ForeColor = white
        th3.Font.Bold = True
        th3.BackColor = darkblue
        th3.ForeColor = white
        th4.Font.Bold = True
        th4.BackColor = darkblue
        th4.ForeColor = white
        th5.Font.Bold = True
        th5.BackColor = darkblue
        th5.ForeColor = white
        th6.Font.Bold = True
        th6.BackColor = darkblue
        th6.ForeColor = white
        th7.Font.Bold = True
        th7.BackColor = darkblue
        th7.ForeColor = white
        th8.Font.Bold = True
        th8.BackColor = darkblue
        th8.ForeColor = white
    End Sub

    Protected Sub btn_Auftraege_Click(sender As Object, e As EventArgs)
        'MsgBox(Session.Item("test").ToString)
        'MsgBox(Session.Item("CustomerID").ToString)
        'MsgBox(Session.Item("PW").ToString)
        Try
            Kdnrtext = Session.Item("CustomerID")
        Catch A As UnauthorizedAccessException When Kdnrtext = Nothing
            MsgBox("Dieser Bereich ist nicht gestattet! Ein Fehler ist bei der Validierung der ID aufgetreten! Bitte erneut versuchen!", MsgBoxStyle.Information, "Error in User Area!")
        End Try
        dt = Nothing
        If txt_Absender.Text IsNot "" Then
            txt_Absender.ValidateRequestMode = UI.ValidateRequestMode.Enabled
            Try
                Absender = txt_Absender.Text
            Catch ex As FormatException
                MsgBox("Diese Daten sind nicht gültig!", MsgBoxStyle.Critical)
            End Try
        ElseIf txt_Empfaenger.Text IsNot "" Then
            txt_Empfaenger.ValidateRequestMode = UI.ValidateRequestMode.Enabled
            Try
                Empfaenger = txt_Empfaenger.Text
            Catch ex As FormatException
                MsgBox("Diese Daten sind nicht gültig!", MsgBoxStyle.Critical)
            End Try
        ElseIf txt_KdNrAuftrag.Text IsNot "" Then
            txt_KdNrAuftrag.ValidateRequestMode = UI.ValidateRequestMode.Enabled
            Try
                KDNAFNR = txt_KdNrAuftrag.Text
            Catch ex As FormatException
                MsgBox("Diese Daten sind nicht gültig!", MsgBoxStyle.Critical)
            End Try
        ElseIf txt_LKWNr.Text IsNot "" Then
            txt_LKWNr.ValidateRequestMode = UI.ValidateRequestMode.Enabled
            Try
                LKWNR = txt_LKWNr.Text
            Catch ex As FormatException
                MsgBox("Diese Daten sind nicht gültig!", MsgBoxStyle.Critical)
            End Try
        ElseIf txt_Absender_M.Text IsNot "" Then
            txt_Absender_M.ValidateRequestMode = UI.ValidateRequestMode.Enabled
            Try
                Absender = txt_Absender_M.Text
            Catch ex As FormatException
                MsgBox("Diese Daten sind nicht gültig!", MsgBoxStyle.Critical)
            End Try
        ElseIf txt_Empfaenger_M.Text IsNot "" Then
            txt_Empfaenger_M.ValidateRequestMode = UI.ValidateRequestMode.Enabled
            Try
                Empfaenger = txt_Empfaenger_M.Text
            Catch ex As FormatException
                MsgBox("Diese Daten sind nicht gültig!", MsgBoxStyle.Critical)
            End Try
        ElseIf txt_KdNrAuftrag_M.Text IsNot "" Then
            txt_KdNrAuftrag_M.ValidateRequestMode = UI.ValidateRequestMode.Enabled
            Try
                KDNAFNR = txt_KdNrAuftrag_M.Text
            Catch ex As FormatException
                MsgBox("Diese Daten sind nicht gültig!", MsgBoxStyle.Critical)
            End Try
        ElseIf txt_LKWNr_M.Text IsNot "" Then
            txt_LKWNr_M.ValidateRequestMode = UI.ValidateRequestMode.Enabled
            Try
                LKWNR = txt_LKWNr_M.Text
            Catch ex As FormatException
                MsgBox("Diese Daten sind nicht gültig!", MsgBoxStyle.Critical)
            End Try
        End If

        If rbt_Alle.Checked = True Or rbt_Alle_M.Checked = True Then
            pickdate1.ValidateRequestMode = UI.ValidateRequestMode.Enabled
            pickdate2.ValidateRequestMode = UI.ValidateRequestMode.Enabled
            dt = VERAG_PROG_ALLGEMEIN.cAviso.GET_KDLIST_WEB(Art, Kdnrtext, {0, 1, 2, 3, 4, 5}, datevon, datebis, Absender, Empfaenger, LKWNR, KDNAFNR)
            If pickdate1.Text = Nothing Or pickdate2.Text = Nothing Then
                Try
                    Dim erster = New Date(Now().Year, Now().Month, 1)
                    Dim ersterdat = erster.Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString
                    ' MsgBox(ersterdat)
                    datevon = ersterdat
                    pickdate1.Text = erster.Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString
                    datebis = Date.Parse(Now().Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString).ToString
                    pickdate2.Text = Date.Parse(Now().Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString).ToString
                Catch ex As ValidationException When Date.ParseExact(pickdate1.Text, "dd.MM.yyyy", Nothing).Year < Date.ParseExact("2001", "yyyy", Nothing).Year And Date.ParseExact(pickdate2.Text, "dd.MM.yyyy", Nothing).Year > Date.ParseExact(Today, "dd.MM.yyyy", Nothing).Year
                    MsgBox("Die Zeitzonen sind nicht gültig!", MsgBoxStyle.Exclamation)
                End Try
            Else
                Try
                    datevon = Date.Parse(pickdate1.Text)
                    datebis = Date.Parse(pickdate2.Text)
                Catch ex As ValidationException When Date.ParseExact(pickdate1.Text, "dd.MM.yyyy", Nothing).Year < Date.ParseExact("2001", "yyyy", Nothing).Year And Date.ParseExact(pickdate2.Text, "dd.MM.yyyy", Nothing).Year > Date.ParseExact(Today, "dd.MM.yyyy", Nothing).Year
                    MsgBox("Die Zeitzonen sind nicht gültig!", MsgBoxStyle.Exclamation)
                End Try
            End If
        ElseIf rbt_Erf.Checked = True Or rbt_Erf_M.Checked = True Then
            dt = VERAG_PROG_ALLGEMEIN.cAviso.GET_KDLIST_WEB(Art, Kdnrtext, {0}, Nothing, Nothing, Absender, Empfaenger, LKWNR, KDNAFNR)
        ElseIf rbt_Freig.Checked = True Or rbt_Freig_M.Checked = True Then
            pickdate1.ValidateRequestMode = UI.ValidateRequestMode.Enabled
            pickdate2.ValidateRequestMode = UI.ValidateRequestMode.Enabled
            If pickdate1.Text = Nothing Or pickdate2.Text = Nothing Then
                Dim erster = New Date(Now().Year, Now().Month, 1)
                Dim ersterdat = erster.Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString
                pickdate1.Text = erster.Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString
                ' MsgBox(ersterdat)
                datevon = ersterdat
                datebis = Date.Parse(Now().Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString).ToString
                pickdate2.Text = Date.Parse(Now().Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString).ToString
                dt = VERAG_PROG_ALLGEMEIN.cAviso.GET_KDLIST_WEB(Art, Kdnrtext, {1}, datevon, datebis, Absender, Empfaenger, LKWNR, KDNAFNR)
            Else
                Try
                    datevon = Date.Parse(pickdate1.Text)
                    'MsgBox(pickdate1.Text)
                    datebis = Date.Parse(pickdate2.Text)
                    ' MsgBox(pickdate2.Text)
                    dt = VERAG_PROG_ALLGEMEIN.cAviso.GET_KDLIST_WEB(Art, Kdnrtext, {1}, datevon, datebis, Absender, Empfaenger, LKWNR, KDNAFNR)
                Catch ex As ValidationException When Date.ParseExact(pickdate1.Text, "dd.MM.yyyy", Nothing).Year < Date.ParseExact("2001", "yyyy", Nothing).Year And Date.ParseExact(pickdate2.Text, "dd.MM.yyyy", Nothing).Year > Date.ParseExact(Today, "dd.MM.yyyy", Nothing).Year
                    MsgBox("Die Zeitzonen sind nicht gültig!", MsgBoxStyle.Exclamation)
                End Try
            End If
        ElseIf rbt_Ankunft.Checked = True Or rbt_Ankunft_M.Checked = True Then
            dt = VERAG_PROG_ALLGEMEIN.cAviso.GET_KDLIST_WEB(Art, Kdnrtext, {3}, Nothing, Nothing, Absender, Empfaenger, LKWNR, KDNAFNR)
        ElseIf rbt_Vorb.Checked = True Or rbt_Vorb_M.Checked = True Then
            dt = VERAG_PROG_ALLGEMEIN.cAviso.GET_KDLIST_WEB(Art, Kdnrtext, {4}, Nothing, Nothing, Absender, Empfaenger, LKWNR, KDNAFNR)
        ElseIf rbt_Vorg.Checked = True Or rbt_Vorg_M.Checked = True Then
            dt = VERAG_PROG_ALLGEMEIN.cAviso.GET_KDLIST_WEB(Art, Kdnrtext, {5}, Nothing, Nothing, Absender, Empfaenger, LKWNR, KDNAFNR)
        End If

        If dt IsNot Nothing AndAlso Not dt.Rows.Count = 0 Then
            Dim i As Integer = 0
            For Each d In dt.Rows
                Dim tr = New TableRow
                Dim Cell = New TableCell
                Dim tbl_CellIndex = New TableCell
                Dim tbl_CellStatus = New TableCell
                Dim tbl_Cell_Auftragsdatum = New TableCell
                Dim tbl_CellAbsender = New TableCell
                Dim tbl_CellEmpfaenger = New TableCell
                Dim tbl_CellLKWs = New TableCell
                Dim tbl_CellKundAuftNr = New TableCell
                Dim tbl_CellInfo = New TableCell

                Dim zahl = i + 1
                tbl_CellIndex.ValidateRequestMode = UI.ValidateRequestMode.Enabled
                tbl_CellIndex.Text = zahl
                tr.Cells.Add(tbl_CellIndex)
                tbl_CellLKWs.ValidateRequestMode = UI.ValidateRequestMode.Enabled
                tbl_CellLKWs.Text = d("LKW_Nr").ToString
                tr.Cells.Add(tbl_CellLKWs)
                tbl_CellStatus.ValidateRequestMode = UI.ValidateRequestMode.Enabled
                Select Case d("Status")
                    Case 0
                        tbl_CellStatus.Text = "Erfasst"
                        tr.Cells.Add(tbl_CellStatus)
                    Case 1
                        tbl_CellStatus.Text = "Freigabe"
                        tr.Cells.Add(tbl_CellStatus)
                    Case 2
                        tbl_CellStatus.Text = "Nicht eingetroffen"
                        tr.Cells.Add(Cell)
                    Case 3
                        tbl_CellStatus.Text = "Ankunft"
                        tr.Cells.Add(tbl_CellStatus)
                    Case 4
                        tbl_CellStatus.Text = "Vorbereitet"
                        tr.Cells.Add(tbl_CellStatus)
                    Case 5
                        tbl_CellStatus.Text = "Vorgeschrieben"
                        tr.Cells.Add(tbl_CellStatus)
                    Case Nothing
                        tbl_CellStatus.Text = "Undefiniert"
                        tr.Cells.Add(tbl_CellStatus)
                End Select
                initcells(tr, tbl_CellIndex, tbl_CellStatus, tbl_Cell_Auftragsdatum, tbl_CellAbsender, tbl_CellEmpfaenger, tbl_CellLKWs, tbl_CellKundAuftNr, tbl_CellInfo, tbl_HeaderCellIndexNr, tbl_HeaderCell_Status, tbl_HeaderCell_Auftragsdatum, tbl_HeaderCell_Absender, tbl_HeaderCell_Empfaenger, tbl_HeaderCell_LKWs, tbl_HeaderCell_KundAuftNr, tbl_HeaderCell_Info)
                tbl_Cell_Auftragsdatum.ValidateRequestMode = UI.ValidateRequestMode.Enabled
                tbl_Cell_Auftragsdatum.Text = d("AvisoEingang").ToString
                tr.Cells.Add(tbl_Cell_Auftragsdatum)
                tbl_CellAbsender.ValidateRequestMode = UI.ValidateRequestMode.Enabled
                tbl_CellAbsender.Text = d("Auftraggeber").ToString
                tr.Cells.Add(tbl_CellAbsender)
                tbl_CellEmpfaenger.ValidateRequestMode = UI.ValidateRequestMode.Enabled
                tbl_CellEmpfaenger.Text = d("Auftraggeber").ToString
                tr.Cells.Add(tbl_CellEmpfaenger)
                tbl_CellKundAuftNr.ValidateRequestMode = UI.ValidateRequestMode.Enabled
                tbl_CellKundAuftNr.Text = d("KdAuftragsNr_Avisierer").ToString
                tr.Cells.Add(tbl_CellKundAuftNr)

                Dim btn As New ImageButton
                btn.ViewStateMode = ViewStateMode.Enabled
                'btn.Text = "Text"
                btn.CssClass = "btn btn-primary"
                btn.ImageUrl = "../images/Icons/service/hilfe_small.png"
                'btn.Attributes.Add("Text", <img src= width="15" height="15"/>)
                btn.Attributes.Add("href", "../status_Julius.aspx?AvisoId=" + VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(d("AvisoID")).ToString)
                btn.Attributes.Add("target", "_blank")
                btn.PostBackUrl = "../status_Julius.aspx?AvisoId=" + VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(d("AvisoID")).ToString
                tbl_CellInfo.ValidateRequestMode = UI.ValidateRequestMode.Enabled
                tbl_CellInfo.Controls.Add(btn)
                tr.Cells.Add(tbl_CellInfo)

                If (rbt_Alle.Checked = True Or rbt_Alle_M.Checked = True) Then
                    normaltable.Rows.Add(tr)
                ElseIf (rbt_Ankunft.Checked = True Or rbt_Ankunft_M.Checked = True) AndAlso tbl_CellStatus.Text = "Ankunft" Then
                    normaltable.Rows.Add(tr)
                ElseIf (rbt_Erf.Checked = True Or rbt_Erf_M.Checked = True) AndAlso tbl_CellStatus.Text = "Erfasst" Then
                    normaltable.Rows.Add(tr)
                ElseIf (rbt_Freig.Checked = True Or rbt_Freig_M.Checked = True) AndAlso tbl_CellStatus.Text = "Freigegeben" Then
                    normaltable.Rows.Add(tr)
                ElseIf (rbt_Vorb.Checked = True Or rbt_Vorb_M.Checked = True) AndAlso tbl_CellStatus.Text = "Vorbereitet" Then
                    normaltable.Rows.Add(tr)
                ElseIf (rbt_Vorg.Checked = True Or rbt_Vorg_M.Checked = True) AndAlso tbl_CellStatus.Text = "Vorgeschrieben" Then
                    normaltable.Rows.Add(tr)
                End If

                i += 1
            Next
        Else
            Dim tbl_cellNothing = New TableCell()
            tbl_cellNothing.ColumnSpan = tbl_Header_row.Cells.Count
            tbl_cellNothing.Style.Add("text-align", "center")
            Dim tr = New TableRow()
            tr.Style.Add("text-align", "center")
            tbl_cellNothing.Text = Server.HtmlEncode("Keine Daten gefunden.")
            tr.Cells.Add(tbl_cellNothing)
            normaltable.Rows.Add(tr)
        End If
    End Sub

    Protected Sub btn_resetForm_Click(sender As Object, e As EventArgs)
        'Mobil
        rbt_Alle_M.Checked = True
        rbt_Alle_M.Disabled = False
        rbt_Ankunft_M.Checked = False
        rbt_Ankunft_M.Disabled = False
        rbt_Erf_M.Checked = False
        rbt_Erf_M.Disabled = False
        rbt_Freig_M.Checked = False
        rbt_Freig_M.Disabled = False
        rbt_Vorg_M.Checked = False
        rbt_Vorg_M.Disabled = False
        rbt_Vorb_M.Checked = False
        rbt_Vorb_M.Disabled = False
        txt_Absender_M.Text = ""
        txt_Empfaenger_M.Text = ""
        txt_KdNrAuftrag_M.Text = ""
        txt_LKWNr_M.Text = ""
        'Desktop
        rbt_Alle.Checked = True
        rbt_Alle.Disabled = False
        rbt_Ankunft.Checked = False
        rbt_Ankunft.Disabled = False
        rbt_Erf.Checked = False
        rbt_Erf.Disabled = False
        rbt_Freig.Checked = False
        rbt_Freig.Disabled = False
        rbt_Vorg.Checked = False
        rbt_Vorg.Disabled = False
        rbt_Vorb.Checked = False
        rbt_Vorb.Disabled = False
        txt_Absender.Text = ""
        txt_Empfaenger.Text = ""
        txt_KdNrAuftrag.Text = ""
        txt_LKWNr.Text = ""

        Dim erster = New Date(Now().Year, Now().Month, 1)
        pickdate1.Text = erster.Day.ToString + "." + erster.Month.ToString + "." + erster.Year.ToString
        pickdate2.Text = Date.Parse(erster.Day.ToString + "." + Now().Month.ToString + "." + Now().Year.ToString).ToString
        datevon = Nothing
        datebis = Nothing
        dt = Nothing
        'txt_KdNr.Focus()
    End Sub

    Protected Sub pickdate1_TextChanged(sender As Object, e As EventArgs)
        valDateRange_1.Validate()
    End Sub
    Protected Sub pickdate2_TextChanged(sender As Object, e As EventArgs)
        valDateRange_2.Validate()
    End Sub

    Protected Sub valDateRange_1_ServerValidate(source As Object, args As ServerValidateEventArgs)
        Dim minDate As DateTime = DateTime.Parse("01.04.2001")
        Dim maxDate As DateTime = DateTime.Parse(DateTime.Now.ToShortDateString)
        Dim dt As DateTime

        args.IsValid = (DateTime.TryParse(args.Value, dt) AndAlso
                     dt <= maxDate AndAlso
                     dt >= minDate)
    End Sub
    Protected Sub valDateRange_2_ServerValidate(source As Object, args As ServerValidateEventArgs)
        Dim minDate As DateTime = DateTime.Parse("01." + Date.Now.Month.ToString + ".2001")
        Dim maxDate As DateTime = DateTime.Parse(DateTime.Now.ToShortDateString)
        Dim dt As DateTime

        args.IsValid = (DateTime.TryParse(args.Value, dt) AndAlso
                     dt <= maxDate AndAlso
                     dt >= minDate) And dt < Date.Now.AddDays(-1)
    End Sub

    Protected Sub txt_LKWNr_TextChanged(sender As Object, e As EventArgs)
        regexval_txt_LKW.Validate()
    End Sub

    Protected Sub txt_Absender_TextChanged(sender As Object, e As EventArgs)
        regexval_txt_Absender.Validate()
    End Sub

    Protected Sub txt_KdNrAuftrag_TextChanged(sender As Object, e As EventArgs)
        regexval_txt_KdNrAuftrag.Validate()
    End Sub

    Protected Sub txt_Empfaenger_TextChanged(sender As Object, e As EventArgs)
        regexval_txt_Empfaenger.Validate()
    End Sub

    Protected Sub txt_LKWNr_M_TextChanged(sender As Object, e As EventArgs)
        regexval_txt_LKWNr_M.Validate()
    End Sub

    Protected Sub txt_Empfaenger_M_TextChanged(sender As Object, e As EventArgs)
        regval_txt_Empfaenger_M.Validate()
    End Sub

    Protected Sub txt_Absender_M_TextChanged(sender As Object, e As EventArgs)
        regval_txt_Absender_M.Validate()
    End Sub

    Protected Sub txt_KdNrAuftrag_M_TextChanged(sender As Object, e As EventArgs)
        regval_txt_KdNrAuftrag_M.Validate()
    End Sub
End Class