Public Class frmWD_Resultlist_Config

    'Private Class ResultListType
    '    Public Property Name As String
    '    Public Property Id As Integer

    '    Public Sub New(Id As Integer, Name As String)
    '        Me.Name = Name
    '        Me.Id = Id
    '    End Sub
    'End Class

    Private Sub frmWD_Resultlist_Config_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: Diese Codezeile lädt Daten in die Tabelle "DD_ECMAdmin.TBPMO_DOCSEARCH_RESULTLIST_CONFIG_TYPE_ID". Sie können sie bei Bedarf verschieben oder entfernen.

        Try
            Me.TBPMO_DOCSEARCH_RESULTLIST_CONFIG_TYPE_IDTableAdapter.Connection.ConnectionString = MyConnectionString
            Me.TBPMO_DOCSEARCH_RESULTLIST_CONFIG_TYPE_IDTableAdapter.Fill(Me.DD_ECMAdmin.TBPMO_DOCSEARCH_RESULTLIST_CONFIG_TYPE_ID)
            Me.TBPMO_DOCSEARCH_RESULTLIST_CONFIGTableAdapter.Connection.ConnectionString = MyConnectionString
            Me.TBPMO_DOCSEARCH_RESULTLIST_CONFIGTableAdapter.Fill(Me.DD_ECMAdmin.TBPMO_DOCSEARCH_RESULTLIST_CONFIG)
            Me.TBWH_ENTITYTableAdapter.Connection.ConnectionString = MyConnectionString
            Me.TBWH_ENTITYTableAdapter.Fill(Me.DD_DMSDataSet.TBWH_ENTITY, USER_LANGUAGE)

            'Dim ResultListTypes As New List(Of ResultListType)
            'ResultListTypes.Add(New ResultListType(1, "TextBox"))
            'ResultListTypes.Add(New ResultListType(2, "CheckBox"))
            'ResultListTypes.Add(New ResultListType(3, "DatePicker"))
            'ResultListTypes.Add(New ResultListType(4, "DropDown"))

            ' Gruppierung nach Entität und dann nach Sprache
            grvwMain.Columns.Item("NAME").GroupIndex = 0
            grvwMain.Columns.Item("LANGUAGE").GroupIndex = 1
            ' Unwichtige Spalten ausblenden
            grvwMain.Columns.Item("GUID").Visible = False
            grvwMain.Columns.Item("ADDED_WHO").Visible = False
            grvwMain.Columns.Item("ADDED_WHEN").Visible = False
            grvwMain.Columns.Item("CHANGED_WHO").Visible = False
            grvwMain.Columns.Item("CHANGED_WHEN").Visible = False
        Catch ex As System.Exception
            MsgBox("Error while loading TBPMO_DOCSEARCH_RESULTLIST_CONFIG:" & vbNewLine & ex.Message)
        End Try
    End Sub

    Private Sub TBPMO_DOCSEARCH_RESULTLIST_CONFIGBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles TBPMO_DOCSEARCH_RESULTLIST_CONFIGBindingNavigatorSaveItem.Click
        Try
            Me.Validate()
            Me.TBPMO_DOCSEARCH_RESULTLIST_CONFIGBindingSource.EndEdit()

            If DD_ECMAdmin.TBPMO_DOCSEARCH_RESULTLIST_CONFIG.GetChanges() IsNot Nothing Then
                Me.CHANGED_WHOTextBox.Text = USER_USERNAME
                Me.TBPMO_DOCSEARCH_RESULTLIST_CONFIGBindingSource.EndEdit()
                Me.TBPMO_DOCSEARCH_RESULTLIST_CONFIGTableAdapter.Update(Me.DD_ECMAdmin.TBPMO_DOCSEARCH_RESULTLIST_CONFIG)
                labelSuccess.Visible = True
            Else
                MsgBox("No changes")
                labelSuccess.Visible = False
            End If
        Catch ex As Exception
            MsgBox("Error while saving TBPMO_DOCSEARCH_RESULTLIST_CONFIG:" & vbNewLine & ex.Message)
        End Try
    End Sub

    Private Sub TBPMO_DOCSEARCH_RESULTLIST_CONFIGBindingSource_AddingNew(sender As Object, e As System.ComponentModel.AddingNewEventArgs) Handles TBPMO_DOCSEARCH_RESULTLIST_CONFIGBindingSource.AddingNew
        DD_ECMAdmin.TBPMO_DOCSEARCH_RESULTLIST_CONFIG.ADDED_WHOColumn.DefaultValue = USER_USERNAME
    End Sub

    Private Sub grvwMain_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles grvwMain.FocusedRowChanged
        labelSuccess.Visible = False
    End Sub

    Private Sub grvwMain_CustomUnboundColumnData(sender As Object, e As DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs) Handles grvwMain.CustomUnboundColumnData
        If e.IsGetData Then
            Dim row As DataRowView = e.Row
            Dim entityId = row.Item("ENTITY_ID")
            Dim entityRow As DataRow = DD_DMSDataSet.TBWH_ENTITY.Select("FORM_ID = " & entityId).First()
            If Not IsNothing(entityRow.Item("FORM_TITLE")) Then
                e.Value = entityRow.Item("FORM_TITLE").ToString()
            End If
        End If
    End Sub
End Class