Public Class frmObjecttypeConfig
    Private Shared _Instance As frmObjecttypeConfig = Nothing
    
    Public Shared Function Instance() As frmObjecttypeConfig
        If _Instance Is Nothing OrElse _Instance.IsDisposed = True Then
            _Instance = New frmObjecttypeConfig
        End If
        _Instance.BringToFront()
        Return _Instance
    End Function
    Private Sub TBPMO_WD_OBJECTTYPEBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles TBPMO_WD_OBJECTTYPEBindingNavigatorSaveItem.Click
       Save_ObjecttypeKonfig
    End Sub
    Sub Save_ObjecttypeKonfig()
        Try
            Me.TBPMO_WD_OBJECTTYPEBindingSource.EndEdit()
            If DD_DMSDataSet.TBPMO_WD_OBJECTTYPE.GetChanges Is Nothing = False Then
                Me.CHANGED_WHOTextBox.Text = Environment.UserName
                Me.TBPMO_WD_OBJECTTYPEBindingSource.EndEdit()
                Me.TBPMO_WD_OBJECTTYPETableAdapter.Update(Me.DD_DMSDataSet.TBPMO_WD_OBJECTTYPE)
                Me.lblSaveDokart.Visible = True
            Else
                Me.lblSaveDokart.Visible = False
            End If
        Catch ex As Exception
            MsgBox("Error in Save Objecttype-Config:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub
    Private Sub frmObjecttypeConfig_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: Diese Codezeile lädt Daten in die Tabelle "DD_DMSDataSet.TBPMO_WD_OBJECTTYPE". Sie können sie bei Bedarf verschieben oder entfernen.
        Try

            TBPMO_WD_OBJECTTYPETableAdapter.Connection.ConnectionString = MyConnectionString
            Me.TBPMO_WD_OBJECTTYPETableAdapter.Fill(Me.DD_DMSDataSet.TBPMO_WD_OBJECTTYPE)
            ClassWindream.Init()
        Catch ex As Exception
            MsgBox("Error loading Form:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try
     
    End Sub
    Private Sub ObjektTypenEintragen()
        Try
            Dim oDokumentTyp As WINDREAMLib.WMObject
            ' Combobox leeren
            Me.OBJECT_TYPEComboBox.Items.Clear()
            ' alle Objekttypen durchlaufen
            For Each oDokumentTyp In ClassWindream.GetObjecttypesAsObjects
                ' und in die Combobox eintragen
                Me.OBJECT_TYPEComboBox.Items.Add(oDokumentTyp.aName)
            Next
        Catch ex As Exception
            MsgBox("Fehlernachricht:" & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Fehler beim Eintragen der Objekttypen")
        End Try

    End Sub

    Private Sub OBJECT_TYPEComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles OBJECT_TYPEComboBox.SelectedIndexChanged
       load_Indices
    End Sub
    Sub load_Indices()
        Try
            If Me.OBJECT_TYPEComboBox.SelectedIndex <> -1 Then
                Me.IDXNAME_ENTITYIDComboBox.Items.Clear()
                Me.IDXNAME_PARENTIDComboBox.Items.Clear()
                Dim indexe = ClassWindream.GetIndicesByObjecttype(OBJECT_TYPEComboBox.Text)
                If indexe IsNot Nothing Then
                    For Each index As String In indexe
                        Me.IDXNAME_ENTITYIDComboBox.Items.Add(index)
                        Me.IDXNAME_PARENTIDComboBox.Items.Add(index)
                    Next
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Fehler bei OBJECT_TYPEComboBox.SelectedIndexChanged: ")
        End Try
    End Sub

    Private Sub TBPMO_WD_OBJECTTYPEBindingSource_AddingNew(sender As Object, e As System.ComponentModel.AddingNewEventArgs) Handles TBPMO_WD_OBJECTTYPEBindingSource.AddingNew
        Try
            Me.DD_DMSDataSet.TBPMO_WD_OBJECTTYPE.ADDED_WHOColumn.DefaultValue = Environment.UserName
        Catch ex As Exception
            MsgBox("Error in Save Objecttype-Config:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try

    End Sub

    Private Sub frmObjecttypeConfig_Shown(sender As Object, e As EventArgs) Handles Me.Shown
        ObjektTypenEintragen()
    End Sub
End Class