Public Class frmAddLKW
    Public OldLkW As String = ""
    Public SDLNr As String = ""
    Public History As String = ""
    Public kundenNr As String = ""
    Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click

        txtKennzeichen.Text = txtKennzeichen.Text.ToUpper
        MyTextBox2.Text = MyTextBox2.Text.ToUpper
        Label1.ForeColor = Color.Black

        If txtKennzeichen.Text = "" Then
            If OldLkW <> "" And OldLkW <> txtKennzeichen.Text Then
                Dim SQL As New SQL
                If cbxFurAlleLeistungenUbernehmen.Checked Then
                    Try
                        SQL.doSQL("UPDATE [LKW] SET KfzKennzeichen= '" & txtKennzeichen.Text & "' WHERE KundenNr='" & kundenNr & "' AND  KfzKennzeichen='" & OldLkW & "'", "SDL", True)
                        SQL.doSQL("UPDATE SDL SET KfzKennzeichen= '" & txtKennzeichen.Text & "' WHERE KundenNr='" & kundenNr & "' AND  KfzKennzeichen='" & OldLkW & "'", "SDL", True)
                        SQL.doSQL("UPDATE [Kartenpool] SET KfzKennzeichen= '" & txtKennzeichen.Text & "' WHERE KundenNr='" & kundenNr & "' AND  KfzKennzeichen='" & OldLkW & "'", "SDL", True)

                    Catch ex As Exception
                        MsgBox(ex.Message)
                    End Try
                Else
                    Try
                        SQL.doSQL("UPDATE SDL SET KfzKennzeichen= '" & txtKennzeichen.Text & "' WHERE KundenNr='" & kundenNr & "' AND  KfzKennzeichen='" & OldLkW & "' AND  SDLNr='" & SDLNr & "'  AND  History='" & History & "'", "SDL", True)
                    Catch ex As Exception
                        MsgBox(ex.Message)
                    End Try
                End If


                Me.Close()

            Else
                Label1.ForeColor = Color.Red
                txtKennzeichen.Focus()
                Me.DialogResult = Windows.Forms.DialogResult.None
            End If
        End If
    End Sub

    Private Sub MyTextBox2_KeyDown(sender As Object, e As KeyEventArgs) Handles txtKennzeichen.KeyDown, MyTextBox2.KeyDown
        If e.KeyCode = Keys.Return Then
            btnOK.PerformClick()
        End If
    End Sub

    Private Sub frmAddLKW_Load(sender As Object, e As EventArgs) Handles Me.Load
        If OldLkW <> "" Then
            txtKennzeichen.Text = OldLkW
            MyTextBox2.Visible = False
            Label2.Visible = False
            cbxFurAlleLeistungenUbernehmen.Visible = True
        End If
        txtKennzeichen.Focus()
    End Sub

    Private Sub txtKennzeichen_LostFocus(sender As Object, e As EventArgs) Handles txtKennzeichen.LostFocus
        txtKennzeichen.Text = txtKennzeichen.Text.ToUpper
    End Sub
    Private Sub MyTextBox2_LostFocus(sender As Object, e As EventArgs) Handles MyTextBox2.LostFocus
        MyTextBox2.Text = MyTextBox2.Text.ToUpper
    End Sub


End Class