Imports DocumentFormat.OpenXml.Wordprocessing

Public Class frmDatenarchivarchiv


    Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            If txtMax._value = "" Then Me.Cursor = Cursors.Default : Exit Sub
            If Not IsNumeric(txtMax._value) Then Me.Cursor = Cursors.Default : Exit Sub
            If Not IsDate(txtVon._value) Then Me.Cursor = Cursors.Default : Exit Sub
            If Not IsDate(txtBis._value) Then Me.Cursor = Cursors.Default : Exit Sub
            If txtKategorie.Text Is String.Empty Then Me.Cursor = Cursors.Default : Exit Sub
            If txtOrdner.Text Is String.Empty Then Me.Cursor = Cursors.Default : Exit Sub

            Dim DT = SQL.loadDgvBySql(" SELECT TOP (" & txtMax._value & ") [da_id]  FROM [tblDatenarchiv] inner join tblDatenarchiv_Collection on da_id=coll_daId
                            where da_vorlage=0 and coll_date BETWEEN '" & txtVon._value & "' and '" & txtBis._value & "' and coll_pfad NOT LIKE '%\\stor01.verag.ost.dmn\DatenArchivArchiv%' and coll_pfad NOT LIKE '\\DELETED\%'
		                        AND da_kategorie='" & txtKategorie.Text & "' and da_ordner='" & txtOrdner.Text & "'
                         and da_id>=392150   group by [da_id] order by  [da_id] ", "FMZOLL")

            If DT Is Nothing Then Me.Cursor = Cursors.Default : Exit Sub
            If DT.Rows.Count = 0 Then Me.Cursor = Cursors.Default : Exit Sub

            If vbYes = MsgBox("Es werden '" & DT.Rows.Count & "' Einträge verschoben - fortfahren?", vbYesNoCancel) Then

                ProgressBar1.Minimum = 1
                ProgressBar1.Maximum = DT.Rows.Count
                ProgressBar1.Step = 1
                ProgressBar1.Value = 1

                For Each ROW In DT.Rows
                    'Dim DS = New VERAG_PROG_ALLGEMEIN.cDATENSERVER(txtKategorie._value, txtOrdner._value, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, txtMax._value)

                    Dim DS = New VERAG_PROG_ALLGEMEIN.cDATENSERVER(ROW("da_id"))
                    If DS.DATA_LIST.LIST.Count > 0 Then
                        DS.moveTo_ARCHIVARCHIV()
                    End If
                    ProgressBar1.PerformStep()

                    Label1.Text = ProgressBar1.Value & "/" & DT.Rows.Count

                    If DT.Rows.Count < 100 Then
                        Me.Refresh()
                    Else
                        If ProgressBar1.Value Mod 20 = 0 Then
                            Me.Refresh()
                        End If
                    End If
                Next

            End If

        Catch ex As Exception
            VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name)
        End Try
        Me.Cursor = Cursors.Default
    End Sub
End Class