Public Class frmNamenkonvention
    Dim FILE_DELIMITER As String
    Dim VERSION_DELIMITER As String
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnAddIndexM.Click
        If Not Me.cmbIndex_m.Text = "" Then
            'AREANLAGE-[%mARENR]-[%aKurzname]-I[%Version]
            Dim text As String = "[%m" & Me.cmbIndex_m.Text.ToString.ToUpper & "]"
            Dim altePosition As Integer = Me.txtnamenKonv.SelectionStart()
            Me.txtnamenKonv.Text = Me.txtnamenKonv.Text.Insert(altePosition, text)
            Me.txtnamenKonv.SelectionStart = altePosition + text.Length
        End If
    End Sub

    Private Sub btnAddIndexA_Click(sender As Object, e As EventArgs) Handles btnAddIndexA.Click
        If Not Me.cmbIndex_A.Text = "" Then
            'AREANLAGE-[%mARENR]-[%aKurzname]-I[%Version]
            Dim text As String = "[%a" & Me.cmbIndex_A.Text.ToString.ToUpper & "]"
            Dim altePosition As Integer = Me.txtnamenKonv.SelectionStart()
            Me.txtnamenKonv.Text = Me.txtnamenKonv.Text.Insert(altePosition, text)
            Me.txtnamenKonv.SelectionStart = altePosition + text.Length
        End If
    End Sub

    Private Sub frmNamenkonvention_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing

    End Sub

    Private Sub frmNamenkonvention_Load(sender As Object, e As EventArgs) Handles Me.Load
        Try
            Dim sql As String = "select VERSION_DELIMITER, FILE_DELIMITER FROM TBDD_MODULES WHERE GUID = 1"
            Dim DT As DataTable = DATABASE_ECM.GetDatatable(sql)
            For Each row As DataRow In DT.Rows
                FILE_DELIMITER = row.Item("FILE_DELIMITER")
                VERSION_DELIMITER = row.Item("VERSION_DELIMITER")
            Next
            TBDD_INDEX_MANTableAdapter.Connection.ConnectionString = MyConnectionString
            Me.TBDD_INDEX_MANTableAdapter.Fill(Me.MyDataset.TBDD_INDEX_MAN, frmAdministration._aktDokart_Id)
            Me.TBDD_INDEX_AUTOMTableAdapter.Connection.ConnectionString = MyConnectionString
            Me.TBDD_INDEX_AUTOMTableAdapter.Fill(Me.MyDataset.TBDD_INDEX_AUTOM, frmAdministration._aktDokart_Id)
            txtnamenKonv.Text = frmAdministration._Namenkonvention
        Catch ex As Exception
            MsgBox("Unexpected error inm Laden der Grunddaten zur Dokumentart: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub

    Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click

    End Sub

    Private Sub btnVersion_Click(sender As Object, e As EventArgs)
        If txtnamenKonv.Text.Contains("[%Version]") Then
            If USER_LANGUAGE = "de-DE" Then
                MsgBox("Versionstag ist bereits enthalten!", MsgBoxStyle.Exclamation)
            Else
                MsgBox("Versiontag already added!", MsgBoxStyle.Exclamation)
            End If
            Exit Sub
        End If
        Dim text As String = "[%Version]"
        Dim altePosition As Integer = Me.txtnamenKonv.SelectionStart()
        Me.txtnamenKonv.Text = Me.txtnamenKonv.Text.Insert(altePosition, text)
        Me.txtnamenKonv.SelectionStart = altePosition + text.Length
    End Sub

    Private Sub btndelete_Click(sender As Object, e As EventArgs) Handles btndelete.Click
        txtnamenKonv.Text = ""
    End Sub

    Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
        frmAdministration._Namenkonvention = txtnamenKonv.Text
        Me.Close()
    End Sub

    Private Sub btnclose_Click(sender As Object, e As EventArgs) Handles btnclose.Click
        Me.Close()
    End Sub

    Private Sub btnTrennzeichen_Click(sender As Object, e As EventArgs) Handles btnTrennzeichen.Click
        Dim altePosition As Integer = Me.txtnamenKonv.SelectionStart()
        Me.txtnamenKonv.Text = Me.txtnamenKonv.Text.Insert(altePosition, FILE_DELIMITER)
        Me.txtnamenKonv.SelectionStart = altePosition + FILE_DELIMITER.Length
    End Sub

    Private Sub btnVersionTZ_Click(sender As Object, e As EventArgs) Handles btnVersionTZ.Click

        Dim altePosition As Integer = Me.txtnamenKonv.SelectionStart()
        Me.txtnamenKonv.Text = Me.txtnamenKonv.Text.Insert(altePosition, VERSION_DELIMITER)
        Me.txtnamenKonv.SelectionStart = altePosition + VERSION_DELIMITER.Length
    End Sub

    Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles btnAddDate.Click
        If Not Me.cmbDate.Text = "" Then
            'AREANLAGE-[%mARENR]-[%aKurzname]-I[%Version]
            Dim text As String = "[%v" & Me.cmbDate.Text.ToString.ToUpper & "]"
            Dim altePosition As Integer = Me.txtnamenKonv.SelectionStart()
            Me.txtnamenKonv.Text = Me.txtnamenKonv.Text.Insert(altePosition, text)
            Me.txtnamenKonv.SelectionStart = altePosition + text.Length
        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        If Not txtnamenKonv.Text.Contains("[%vOFilename]") Then
            Dim text As String = "[%vOFilename]"
            Dim altePosition As Integer = Me.txtnamenKonv.SelectionStart()
            Me.txtnamenKonv.Text = Me.txtnamenKonv.Text.Insert(altePosition, text)
            Me.txtnamenKonv.SelectionStart = altePosition + text.Length
        End If
    End Sub

    Private Sub btnAddDivers_Click(sender As Object, e As EventArgs) Handles btnAddDivers.Click
        If Not Me.cmbdivers.Text = "" Then
            'AREANLAGE-[%mARENR]-[%aKurzname]-I[%Version]
            Dim text As String = "[%v" & Me.cmbdivers.Text.ToString.ToUpper & "]"
            Dim altePosition As Integer = Me.txtnamenKonv.SelectionStart()
            Me.txtnamenKonv.Text = Me.txtnamenKonv.Text.Insert(altePosition, text)
            Me.txtnamenKonv.SelectionStart = altePosition + text.Length
        End If
    End Sub
End Class