Imports System.Threading
Imports System.Globalization
Imports DevExpress.LookAndFeel
Imports DD_LIB_Standards
Imports System.IO
Imports DevExpress.XtraCharts.Native
Imports DigitalData.Modules.Database

Public Class frmConfig_Basic
    Private _Helper As New ClassHelper
    Dim formloaded As Boolean = False
    Private email As New ClassEmail
    Private Sub BtnConnect_Click(sender As Object, e As EventArgs) Handles BtnConnect.Click
        Try
            Dim con As String
            If chkbxUserAut.Checked Then
                con = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";Trusted_Connection=True;Application Name=DD OrgFLOW-Client"
            Else
                con = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & Me.txtPasswort.Text & ";Application Name=DD OrgFLOW-Client"
            End If


            Dim connection As New SqlClient.SqlConnection(con) 'csb.ConnectionString)
            'während Verbindungsaufbau Sanduhr-Mauszeiger
            Cursor = Cursors.WaitCursor
            connection.Open()
            Cursor = Cursors.Default
            'DialogResult = Windows.Forms.DialogResult.OK
            Dim result As MsgBoxResult
            Dim msg = "Die Verbindung wurde erfolgreich aufgebaut!" & vbNewLine & "Möchten Sie diese Verbindung nun in der Anwendung speichern?"
            If USER_LANGUAGE <> "de-DE" Then
                msg = "Connection was successfully opened!" & vbNewLine & "Would You like to save it?"
            End If
            result = MessageBox.Show(msg, "Database-Connection", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            If result = MsgBoxResult.Yes Then
                CONNECTION_CHANGED = True
                'Set the construction string
                If rbConnDefault.Checked Then
                    MyConnectionString = con
                    MYDB_ECM = New MSSQLServer(LOGCONFIG, MyConnectionString)

                Else
                    ClassProxy.MyPROXYConnectionString = con
                    clsDatabase.Init(MyConnectionString, True)
                End If
                My.Settings.Save()

                If chkbxUserAut.Checked = False Then
                    Dim wrapper As New ClassEncryption("!35452didalog=")
                    Dim cipherText As String = wrapper.EncryptData(Me.txtPasswort.Text)
                    Dim pw As String = cipherText
                    con = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & pw & ";"
                End If
                If rbConnDefault.Checked Then
                    CONFIG.Config.ConnectionString = con
                    CONFIG.Save(ForceAll:=True)
                    ' SaveMySettingsValue("MyConnectionString", con, "ConfigMain")
                Else
                    SaveMySettingsValue("MyProxyConnectionString", con, "ConfigMain")
                End If
                Dim csb As New SqlClient.SqlConnectionStringBuilder
                csb.ConnectionString = MYDB_ECM.CurrentConnectionString
                Dim constr = connection.ConnectionString
                If chkbxUserAut.Checked = False Then
                    constr = constr.Replace(csb.Password, "XXXXX")
                End If
                Me.txtActualConnection.Text = constr
            End If
        Catch ex As Exception
            Cursor = Cursors.Default
            MsgBox("Error in Connectionbuild: " & vbNewLine & ex.Message, MsgBoxStyle.Exclamation)
        End Try
    End Sub

    Private Sub cmbDatenbank_MouseClick(sender As Object, e As MouseEventArgs) Handles cmbDatenbank.MouseClick
        Load_Databases()
    End Sub
    Sub Load_Databases()
        Try
            Me.Cursor = Cursors.WaitCursor
            Dim csb As New SqlClient.SqlConnectionStringBuilder
            csb.DataSource = Me.txtServer.Text
            csb.IntegratedSecurity = False
            csb.UserID = Me.txtUser.Text
            csb.Password = Me.txtPasswort.Text

            Dim con As String
            If chkbxUserAut.Checked Then
                con = "Data Source=" & Me.txtServer.Text & ";Trusted_Connection=True;"
            Else
                'con = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & Me.txtPasswort.Text & ";"
                con = "Server=" & Me.txtServer.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & Me.txtPasswort.Text & ";"
            End If
            Dim connection As New SqlClient.SqlConnection(con) 'csb.ConnectionString)
            connection.Open()
            Dim cmd As New SqlClient.SqlCommand("sp_databases", connection)
            cmd.CommandType = CommandType.StoredProcedure
            ' Ausführen und Ergebnis in einer ListBox anzeigen
            Dim dr As SqlClient.SqlDataReader = cmd.ExecuteReader
            If dr.HasRows Then
                cmbDatenbank.Items.Clear()
                Do While dr.Read
                    cmbDatenbank.Items.Add(dr("Database_Name"))
                Loop
                cmbDatenbank.DroppedDown = True
            Else
                MsgBox("The standard-databases could not be retrieved. The default database will be set!" & vbNewLine & "Check rights in sql-server for user: " & Me.txtUser.Text, MsgBoxStyle.Exclamation)
            End If
            connection.Close()
        Catch ex As Exception
            If ex.Message.ToLower.Contains("he standard-databases") Or ex.Message.ToLower.Contains("ie standard-datenbanken") Then
                cmbDatenbank.Text = "DD_ECM"
            End If
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Error in Load Databases:")
        End Try
        Cursor = Cursors.Default
    End Sub
    Private Sub frmConfig_Basic_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        _Helper = New ClassHelper
        If LICENSE_PROXY = True Then
            Me.rbConn_Proxy.Visible = True
        Else
            Me.rbConn_Proxy.Visible = False
        End If
        If Not MyConnectionString = String.Empty Then
            CONNECTION_CHANGED = False
            'Try
            Dim csb As New SqlClient.SqlConnectionStringBuilder
            csb.ConnectionString = MYDB_ECM.CurrentConnectionString

            Dim constr = MYDB_ECM.CurrentConnectionString
            If Not MyConnectionString.Contains("Trusted") Then
                constr = constr.Replace(csb.Password, "XXXXX")
                txtUser.Text = csb.UserID
                chkbxUserAut.Checked = False
            Else
                chkbxUserAut.Checked = True
            End If

            Try
                txtServer.Text = csb.DataSource
                cmbDatenbank.Text = csb.InitialCatalog
            Catch ex As Exception

            End Try

            Me.txtActualConnection.Text = constr
            chkLogErrorsOnly.Checked = DEBUG
            'txtwdSearch_Count.Text = WDResultListCount.ToString
            txtTask_Popup.Text = Task_Popup_minutes.ToString


            Dim sql As String = "SELECT 0,'' UNION ALL SELECT T.GUID, T.FORM_TITLE FROM TBPMO_FORM_CONSTRUCTOR T"
            Dim DT As DataTable = MYDB_ECM.GetDatatable(sql)
            If DT.Rows.Count > 0 Then
                cmbConstructor.Enabled = True
                cmbConstructor.DataSource = DT
                cmbConstructor.DisplayMember = DT.Columns(1).ColumnName
                cmbConstructor.ValueMember = DT.Columns(0).ColumnName
                If Sett_ConstructorStart <> 0 Then
                    cmbConstructor.SelectedValue = Sett_ConstructorStart
                End If

            Else
                cmbConstructor.Enabled = False
            End If

            cmbDesign.Text = MyFormsDesign

            'Catch ex As Exception
            '    MsgBox("Fehler in FormLoad: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
            'End Try



        End If
    End Sub
    Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        ' Specify that the link was visited.
        Me.LinkLabel1.LinkVisited = True
        ' Navigate to a URL.
        System.Diagnostics.Process.Start("http://www.didalog.de/Support")
    End Sub

    Private Sub btnApplicationFolder_Click(sender As Object, e As EventArgs) Handles btnApplicationFolder.Click
        Process.Start(Application.UserAppDataPath())
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Process.Start(LOGCONFIG.LogDirectory)

    End Sub

    Private Sub chkLogErrorsOnly_CheckedChanged(sender As Object, e As EventArgs) Handles chkLogErrorsOnly.CheckedChanged
        DEBUG = chkLogErrorsOnly.Checked
        SaveMySettingsValue("LogErrorsOnly", DEBUG, "ConfigMain")
        clsCURRENT.LOG_ERRORS_ONLY = DEBUG
        LOGCONFIG.Debug = DEBUG

    End Sub
    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
        My.Settings.Save()
    End Sub

    Private Sub cmbConstructor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbConstructor.SelectedIndexChanged
        If cmbConstructor.SelectedIndex <> -1 And formloaded = True Then
            If Sett_ConstructorStart <> cmbConstructor.SelectedValue Then
                Sett_ConstructorStart = cmbConstructor.SelectedValue
                SaveMySettingsValue("Sett_ConstructorStart", Sett_ConstructorStart, "ConfigMain")
            End If

        End If
    End Sub

    Private Sub frmConfig_Basic_Shown(sender As Object, e As EventArgs) Handles Me.Shown
        formloaded = True
    End Sub

    Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabControl1.SelectedIndexChanged
        Select Case TabControl1.SelectedIndex
            Case 1
                cmbLanguage.SelectedIndex = cmbLanguage.FindStringExact(USER_LANGUAGE)
            Case 2
                Dim DTSCAN_folderwatch As DataTable = MYDB_ECM.GetDatatable("SELECT FOLDER_PATH,SUBDIRECTORIES FROM TBPMO_FOLDERWATCH_USER WHERE FOLDER_TYPE = 'SCAN' AND USER_ID = " & USER_GUID)
                If Not DTSCAN_folderwatch Is Nothing Then
                    If DTSCAN_folderwatch.Rows.Count = 1 Then
                        CURRENT_SCAN_FOLDERWATCH = DTSCAN_folderwatch.Rows(0).Item(0)
                        CURRENT_SCAN_FOLDERWATCH_SD = DTSCAN_folderwatch.Rows(0).Item(1)
                    End If

                End If
                Me.txtScanFolderWatch.Text = CURRENT_SCAN_FOLDERWATCH

                If Not ClassFolderWatcher.FolderWatcher_SCAN Is Nothing Then
                    If ClassFolderWatcher.FolderWatcher_SCAN.EnableRaisingEvents = True Then
                        'If USER_LANGUAGE = "de-DE" Then
                        btnstartstop2.Text = "Überwachung stoppen"
                        'Else
                        '    btnstartstop2.Text = "Stop hotfolder"
                        'End If

                        btnstartstop2.Image = My.Resources.bell_delete
                    Else
                        ' If USER_LANGUAGE = "de-DE" Then
                        btnstartstop2.Text = "Überwachung starten"
                        'Else
                        'btnstartstop2.Text = "Stop hotfolder"
                        'End If

                        btnstartstop2.Image = My.Resources.bell_go
                    End If
                Else
                    ' If USER_LANGUAGE = "de-DE" Then
                    btnstartstop2.Text = "Überwachung starten"
                    'Else
                    '   btnstartstop2.Text = "Stop hotfolder"
                    'End If

                    btnstartstop2.Image = My.Resources.bell_go
                End If
                Me.DataGridView1.DataSource = DTEXCLUDE_FILES

        End Select
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim fbdialog As New FolderBrowserDialog
        If txtScanFolderWatch.Text <> "" Then
            fbdialog.SelectedPath = txtScanFolderWatch.Text
        End If
        If fbdialog.ShowDialog() = DialogResult.OK Then
            CheckScanFolder(fbdialog.SelectedPath, chkSubfolder.Checked)
        End If
    End Sub
    Sub CheckScanFolder(mypath As String, SUBDIRECTORIES As Boolean)
        Try
            If mypath <> "" Then
                Try
                    If (Not System.IO.Directory.Exists(mypath)) Then
                        System.IO.Directory.CreateDirectory(mypath)
                    End If
                Catch ex As Exception
                    LOGGER.Warn("Fehler beim Erstellen des Folderwatchordners: " & mypath)
                    LOGGER.Warn("" & ex.Message)
                    MsgBox("Error in creating Hotfolder: " & mypath & vbNewLine & "Please check the rights!" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
                    Exit Sub
                End Try
            End If

            Dim _SUBDIRECTORIES
            If SUBDIRECTORIES = False Then
                _SUBDIRECTORIES = 0
            Else
                _SUBDIRECTORIES = 1
            End If

            Dim folderwatch = MYDB_ECM.GetScalarValue("SELECT GUID FROM TBPMO_FOLDERWATCH_USER WHERE USER_ID = " & USER_GUID & " AND FOLDER_TYPE = 'SCAN'")
            Dim sql As String
            If folderwatch Is Nothing And mypath <> "" Then
                sql = "INSERT INTO TBPMO_FOLDERWATCH_USER (USER_ID, FOLDER_PATH, FOLDER_TYPE,SUBDIRECTORIES, ADDED_WHO) VALUES (" & USER_GUID & ",'" & mypath & "','SCAN', " & _SUBDIRECTORIES & ",'" & USER_USERNAME & "')"
            Else
                sql = "UPDATE TBPMO_FOLDERWATCH_USER SET FOLDER_PATH = '" & mypath & "', SUBDIRECTORIES = " & _SUBDIRECTORIES & ", CHANGED_WHO = '" & USER_USERNAME & "' where GUID = " & folderwatch
            End If
            If MYDB_ECM.ExecuteNonQuery(sql) Then
                Dim DT As DataTable = MYDB_ECM.GetDatatable("SELECT FOLDER_PATH, SUBDIRECTORIES FROM TBPMO_FOLDERWATCH_USER WHERE USER_ID = " & USER_GUID & " AND FOLDER_TYPE = 'SCAN'")

                CURRENT_SCAN_FOLDERWATCH = DT.Rows(0).Item(0)
                CURRENT_SCAN_FOLDERWATCH_SD = DT.Rows(0).Item(1)
                Me.txtScanFolderWatch.Text = CURRENT_SCAN_FOLDERWATCH
                Me.chkSubfolder.Checked = CURRENT_SCAN_FOLDERWATCH_SD
            End If
            If FWSCAN_started = True Then
                ClassFolderWatcher.Restart_FolderWatchSCAN()
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Error in CheckFolder:")
        End Try

    End Sub

    Private Sub btnSaveExclusionFiles_Click(sender As Object, e As EventArgs) Handles btnSaveExclusionFiles.Click
        Try
            DTEXCLUDE_FILES.AcceptChanges()
            DTEXCLUDE_FILES.WriteXml(PATH_FileExclusions)
            MsgBox("Changes saved.", MsgBoxStyle.Information)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Error in Saving Exclusion files:")
        End Try

    End Sub

    Private Sub btnstartstop2_Click(sender As Object, e As EventArgs) Handles btnstartstop2.Click
        If CURRENT_SCAN_FOLDERWATCH <> "" Then
            ClassFolderWatcher.DELETE_SCAN_File_User()
            CheckScanFolder(CURRENT_SCAN_FOLDERWATCH, chkSubfolder.Checked)
            CheckFWSCAN_State()
        End If
    End Sub
    Sub CheckFWSCAN_State()
        Select Case ClassFolderWatcher.StartStop_FolderWatchSCAN()
            Case 1
                'If USER_LANGUAGE = "de-DE" Then
                btnstartstop2.Text = "Überwachung stoppen"
                ' Else
                'btnstartstop2.Text = "Stop Hotfolder"
                ' End If
                btnstartstop2.Image = My.Resources.bell_delete
            Case 0
                ' If USER_LANGUAGE = "de-DE" Then
                btnstartstop2.Text = "Überwachung starten"
                'Else
                ' btnstartstop2.Text = "Start Hotfolder"
                'End If
                btnstartstop2.Image = My.Resources.bell_go
        End Select
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim result As MsgBoxResult
        If USER_LANGUAGE = "de-DE" Then
            result = MessageBox.Show("Wollen Sie die Applikationssprache nun auf '" & cmbLanguage.Text & "' ändern?", "Bestätigung erforderlich:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        Else
            result = MessageBox.Show("Would You like to change Your application language to '" & cmbLanguage.Text & "' ?", "Confirmation required:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        End If

        If result = MsgBoxResult.Yes Then
            formloaded = False
            Try
                Dim update As String = "UPDATE TBDD_USER SET [LANGUAGE] = '" & cmbLanguage.Text & "' WHERE GUID = " & USER_GUID
                USER_LANGUAGE = cmbLanguage.Text

                If MYDB_ECM.ExecuteNonQuery(update) = True Then
                    If USER_LANGUAGE = "de-DE" Then
                        MsgBox("Die Sprache wurde erfolgreich geändert und nach einem Neustart angewendet!", MsgBoxStyle.Information)
                    Else
                        MsgBox("The language was changed successfully and will be set after App-Restart", MsgBoxStyle.Information)
                    End If
                    LANGUAGE_CHANGED = True
                End If
            Catch ex As Exception

            End Try
            formloaded = True
        End If
    End Sub
    Private Sub chkbxUserAut_CheckedChanged(sender As Object, e As EventArgs) Handles chkbxUserAut.CheckedChanged
        If chkbxUserAut.Checked Then
            Me.txtPasswort.Enabled = False
            Me.txtUser.Enabled = False
        Else
            Me.txtPasswort.Enabled = True
            Me.txtUser.Enabled = True
        End If
    End Sub

    Private Sub txtActualConnection_TextChanged(sender As Object, e As EventArgs) Handles txtActualConnection.TextChanged

    End Sub

    Private Sub cmbDatenbank_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbDatenbank.SelectedIndexChanged

    End Sub

    Private Sub txtPasswort_Leave(sender As Object, e As EventArgs) Handles txtPasswort.Leave

    End Sub

    Private Sub txtTask_Popup_TextChanged(sender As Object, e As EventArgs) Handles txtTask_Popup.TextChanged
        Try
            If IsNumeric(txtTask_Popup.Text) Then
                Task_Popup_minutes = txtTask_Popup.Text
                SaveMySettingsValue("Task_Popup_minutes", txtTask_Popup.Text, "ConfigMain")
            End If
        Catch ex As Exception

        End Try



    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        If email.Send_Log_Mail("<b> Log-/SupportMail Org-Flow.</b> <p>",
                             "Support-Mail OrgFlow", "support@didalog.de", "mail.triplew.de", "support@didalog.de", "ddemail40", "support-flow@digitaldata.works") = True Then
            MsgBox("Log Mail was sent to Digital Data!", MsgBoxStyle.Information, "Success!")
        End If
    End Sub

    Private Sub txtScanFolderWatch_TextChanged(sender As Object, e As EventArgs) Handles txtScanFolderWatch.TextChanged
        CheckScanFolder(txtScanFolderWatch.Text, chkSubfolder.Checked)
    End Sub

    Private Sub chkSubfolder_CheckedChanged(sender As Object, e As EventArgs) Handles chkSubfolder.CheckedChanged
        CheckScanFolder(txtScanFolderWatch.Text, chkSubfolder.Checked)
    End Sub

    Private Sub txtPasswort_TextChanged(sender As Object, e As EventArgs) Handles txtPasswort.TextChanged

    End Sub

    Private Sub rbConn_Proxy_CheckedChanged(sender As Object, e As EventArgs) Handles rbConn_Proxy.CheckedChanged
        If rbConn_Proxy.Checked Then
            Display_Proxy_String()
            Me.lblLinkedServer.Visible = True
            Me.txtLinkedServer.Visible = True
            txtLinkedServer.Text = ClassProxy.MyLinkedServer
        Else
            Me.lblLinkedServer.Visible = False
            Me.txtLinkedServer.Visible = False
        End If
    End Sub
    Sub Display_Proxy_String()
        If clsDatabase.DB_PROXY_INITIALIZED And ClassProxy.MyPROXYConnectionString <> String.Empty Then
            Dim csb As New SqlClient.SqlConnectionStringBuilder
            csb.ConnectionString = ClassProxy.MyPROXYConnectionString

            Dim constr = ClassProxy.MyPROXYConnectionString
            If Not constr.Contains("Trusted") Then
                constr = constr.Replace(csb.Password, "XXXXX")
                txtUser.Text = csb.UserID
                chkbxUserAut.Checked = False
            Else
                chkbxUserAut.Checked = True
            End If

            Try
                txtServer.Text = csb.DataSource
                cmbDatenbank.Text = csb.InitialCatalog
            Catch ex As Exception

            End Try

            Me.txtActualConnection.Text = constr
            btndeleteProxy.Visible = True
        Else
            Me.txtActualConnection.Text = ""
            btndeleteProxy.Visible = False
        End If
    End Sub
    Private Sub rbConnDefault_CheckedChanged(sender As Object, e As EventArgs) Handles rbConnDefault.CheckedChanged
        If rbConnDefault.Checked Then
            If MyConnectionString <> String.Empty Then
                Dim csb As New SqlClient.SqlConnectionStringBuilder
                csb.ConnectionString = MYDB_ECM.CurrentConnectionString

                Dim constr = MYDB_ECM.CurrentConnectionString
                If Not constr.Contains("Trusted") Then
                    constr = constr.Replace(csb.Password, "XXXXX")
                    txtUser.Text = csb.UserID
                    chkbxUserAut.Checked = False
                Else
                    chkbxUserAut.Checked = True
                End If

                Try
                    txtServer.Text = csb.DataSource
                    cmbDatenbank.Text = csb.InitialCatalog
                Catch ex As Exception

                End Try

                Me.txtActualConnection.Text = constr
            End If
        End If
    End Sub

    Private Sub btndeleteProxy_Click(sender As Object, e As EventArgs) Handles btndeleteProxy.Click
        SaveMySettingsValue("MyProxyConnectionString", "", "ConfigMain")
        ClassProxy.MyPROXYConnectionString = ""
        clsDatabase.DB_PROXY_INITIALIZED = False
        Me.txtActualConnection.Text = ""
        CONNECTION_CHANGED = True
    End Sub

    Private Sub txtLinkedServer_Leave(sender As Object, e As EventArgs) Handles txtLinkedServer.Leave
        SaveMySettingsValue("MyLinkedServer", txtLinkedServer.Text, "ConfigMain")
        ClassProxy.MyLinkedServer = txtLinkedServer.Text
    End Sub

    Private Sub btncheckWDFolderexists_Click(sender As Object, e As EventArgs) Handles btncheckWDFolderexists.Click
        If txtwdFolder.Text <> String.Empty And clsWindream.SESSION_CREATED = True Then
            Dim folderpath = _Helper.FORMAT_WM_PATH(txtwdFolder.Text)

            If clsWD_GET.WD_PATH_EXISTS(folderpath) Then
                MsgBox("Folder exists in windream!")
            Else
                MsgBox("Folder is not existing in windream!", MsgBoxStyle.Critical)
            End If
        End If
    End Sub

    Private Sub btnTest_Anmeldung_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        If cmbDesign.SelectedIndex <> -1 Then
            UserLookAndFeel.Default.SetSkinStyle(cmbDesign.Text)
            SaveMySettingsValue("MyFormsDesign", cmbDesign.Text, "ConfigMain")
        End If

    End Sub

    Private Sub cmbLanguage_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbLanguage.SelectedIndexChanged

    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        Dim exists
        If rbUser.Checked Then
            exists = clsWD_GET.WM_USER_EXISTS(txtObjectExists.Text)
        ElseIf rbGruppe.Checked Then
            exists = clsWD_GET.WM_GROUP_EXISTS(txtObjectExists.Text)
        End If
        If exists = True Then
            MsgBox("Object exists in windream!")
        Else
            MsgBox("Object is not existing in windream!", MsgBoxStyle.Critical)
        End If
    End Sub

    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        Dim group
        If rbGruppe.Checked Then
            group = clsWD_GET.GET_WM_GROUP_OBJECT(txtObjectExists.Text)
            If Not IsNothing(group) Then
                MsgBox("GROUP.NAME: " & group.aname)
            End If
        End If
    End Sub

    Private Sub CheckBoxGridDocResult_BestFitColumns_CheckedChanged(sender As Object, e As EventArgs)
        If formloaded = False Then Exit Sub
        GridDocResult_BestFitColumns = chkLogErrorsOnly.Checked
        SaveMySettingsValue("GridDocResult_BestFitColumns", GridDocResult_BestFitColumns, "ConfigMain")
    End Sub

    Private Sub frmConfig_Basic_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        My.Settings.Save()
    End Sub
End Class