
Imports System
Imports System.Web.Security
Imports System.Web.UI.WebControls

Partial Class LKWS
    Inherits System.Web.UI.Page
    Dim Kdnrtext As String = String.Empty
    Dim list As Collections.Generic.List(Of VERAG_PROG_ALLGEMEIN.cSDL) = Nothing
    Protected Sub Page_Load(sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        VERAG_VARIABLES.initerrorcount()
        If Me.Page.User.Identity.IsAuthenticated Then
            Try
                Kdnrtext = Session.Item("CustomerID")
            Catch A As UnauthorizedAccessException When String.IsNullOrEmpty(Kdnrtext)
                '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
        Else
            FormsAuthentication.RedirectToLoginPage()
        End If
        If Page.IsPostBack = True Then
            Page.MaintainScrollPositionOnPostBack = True
        Else
            Page.MaintainScrollPositionOnPostBack = False
        End If
    End Sub

    Protected Sub btn_alle_Click(sender As Object, e As EventArgs)
        'list = VERAG_PROG_ALLGEMEIN.cSDL.GET_LIST_WEB(Kdnrtext)
        'MsgBox("Test1")
        Dim cnt As Integer = 0
        list = VERAG_PROG_ALLGEMEIN.cSDL.GET_LIST_WEB(401940)
        Dim tbl_sidemenue As Table = FindControl("tbl_sidemenue")
        Dim tblhrow As TableHeaderRow = New TableHeaderRow()
        Dim tblheader_Cell1 As TableHeaderCell = FindControl("tbhc_KFZKennz")
        Dim tblheader_Cellnat As TableHeaderCell = FindControl("tbhc_Nat")
        Dim tblheader_Cellverk As TableHeaderCell = FindControl("tbhc_Verk")
        Dim tblheader_cell_KZ As TableHeaderCell = FindControl("tblhc_Kz")
        Dim tblheader_cell_Verm As TableHeaderCell = FindControl("tblhc_Verm")
        tblhrow.Cells.Add(tblheader_Cell1)
        tblhrow.Cells.Add(tblheader_Cellnat)
        tblhrow.Cells.Add(tblheader_Cellverk)
        tblhrow.Cells.Add(tblheader_cell_KZ)
        tblhrow.Cells.Add(tblheader_cell_Verm)

        tbl_sidemenue.Rows.Add(tblhrow)

        'tbl_sidemenue.Rows.Clear()
        'MsgBox("Test2")
        For Each l1 In list
            Dim tr1 As TableRow = New TableRow()
            Dim tc_KfzKennz As TableCell = New TableCell()
            Dim tc_Nationalitaet As TableCell = New TableCell()
            Dim tc_Verk As TableCell = New TableCell()
            Dim tc_KZ_An As TableCell = New TableCell()
            Dim tc_Vermerk As TableCell = New TableCell()

            tc_KfzKennz.Text = l1.KfzKennzeichen
            tr1.Cells.Add(tc_KfzKennz)
            tc_Nationalitaet.Text = String.Empty
            tr1.Cells.Add(tc_Nationalitaet)
            Dim cbverk As CheckBox = New CheckBox()
            tc_Verk.Controls.Add(cbverk)
            tr1.Cells.Add(tc_Verk)
            Dim chbx2_Kz_an As CheckBox = New CheckBox()
            tc_KZ_An.Controls.Add(chbx2_Kz_an)
            tr1.Cells.Add(tc_KZ_An)
            tc_Vermerk.Text = l1.Vermerk.ToString
            tr1.Cells.Add(tc_Vermerk)
            cnt += 1
            initcells(tblhrow, tblheader_Cell1, tblheader_Cellnat, tblheader_Cellverk, tblheader_cell_KZ, tblheader_cell_Verm, tr1, tc_KfzKennz, tc_Nationalitaet, tc_Verk, tc_KZ_An, tc_Vermerk, cnt)
            tbl_sidemenue.Rows.Add(tr1)
        Next
        'MsgBox("Test3")
    End Sub

    Private Sub initcells(thr1 As TableHeaderRow, th1 As TableHeaderCell, th2 As TableHeaderCell, th3 As TableHeaderCell, th4 As TableHeaderCell, th5 As TableHeaderCell, tr1 As TableRow, tc_KfzKennz As TableCell, tc_Nationalitaet As TableCell, tc_Verk As TableCell, tc_KZ_An As TableCell, tc_Vermerk As TableCell, countrows As Integer)
        Dim res As Integer
        thr1.BackColor = Drawing.Color.FromArgb(0, 4, 51, 129)
        th1.BackColor = Drawing.Color.FromArgb(0, 4, 51, 129)
        th2.BackColor = Drawing.Color.FromArgb(0, 4, 51, 129)
        th3.BackColor = Drawing.Color.FromArgb(0, 4, 51, 129)
        th4.BackColor = Drawing.Color.FromArgb(0, 4, 51, 129)
        th5.BackColor = Drawing.Color.FromArgb(0, 4, 51, 129)
        th1.ForeColor = Drawing.Color.White
        th2.ForeColor = Drawing.Color.White
        th3.ForeColor = Drawing.Color.White
        th4.ForeColor = Drawing.Color.White
        th5.ForeColor = Drawing.Color.White

        If Math.DivRem(countrows, 2, res) = 0 Then
            tr1.BackColor = Drawing.Color.LightBlue
            tc_KfzKennz.BackColor = Drawing.Color.LightBlue
            tc_KZ_An.BackColor = Drawing.Color.LightBlue
            tc_Nationalitaet.BackColor = Drawing.Color.LightBlue
            tc_Verk.BackColor = Drawing.Color.LightBlue
            tc_Vermerk.BackColor = Drawing.Color.LightBlue
            tr1.ForeColor = Drawing.Color.Black
            tc_KfzKennz.ForeColor = Drawing.Color.FromArgb(0, 4, 51, 129)
            tc_KZ_An.ForeColor = Drawing.Color.FromArgb(0, 4, 51, 129)
            tc_Nationalitaet.ForeColor = Drawing.Color.FromArgb(0, 4, 51, 129)
            tc_Verk.ForeColor = Drawing.Color.FromArgb(0, 4, 51, 129)
            tc_Vermerk.ForeColor = Drawing.Color.FromArgb(0, 4, 51, 129)
        Else
            tr1.BackColor = Drawing.Color.WhiteSmoke
            tc_KfzKennz.BackColor = Drawing.Color.WhiteSmoke
            tc_KZ_An.BackColor = Drawing.Color.WhiteSmoke
            tc_Nationalitaet.BackColor = Drawing.Color.WhiteSmoke
            tc_Verk.BackColor = Drawing.Color.WhiteSmoke
            tc_Vermerk.BackColor = Drawing.Color.WhiteSmoke
            tc_KfzKennz.ForeColor = Drawing.Color.FromArgb(0, 4, 51, 129)
            tc_KZ_An.ForeColor = Drawing.Color.FromArgb(0, 4, 51, 129)
            tc_Nationalitaet.ForeColor = Drawing.Color.FromArgb(0, 4, 51, 129)
            tc_Verk.ForeColor = Drawing.Color.FromArgb(0, 4, 51, 129)
            tc_Vermerk.ForeColor = Drawing.Color.FromArgb(0, 4, 51, 129)
        End If
    End Sub

    Protected Sub btn_Suchen_Click(sender As Object, e As EventArgs)
        'MsgBox("Test0")
        Dim txt_LkwNr As TextBox = Page.FindControl("txt_LkwNr")
        'list = VERAG_PROG_ALLGEMEIN.cSDL.GET_LIST_WEB(401940, "COOPER8")
        list = VERAG_PROG_ALLGEMEIN.cSDL.GET_LIST_WEB(401940, txt_LkwNr.Text)
        Dim tbl_sidemenue2 As Table = FindControl("tbl_sidemenue")
        Dim tblhrow As TableHeaderRow = New TableHeaderRow()
        Dim tblheader_Cell1 As TableHeaderCell = FindControl("tbhc_KFZKennz")
        Dim tblheader_Cellnat As TableHeaderCell = FindControl("tbhc_Nat")
        Dim tblheader_Cellverk As TableHeaderCell = FindControl("tbhc_Verk")
        Dim tblheader_cell_KZ As TableHeaderCell = FindControl("tblhc_Kz")
        Dim tblheader_cell_Verm As TableHeaderCell = FindControl("tblhc_Verm")
        tblhrow.Cells.Add(tblheader_Cell1)
        tblhrow.Cells.Add(tblheader_Cellnat)
        tblhrow.Cells.Add(tblheader_Cellverk)
        tblhrow.Cells.Add(tblheader_cell_KZ)
        tblhrow.Cells.Add(tblheader_cell_Verm)

        tbl_sidemenue2.Rows.Add(tblhrow)
        'tbl_sidemenue2.Rows.Clear()
        'MsgBox("Test1")
        For Each l2 In list
            Dim cnt As Integer = 0
            Dim tr2 As TableRow = New TableRow()
            Dim tc_KfzKennz As TableCell = New TableCell()
            Dim tc_Nationalitaet As TableCell = New TableCell()
            Dim tc_Verk As TableCell = New TableCell()
            Dim tc_KZ_An As TableCell = New TableCell()
            Dim tc_Vermerk As TableCell = New TableCell()
            tc_KfzKennz.Text = l2.KfzKennzeichen.ToString
            tr2.Cells.Add(tc_KfzKennz)
            tc_Nationalitaet.Text = String.Empty
            tr2.Cells.Add(tc_Nationalitaet)
            Dim cbVerk_Such As CheckBox = New CheckBox()
            tc_Verk.Controls.Add(cbVerk_Such)
            tr2.Cells.Add(tc_Verk)
            Dim cb_Kz_An As CheckBox = New CheckBox()
            tc_KZ_An.Controls.Add(cb_Kz_An)
            tc_Vermerk.Text = l2.Vermerk.ToString
            tr2.Cells.Add(tc_Vermerk)

            'tr2.Attributes.Add("command", "getinfos")
            initcells(tblhrow, tblheader_Cell1, tblheader_Cellnat, tblheader_Cellverk, tblheader_cell_KZ, tblheader_cell_Verm, tr2, tc_KfzKennz, tc_Nationalitaet, tc_Verk, tc_KZ_An, tc_Vermerk, cnt)
            tbl_sidemenue2.Rows.Add(tr2)
            cnt += 1
        Next
        'MsgBox("Test2")
    End Sub

    Protected Sub getinfos(varz As Integer)

    End Sub
End Class
