Imports IntraSell_DLL
Imports IntraSell_Net_Base

Public Class Einstellungen
    Inherits AbstractForm

    Private lokaleSettings As New ClassSettings

    Private Sub Form_Verlassen() Handles MyBase.Verlassen
        Me.Close()
    End Sub

    Private Sub Einstellungen_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            If Not HasRecht(Rechte.Administrator) Then
                Exit Sub
            End If

            ParentBindingNavigator.Visible = False
            CheckBoxPrintAmBildschirm.Checked = VarValue_Default(PRINT_AM_BILDSCHIRM, "false")
            CheckBoxDeaktiviereNettoPreis.Checked = VarValue_Default(BARRECHNUNG_NUR_BRUTTO_PREISE, "false")
            CheckBoxDeaktiviereFeldKunde.Checked = VarValue_Default(BARRECHNUNG_DEAKTIVIERE_KUNDE, "false")
            CheckBoxDeaktiviereFeldMitarbeiter.Checked = VarValue_Default(BARRECHNUNG_DEAKTIVIERE_MITARBEITER, "false")
            ComboBoxPOS_WAIT.Text = VarValue_Default(POS_WAIT, "10")
            ComboBoxBezLaenge.Text = VarValue_Default(BARRECHNUNG_BEZEICHNUNG_LAENGE, "20")
            CheckBoxNoRabatt.Checked = VarValue_Default(BARRECHNUNG_DEAKTIVIERE_RABATT, "false")
            CheckBoxSilent.Checked = VarValue_Default(BARRECHNUNG_SILENT, "true")
            CheckBoxMenuVerstecken.Checked = VarValue_Default(BARRECHNUNG_RESTAURANT_KASSA_MAIN_MENU_VERSTECKT, "true")
            ComboBoxDrucker.Text = VarValue(PRINT_PORT)
            TextBoxPrinterShare.Text = VarValue_Default(PRINT_SHARE, "\\127.0.0.1\Drucker")

            If ExistsVarValue(PRINT_PORT_KUECHE) Then
                ComboBoxDruckerKueche.Text = VarValue(PRINT_PORT_KUECHE)
            End If

            If ExistsVarValue(PRINT_PORT_PIZZA) Then
                ComboBoxDruckerPizza.Text = VarValue(PRINT_PORT_PIZZA)
            End If

            If ExistsVarValue(PRINT_PORT_BAR) Then
                ComboBoxDruckerBAR.Text = VarValue(PRINT_PORT_BAR)
            End If

            CheckBoxKeineEingabeBarGegeben.Checked = VarValue_Default(BARRECHNUNG_KEINE_EINGABE_BAR_GEGEBEN, "true")

            If ExistsVarValue(CUSTOMER_DISPLAY_TYP) Then
                ComboBoxCustomerDisplayTyp.Text = VarValue(CUSTOMER_DISPLAY_TYP)
            End If
            If ExistsVarValue(CUSTOMER_DISPLAY_PRINT_PORT) Then
                ComboBoxCustomerDisplay.Text = VarValue(CUSTOMER_DISPLAY_PRINT_PORT)
            End If

            CheckBoxZeigeDisplay.Checked = VarValue_Default(CUSTOMER_DISPLAY_ANZEIGE_AM_BILDSCHIRM, True)

            If ExistsVarValue(BARRECHNUNG_STANDARD_ARTNR) Then
                ArtikelControl1.ArtNr = VarValue(BARRECHNUNG_STANDARD_ARTNR)
            Else
                ArtikelControl1.ArtNr = Nothing
            End If

            CheckBoxNachScanSofortNeuePosition.Checked = VarValue_Default(BARRECHNUNG_BARCODE_SCAN_SOFORT_NEUE_POSITION, True)
            CheckBoxRestaurantKassaSimpel.Checked = VarValue_Default(BARRECHNUNG_RESTAURANT_KASSA_SIMPEL, False)
            ComboBoxRestKassaSortierung.Text = VarValue_Default(BARRECHNUNG_RESTAURANT_SORTIERUNG, "Bezeichnung")

            ListInstalledPrinters(ComboBoxDrucker)
            ListInstalledPrinters(ComboBoxDruckerBAR)
            ListInstalledPrinters(ComboBoxDruckerKueche)
            ListInstalledPrinters(ComboBoxDruckerPizza)

            '"Tasten"
            ButtonArtikelTaste.Height = VarValue_Default(BARRECHNUNG_RESTAURANT_KASSA_BUTTON_HOEHE, 50)
            ButtonArtikelTaste.Width = VarValue_Default(BARRECHNUNG_RESTAURANT_KASSA_BUTTON_BREITE, 100)
            ButtonArtikelTaste.Font = New Font("Arial", VarValue_Default(BARRECHNUNG_RESTAURANT_KASSA_SCHRIFT_GROESSE, 10))

            CheckBoxVersteckeMainMenu.Checked = VarValue_Default(BARRECHNUNG_RESTAURANT_KASSA_MAIN_MENU_VERSTECKT, False)

            If ExistsVarValue(AUTOSTART) Then
                CheckBoxAutostart.Checked = VarValue(AUTOSTART)
            End If
            If ExistsVarValue(PRINT_REPORT_TEMPLATE_NAME) Then
                ComboBoxTemplateName.Text = VarValue(PRINT_REPORT_TEMPLATE_NAME)
            End If
            If ExistsVarValue(BARRECHNUNG_KEINE_TISCHE) Then
                CheckBoxDeaktiviereTische.Checked = VarValue(BARRECHNUNG_KEINE_TISCHE)
            End If
            If ExistsVarValue(BARRECHNUNG_QRCODE_TEXT) Then
                CheckBoxQR_CODE_TEXT.Checked = VarValue(BARRECHNUNG_QRCODE_TEXT)
            End If

            If ExistsVarValue(BARRECHNUNG_KASSA_SIMPEL) Then
                CheckBoxKassaSimpel.Checked = VarValue(BARRECHNUNG_KASSA_SIMPEL)
            End If

            If ExistsVarValue(DRUCKER_PAPIER_BREITE_MM) Then
                TextBox_DRUCKER_PAPIER_BREITE_MM.Text = VarValue(DRUCKER_PAPIER_BREITE_MM)
            End If

            If ExistsVarValue(DRUCKER_PAPIER_LAENGE_MM) Then
                TextBox_DRUCKER_PAPIER_LAENGE_MM.Text = VarValue(DRUCKER_PAPIER_LAENGE_MM)
            End If

            If ExistsVarValue(BARRECHNUNG_KEINE_ZUSTELLUNG) Then
                CheckBoxDeaktiviereZustellung.Checked = VarValue(BARRECHNUNG_KEINE_ZUSTELLUNG)
            End If

            CheckBoxRECHNUNG_BAR_NACH_ABSCHLIESSEN_NEU.Checked = VarValue_Default(RECHNUNG_BAR_NACH_ABSCHLIESSEN_NEU, "false")

            CheckBoxPositionenGruppieren.Checked = VarValue_Default(BARRECHNUNG_POSITIONEN_GRUPPIEREN, "true")

            If ExistsVarValue(BETRIEB_STARTZEIT) Then
                ComboBoxBetriebszeitStart.SelectedItem = VarValue(BETRIEB_STARTZEIT)
            End If

            If IsNothing(lokaleSettings.Read(PcHatSignaturEinheit)) Then
                CheckBoxSignierServer.ForeColor = Color.Gray
            End If
            CheckBoxSignierServer.Checked = lokaleSettings.ReadBoolean(PcHatSignaturEinheit, True)
            If ExistsVarValue(PRINT_ZWEITE_RECHNUNG_FUER_ZUSTELLUNGEN) Then
                CheckBoxPRINT_ZWEITE_RECHNUNG_FUER_ZUSTELLUNGEN.Checked = VarValue(PRINT_ZWEITE_RECHNUNG_FUER_ZUSTELLUNGEN)
            End If

            If ExistsVarValue(BEEP) Then
                CheckBoxBeep.Checked = VarValue(BEEP)
            Else
                CheckBoxBeep.Checked = True
            End If

            CheckBoxBilder.Checked = VarValue_Default(BARRECHNUNG_RESTAURANT_KASSA_BUTTON_BILD, False)


            If ExistsVarValue(BARRECHNUNG_STANDARD_ARTKATNR & "_" & MitarbeiterID) Then
                ArtikelKategorieControl1.ArtKatNr = VarValue(BARRECHNUNG_STANDARD_ARTKATNR & "_" & MitarbeiterID)
            End If

            If ExistsVarValue(BARRECHNUNG_TOP_ARTIKEL) Then
                CheckBoxTopKategorie.Checked = VarValue_Default(BARRECHNUNG_TOP_ARTIKEL, True)
            Else
                CheckBoxTopKategorie.Checked = True
            End If


            If ExistsVarValue(PRINT_ZUSTELLADRESSE_QR_CODE) Then
                CheckBoxPRINT_ZUSTELLADRESSE.Checked = VarValue_Default(PRINT_ZUSTELLADRESSE_QR_CODE, True)
            Else
                CheckBoxPRINT_ZUSTELLADRESSE.Checked = True
            End If
            CheckBoxPRINT_ZUSTELLADRESSE1.Checked = CheckBoxPRINT_ZUSTELLADRESSE.Checked

            If ExistsVarValue(AUTOSTART_FORM) Then
                CheckBoxEasyKassaAutostart.Checked = "EasyKassa".Equals(VarValue(AUTOSTART_FORM))
            End If

            If ExistsVarValue(Variablen.PRINT_FEEDBACK_QRCODE) Then
                CheckBoxPRINT_FEEDBACK_QRCODE.Checked = VarValue(Variablen.PRINT_FEEDBACK_QRCODE)
            End If

            If ExistsVarValue(Variablen.ORDER_FEEDBACK_URL) Then
                TextBoxOrderFeedback.Text = VarValue(Variablen.ORDER_FEEDBACK_URL)
            End If

            CheckBoxPositionenBeimDruckenSortieren.Checked = VarValue_Default(Variablen.PRINT_SORTIERUNG_KATEGORIE, True)
            CheckBoxKuecheAmStandardDrucken.Checked = VarValue_Default(Variablen.PRINT_KUECHE_AM_STANDARD, False)
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub

    Sub ListInstalledPrinters(ByRef combo As ComboBox)
        combo.Items.Add("/d:\\127.0.0.1\PrintShare")
        combo.Items.Add("/d:\\127.0.0.1\Rechnung")
        For Each InstalledPrinters In Drawing.Printing.PrinterSettings.InstalledPrinters
            combo.Items.Add("/d:""" + InstalledPrinters + """")
        Next InstalledPrinters
    End Sub

    Private Sub CheckBoxPrintAmBildschirm_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxPrintAmBildschirm.CheckedChanged
        SetVarValue(PRINT_AM_BILDSCHIRM, CheckBoxPrintAmBildschirm.Checked.ToString)
    End Sub

    Private Sub CheckBoxDeaktiviereNettoPreis_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxDeaktiviereNettoPreis.CheckedChanged
        SetVarValue(BARRECHNUNG_NUR_BRUTTO_PREISE, CheckBoxDeaktiviereNettoPreis.Checked.ToString)
    End Sub


    Private Sub CheckBoxDeaktiviereFeldKunde_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxDeaktiviereFeldKunde.CheckedChanged
        SetVarValue(BARRECHNUNG_DEAKTIVIERE_KUNDE, CheckBoxDeaktiviereFeldKunde.Checked.ToString)
    End Sub

    Private Sub CheckBoxDeaktiviereFeldMitarbeiter_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxDeaktiviereFeldMitarbeiter.CheckedChanged
        SetVarValue(BARRECHNUNG_DEAKTIVIERE_MITARBEITER, CheckBoxDeaktiviereFeldMitarbeiter.Checked.ToString)
    End Sub

    Private Sub ComboBoxPOS_WAIT_DropDownClosed(sender As Object, e As EventArgs) Handles ComboBoxPOS_WAIT.DropDownClosed
        SetVarValue(POS_WAIT, ComboBoxPOS_WAIT.SelectedItem)
    End Sub

    Private Sub ComboBoxBezLaenge_DropDownClosed(sender As Object, e As EventArgs) Handles ComboBoxBezLaenge.DropDownClosed
        SetVarValue(BARRECHNUNG_BEZEICHNUNG_LAENGE, ComboBoxBezLaenge.SelectedItem)
    End Sub

    Private Sub CheckBoxNoRabatt_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxNoRabatt.CheckedChanged
        SetVarValue(BARRECHNUNG_DEAKTIVIERE_RABATT, CheckBoxNoRabatt.Checked.ToString)
    End Sub

    Private Sub CheckBoxSilent_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxSilent.CheckedChanged
        SetVarValue(BARRECHNUNG_SILENT, CheckBoxSilent.Checked.ToString)
    End Sub

#Region "Drucker"
    Private Sub ComboBoxDrucker_DropDownClosed(sender As Object, e As EventArgs) Handles ComboBoxDrucker.DropDownClosed
        SetVarValue(PRINT_PORT, ComboBoxDrucker.SelectedItem)
    End Sub

    Private Sub ComboBoxDrucker_TextChanged(sender As Object, e As EventArgs) Handles ComboBoxDrucker.TextUpdate
        SetVarValue(PRINT_PORT, ComboBoxDrucker.Text)
    End Sub

    Private Sub ComboBoxDruckerKueche_DropDownClosed(sender As Object, e As EventArgs) Handles ComboBoxDruckerKueche.DropDownClosed
        SetVarValue(PRINT_PORT_KUECHE, ComboBoxDruckerKueche.SelectedItem)
    End Sub

    Private Sub ComboBoxDruckerKueche_TextChanged(sender As Object, e As EventArgs) Handles ComboBoxDruckerKueche.TextUpdate
        SetVarValue(PRINT_PORT_KUECHE, ComboBoxDruckerKueche.Text)
    End Sub

    Private Sub ComboBoxDruckerPizza_DropDownClosed(sender As Object, e As EventArgs) Handles ComboBoxDruckerPizza.DropDownClosed
        SetVarValue(PRINT_PORT_PIZZA, ComboBoxDruckerPizza.SelectedItem)
    End Sub

    Private Sub ComboBoxDruckerPizza_TextChanged(sender As Object, e As EventArgs) Handles ComboBoxDruckerPizza.TextUpdate
        SetVarValue(PRINT_PORT_PIZZA, ComboBoxDruckerPizza.Text)
    End Sub

    Private Sub ComboBoxDruckerBAR_DropDownClosed(sender As Object, e As EventArgs) Handles ComboBoxDruckerBAR.DropDownClosed
        SetVarValue(PRINT_PORT_BAR, ComboBoxDruckerBAR.SelectedItem)
    End Sub

    Private Sub ComboBoxDruckerBAR_TextChanged(sender As Object, e As EventArgs) Handles ComboBoxDruckerBAR.TextUpdate
        SetVarValue(PRINT_PORT_BAR, ComboBoxDruckerBAR.Text)
    End Sub

#End Region

    Private Sub CheckBoxKeineEingabeBarGegeben_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxKeineEingabeBarGegeben.CheckedChanged
        SetVarValue(BARRECHNUNG_KEINE_EINGABE_BAR_GEGEBEN, CheckBoxKeineEingabeBarGegeben.Checked)
    End Sub
#Region "Kundendisplay"

    Private Sub ComboBoxCustomerDisplay_DropDownClosed(sender As Object, e As EventArgs) Handles ComboBoxCustomerDisplay.DropDownClosed
        SetVarValue(CUSTOMER_DISPLAY_PRINT_PORT, ComboBoxCustomerDisplay.SelectedItem)
    End Sub
    Private Sub CheckBoxZeigeDisplay_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxZeigeDisplay.CheckedChanged
        SetVarValue(CUSTOMER_DISPLAY_ANZEIGE_AM_BILDSCHIRM, CheckBoxZeigeDisplay.Checked.ToString)
    End Sub
    Private Sub ComboBoxCustomerDisplayTyp_DropDownClosed(sender As Object, e As EventArgs) Handles ComboBoxCustomerDisplayTyp.DropDownClosed
        SetVarValue(CUSTOMER_DISPLAY_TYP, ComboBoxCustomerDisplayTyp.SelectedItem)
        If ComboBoxCustomerDisplayTyp.SelectedItem.Contains("Columbus") Then
            SetVarValue(CUSTOMER_DISPLAY_PRINT_PORT, "COM1")
            SetVarValue("CUSTOMER_DISPLAY_BAUD_RATE", "38400")
            SetVarValue("CUSTOMER_DISPLAY_DATA_BITS", "8")
            SetVarValue("CUSTOMER_DISPLAY_PARITY", "0 - NONE") 'oder  "1 - ODD"
            SetVarValue("CUSTOMER_DISPLAY_STOP_BITS", "1 - ONE")
            SetVarValue("CUSTOMER_DISPLAY_HANDSHAKE", "2 - RTS/CTS") 'TODO Diese Einstellung kann nicht in VB.NET gesetzt werden 

        ElseIf ComboBoxCustomerDisplayTyp.SelectedItem.Contains("Glancetron") Then
            SetVarValue(CUSTOMER_DISPLAY_PRINT_PORT, "COM3")
            SetVarValue("CUSTOMER_DISPLAY_BAUD_RATE", "9600")
            SetVarValue("CUSTOMER_DISPLAY_DATA_BITS", "8")
            SetVarValue("CUSTOMER_DISPLAY_PARITY", "0 - NONE")
            SetVarValue("CUSTOMER_DISPLAY_STOP_BITS", "1 - ONE")

        ElseIf ComboBoxCustomerDisplayTyp.SelectedItem.Contains("Posligne") Then
            SetVarValue(CUSTOMER_DISPLAY_PRINT_PORT, "COM7")
            SetVarValue("CUSTOMER_DISPLAY_BAUD_RATE", "9600")
            SetVarValue("CUSTOMER_DISPLAY_DATA_BITS", "8")
            SetVarValue("CUSTOMER_DISPLAY_PARITY", "0 - NONE")
            SetVarValue("CUSTOMER_DISPLAY_STOP_BITS", "1 - ONE")
        End If
    End Sub
    Private Sub ButtoncustDisplayMore_Click(sender As Object, e As EventArgs) Handles ButtoncustDisplayMore.Click
        Vars.Show()
        Vars.Filter("CUSTOMER_DISPLAY")
    End Sub

#End Region
    Private Sub ArtikelControl1_ArtNrChanged(ArtNr As Integer) Handles ArtikelControl1.ArtNrChanged
        SetVarValue(BARRECHNUNG_STANDARD_ARTNR, ArtikelControl1.ArtNr)
    End Sub

    Private Sub ButtonEntferneStandard_Click(sender As Object, e As EventArgs) Handles ButtonEntferneStandard.Click
        DeleteVar(BARRECHNUNG_STANDARD_ARTNR)
        ArtikelControl1.ArtNr = Nothing
    End Sub

    Private Sub CheckBoxNachScanSofortNeuePosition_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxNachScanSofortNeuePosition.CheckedChanged
        SetVarValue(BARRECHNUNG_BARCODE_SCAN_SOFORT_NEUE_POSITION, CheckBoxNachScanSofortNeuePosition.Checked)
    End Sub

    Private Sub TextBoxPrinterShare_TextChanged(sender As Object, e As EventArgs) Handles TextBoxPrinterShare.TextChanged
        SetVarValue(PRINT_SHARE, TextBoxPrinterShare.Text)
    End Sub

    Private Sub ButtonNetUse_Click(sender As Object, e As EventArgs) Handles ButtonNetUse.Click
        Try
            Dim cmdDel As String = "NET use " & VarValue(PRINT_PORT).Replace("/d:", "") & " /delete"
            Dim cmd As String = "NET use " & VarValue(PRINT_PORT).Replace("/d:", "") & " " & VarValue(PRINT_SHARE) & " /PERSISTENT:YES"""

            WriteLog(cmdDel)
            WriteLog(cmd)

            LabelCommand.Text = cmdDel & vbNewLine & cmd
            Shell(cmdDel, AppWinStyle.NormalFocus, True, 7000)
            Shell(cmd, AppWinStyle.NormalFocus, True, 7000)
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub

    Private Sub CheckBoxRestaurantKassaSimpel_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxRestaurantKassaSimpel.CheckedChanged
        SetVarValue(BARRECHNUNG_RESTAURANT_KASSA_SIMPEL, CheckBoxRestaurantKassaSimpel.Checked)
    End Sub

    Private Sub ComboBoxRestKassaSortierung_DropDownClosed(sender As Object, e As EventArgs) Handles ComboBoxRestKassaSortierung.DropDownClosed
        Try
            SetVarValue(BARRECHNUNG_RESTAURANT_SORTIERUNG, ComboBoxRestKassaSortierung.SelectedItem)
            If MsgBox("Möchten Sie die manuel eingestellte Positionen der Tasten löschen?", vbYesNo) = vbYes Then
                RunSQL("update grartikel set artkatpos = null")
            End If
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub

#Region "Tasten"
    Private Sub ButtonHoehePlus_Click(sender As Object, e As EventArgs) Handles ButtonHoehePlus.Click
        ButtonArtikelTaste.Height = ButtonArtikelTaste.Height + 1
        SetVarValue(BARRECHNUNG_RESTAURANT_KASSA_BUTTON_HOEHE, ButtonArtikelTaste.Height)
    End Sub

    Private Sub ButtonHoeheMinus_Click(sender As Object, e As EventArgs) Handles ButtonHoeheMinus.Click
        ButtonArtikelTaste.Height = ButtonArtikelTaste.Height - 1
        SetVarValue(BARRECHNUNG_RESTAURANT_KASSA_BUTTON_HOEHE, ButtonArtikelTaste.Height)
    End Sub

    Private Sub ButtonBreiteMinus_Click(sender As Object, e As EventArgs) Handles ButtonBreiteMinus.Click
        ButtonArtikelTaste.Width = ButtonArtikelTaste.Width - 1
        SetVarValue(BARRECHNUNG_RESTAURANT_KASSA_BUTTON_BREITE, ButtonArtikelTaste.Width)
    End Sub

    Private Sub ButtonBreitePlus_Click(sender As Object, e As EventArgs) Handles ButtonBreitePlus.Click
        ButtonArtikelTaste.Width = ButtonArtikelTaste.Width + 1
        SetVarValue(BARRECHNUNG_RESTAURANT_KASSA_BUTTON_BREITE, ButtonArtikelTaste.Width)
    End Sub
    Private Sub ButtonFontSizePlus_Click(sender As Object, e As EventArgs) Handles ButtonFontSizePlus.Click
        ButtonArtikelTaste.Font = New Font("Arial", ButtonArtikelTaste.Font.Size + 1)
        SetVarValue(BARRECHNUNG_RESTAURANT_KASSA_SCHRIFT_GROESSE, ButtonArtikelTaste.Font.Size)
    End Sub

    Private Sub ButtonFontSizeMinus_Click(sender As Object, e As EventArgs) Handles ButtonFontSizeMinus.Click
        ButtonArtikelTaste.Font = New Font("Arial", ButtonArtikelTaste.Font.Size - 1)
        SetVarValue(BARRECHNUNG_RESTAURANT_KASSA_SCHRIFT_GROESSE, ButtonArtikelTaste.Font.Size)
    End Sub

#End Region

    Private Sub CheckBoxVersteckeMainMenu_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxVersteckeMainMenu.CheckedChanged
        SetVarValue(BARRECHNUNG_RESTAURANT_KASSA_MAIN_MENU_VERSTECKT, CheckBoxVersteckeMainMenu.Checked)
    End Sub

    Private Sub ButtonVorlageBeleg_Click(sender As Object, e As EventArgs) Handles ButtonVorlageBeleg.Click
        Try
            Dim ve As New VorlageEditor(VORLAGE_RECHNUNG) With {
                .MdiParent = MdiParent
            }
            ve.Show()
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub

    Private Sub ButtonVorgangInfo_Click(sender As Object, e As EventArgs) Handles ButtonVorgangInfp.Click
        Try
            Dim ve As New VorlageEditor(VORLAGE_INFO) With {
                .MdiParent = MdiParent
            }
            ve.Show()
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub

    Private Sub ButtonVorgangSMS_Click(sender As Object, e As EventArgs) Handles ButtonVorgangSMS.Click
        Try
            Dim ve As New VorlageEditor(VORLAGE_VORGANG_SMS) With {
                .MdiParent = MdiParent
            }
            ve.Show()
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub

    Private Sub ButtonBerechtigungen_Click(sender As Object, e As EventArgs) Handles ButtonBerechtigungen.Click
        Try
            Mitarbeiter.MdiParent = MdiParent
            Mitarbeiter.Show()
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub

    Private Sub CheckBoxMenuVerstecken_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxMenuVerstecken.CheckedChanged
        SetVarValue(BARRECHNUNG_RESTAURANT_KASSA_MAIN_MENU_VERSTECKT, CheckBoxMenuVerstecken.Checked)
    End Sub


    Private Sub ButtonWorkflow_Click(sender As Object, e As EventArgs) Handles ButtonWorkflow.Click
        VorgangEinstellungen.Show()
        VorgangEinstellungen.Filter(VorgangTypen.AU)
    End Sub

    Private Sub CheckBoxAutostart_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxAutostart.CheckedChanged
        Try
            SetVarValue(AUTOSTART, CheckBoxAutostart.Checked.ToString)
            SetAutostart(CheckBoxAutostart.Checked)
        Catch ex As Exception

        End Try
    End Sub


    Private Sub ComboBoxTemplateName_TextChanged(sender As Object, e As EventArgs) Handles ComboBoxTemplateName.TextChanged
        SetVarValue(PRINT_REPORT_TEMPLATE_NAME, ComboBoxTemplateName.Text)
    End Sub

    Private Sub CheckBoxDeaktiviereTische_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxDeaktiviereTische.CheckedChanged
        SetVarValue(BARRECHNUNG_KEINE_TISCHE, CheckBoxDeaktiviereTische.Checked)
    End Sub

    Private Sub CheckBoxQR_CODE_TEXT_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxQR_CODE_TEXT.CheckedChanged
        SetVarValue(BARRECHNUNG_QRCODE_TEXT, CheckBoxQR_CODE_TEXT.Checked)
    End Sub

    Private Sub ButtonFirmaVars_Click(sender As Object, e As EventArgs) Handles ButtonFirmaVars.Click
        Vars.Show()
        Vars.Filter("Firma")
    End Sub

    Private Sub CheckBoxKassaSimpel_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxKassaSimpel.CheckedChanged
        SetVarValue(BARRECHNUNG_KASSA_SIMPEL, CheckBoxKassaSimpel.Checked)
    End Sub

    Private Sub LabelCommand_Click(sender As Object, e As EventArgs) Handles LabelCommand.Click

    End Sub

    Private Sub ComboBoxTemplateName_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBoxTemplateName.SelectedIndexChanged

    End Sub

    Private Sub TextBox_DRUCKER_PAPIER_BREITE_MM_TextChanged(sender As Object, e As EventArgs) Handles TextBox_DRUCKER_PAPIER_BREITE_MM.TextChanged
        SetVarValue(DRUCKER_PAPIER_BREITE_MM, TextBox_DRUCKER_PAPIER_BREITE_MM.Text)
    End Sub

    Private Sub TextBox_DRUCKER_PAPIER_LAENGE_MM_TextChanged(sender As Object, e As EventArgs) Handles TextBox_DRUCKER_PAPIER_LAENGE_MM.TextChanged
        SetVarValue(DRUCKER_PAPIER_LAENGE_MM, TextBox_DRUCKER_PAPIER_LAENGE_MM.Text)
    End Sub

    Private Sub CheckBoxDeaktiviereZustellung_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxDeaktiviereZustellung.CheckedChanged
        SetVarValue(BARRECHNUNG_KEINE_ZUSTELLUNG, CheckBoxDeaktiviereZustellung.Checked)
    End Sub

    Private Sub CheckBoxRECHNUNG_BAR_NACH_ABSCHLIESSEN_NEU_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxRECHNUNG_BAR_NACH_ABSCHLIESSEN_NEU.CheckedChanged
        SetVarValue(RECHNUNG_BAR_NACH_ABSCHLIESSEN_NEU, CheckBoxRECHNUNG_BAR_NACH_ABSCHLIESSEN_NEU.Checked)
    End Sub

    Private Sub CheckBoxPositionenGruppieren_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxPositionenGruppieren.CheckedChanged
        SetVarValue(BARRECHNUNG_POSITIONEN_GRUPPIEREN, CheckBoxPositionenGruppieren.Checked)
    End Sub

    Private Sub ComboBoxBetriebszeitStart_DropDownClosed(sender As Object, e As EventArgs) Handles ComboBoxBetriebszeitStart.DropDownClosed
        SetVarValue(BETRIEB_STARTZEIT, ComboBoxBetriebszeitStart.SelectedItem)
    End Sub

    Private Sub CheckBoxSignierServer_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxSignierServer.CheckedChanged
        lokaleSettings.Write(PcHatSignaturEinheit, CheckBoxSignierServer.Checked)
    End Sub

    Private Sub ButtonArtikelTaste_Click(sender As Object, e As EventArgs) Handles ButtonArtikelTaste.Click

    End Sub

    Private Sub CheckBoxPRINT_ZWEITE_RECHNUNG_FUER_ZUSTELLUNGEN_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxPRINT_ZWEITE_RECHNUNG_FUER_ZUSTELLUNGEN.CheckedChanged
        SetVarValue(PRINT_ZWEITE_RECHNUNG_FUER_ZUSTELLUNGEN, CheckBoxPRINT_ZWEITE_RECHNUNG_FUER_ZUSTELLUNGEN.Checked)
    End Sub

    Private Sub CheckBoxBeep_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxBeep.CheckedChanged
        SetVarValue(BEEP, CheckBoxBeep.Checked)
    End Sub

    Private Sub CheckBoxBilder_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxBilder.CheckedChanged
        SetVarValue(BARRECHNUNG_RESTAURANT_KASSA_BUTTON_BILD, CheckBoxBilder.Checked)
    End Sub

    Private Sub ArtikelKategorieControl1_ArtKatNrChanged(ArtKatNr As Integer) Handles ArtikelKategorieControl1.ArtKatNrChanged2
        SetVarValue(BARRECHNUNG_STANDARD_ARTKATNR & "_" & MitarbeiterID, ArtKatNr)
    End Sub

    Private Sub CheckBoxTopKategorie_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxTopKategorie.CheckedChanged
        SetVarValue(BARRECHNUNG_TOP_ARTIKEL, CheckBoxTopKategorie.Checked)
    End Sub

    Private Sub CheckBoxPRINT_ZUSTELLADRESSE_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxPRINT_ZUSTELLADRESSE.CheckedChanged
        SetVarValue(PRINT_ZUSTELLADRESSE_QR_CODE, CheckBoxPRINT_ZUSTELLADRESSE.Checked)
    End Sub

    Private Sub CheckBoxEasyKassaAutostart_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxEasyKassaAutostart.CheckedChanged
        If CheckBoxEasyKassaAutostart.Checked Then
            SetVarValue(AUTOSTART_FORM, "EasyKassa")
        Else
            DeleteVar(AUTOSTART_FORM)
        End If
    End Sub

    Private Sub CheckBoxPRINT_ZUSTELLADRESSE1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxPRINT_ZUSTELLADRESSE1.CheckedChanged
        SetVarValue(Variablen.PRINT_ZUSTELLADRESSE_QR_CODE, CheckBoxPRINT_ZUSTELLADRESSE1.Checked)
    End Sub

    Private Sub CheckBoxPRINT_FEEDBACK_QRCODE_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxPRINT_FEEDBACK_QRCODE.CheckedChanged
        SetVarValue(Variablen.PRINT_FEEDBACK_QRCODE, CheckBoxPRINT_FEEDBACK_QRCODE.Checked)
    End Sub

    Private Sub TextBoxOrderFeedback_TextChanged(sender As Object, e As EventArgs) Handles TextBoxOrderFeedback.TextChanged
        SetVarValue(Variablen.ORDER_FEEDBACK_URL, TextBoxOrderFeedback.Text)
    End Sub

    Private Sub CheckBoxPositionenBeimDruckenSortieren_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxPositionenBeimDruckenSortieren.CheckedChanged
        SetVarValue(Variablen.PRINT_SORTIERUNG_KATEGORIE, CheckBoxPositionenBeimDruckenSortieren.Checked)
    End Sub

    Private Sub CheckBoxKuecheAmStandardDrucken_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxKuecheAmStandardDrucken.CheckedChanged
        SetVarValue(Variablen.PRINT_KUECHE_AM_STANDARD, CheckBoxKuecheAmStandardDrucken.Checked)
    End Sub
End Class