Imports System.ComponentModel

Public Class frmIndexFileList

    Private Sub frmIndexFileList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            Me.TBGI_FILES_USERTableAdapter.Connection.ConnectionString = MyConnectionString
            'TODO: Diese Codezeile lädt Daten in die Tabelle "MyDataset1.TBGI_FILES_USER". Sie können sie bei Bedarf verschieben oder entfernen.
            Me.TBGI_FILES_USERTableAdapter.Fill(Me.MyDataset1.TBGI_FILES_USER, Environment.UserName)
            If MyDataset1.TBGI_FILES_USER.Rows.Count > 0 Then
                CheckedListBoxControl1.DataSource = MyDataset1.TBGI_FILES_USER
                CheckedListBoxControl1.DisplayMember = MyDataset1.TBGI_FILES_USER.Columns("FILENAME_ONLY").ColumnName
                CheckedListBoxControl1.ValueMember = MyDataset1.TBGI_FILES_USER.Columns(0).ColumnName

            End If

        Catch ex As Exception
            MsgBox("Error in Load Form: " & ex.Message, MsgBoxStyle.Critical)
        End Try

    End Sub

    Private Sub btnstartIndex_Click(sender As Object, e As EventArgs) Handles btnstartIndex.Click
        Try
            For Each item In CheckedListBoxControl1.CheckedItems
                Dim row As DataRowView = CType(item, DataRowView)
                Dim _file = row.Item(1)
                Dim handletype As String = row.Item("HANDLE_TYPE")

                If handletype = "|MSGONLY|" Or handletype = "|ATTMNTEXTRACTED|" Then
                    Try
                        IO.File.Delete(_file)
                    Catch ex As Exception

                    End Try

                End If
                'System.IO.File.Delete(filestring)
                ClassDatabase.Execute_non_Query("DELETE FROM TBGI_FILES_USER WHERE GUID = " & row.Item(0), True)
            Next
        Catch ex As Exception
            MsgBox("Unexpected Error in Clear Multiple Documents: " & ex.Message, MsgBoxStyle.Critical)
        End Try

        Me.Close()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        CheckedListBoxControl1.CheckAll()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        CheckedListBoxControl1.UnCheckAll()
    End Sub

    Private Sub frmIndexFileList_Shown(sender As Object, e As EventArgs) Handles Me.Shown
        Me.BringToFront()
        CheckedListBoxControl1.Focus()
    End Sub

    Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
        ClassDatabase.Execute_non_Query("DELETE FROM TBGI_FILES_USER WHERE UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')", True)
        Close()
    End Sub
End Class