Public Class frmKundenZOLLOffertenSperre
    Public KundenNr = -1
    Public OffertenNr = -1
    Public OffertenTXT = ""
    Dim SQL As New SQL

    Sub New(KundenNr As Integer, OffertenNr As Integer, OffertenTXT As String)
        InitializeComponent()
        Me.OffertenNr = OffertenNr
        Me.KundenNr = KundenNr
        Me.OffertenTXT = OffertenTXT
    End Sub

    Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click

        SQL.doSQL("UPDATE Offerten SET Gesperrt=" & CInt(cbxSperreSetzen.Checked) & ", Gesperrt_Datum=GETDATE(), Gesperrt_Grund='" & txt.Text & "' WHERE KundenNr=" & KundenNr & " AND OffertenNr=" & OffertenNr & "", "FMZOLL")
    End Sub

    Private Sub frmKundenZOLLOffertenSperre_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim dt As DataTable = SQL.loadDgvBySql("SELECT TOP 1 * FROM Offerten WHERE KundenNr=" & KundenNr & " AND OffertenNr=" & OffertenNr & "", "FMZOLL")
        lblOffert.Text = OffertenTXT
        If dt IsNot Nothing Then
            If dt.Rows(0)("Gesperrt") Then
                cbxSperreSetzen.Checked = True
                txt.Text = dt.Rows(0)("Gesperrt_Grund")
            End If
        End If
    End Sub

    Private Sub cbxSperreSetzen_CheckedChanged(sender As Object, e As EventArgs) Handles cbxSperreSetzen.CheckedChanged
        txt.Enabled = cbxSperreSetzen.Checked
        txt.Text = ""
    End Sub
End Class