Public Class frmTask_Overview

    Public Sub Refresh()
        Try
            Dim DTACTIVE As DataTable = ClassDatabase.Return_Datatable("SELECT * FROM VWPMO_WF_OVERVIEW_AUTHORITY WHERE RECORD_ID = " & CURRENT_RECORD_ID & " AND STATE_ID NOT IN (SELECT WORKFLOW_FINAL_STATE1 FROM TBPMO_KONFIGURATION WHERE GUID = 1)")
            ListViewActive.Items.Clear()
            Dim anz As Integer = 0
            For Each row As DataRow In DTACTIVE.Rows

                Dim Colorstring = row.Item("COLOR")
                If Not IsDBNull(Colorstring) Then
                    If Colorstring <> "" Then
                        ListViewActive.Items.Add(row.Item("String")).BackColor = ColorTranslator.FromWin32(CInt(Colorstring))
                    Else
                        ListViewActive.Items.Add(row.Item("String"))
                    End If
                Else
                    ListViewActive.Items.Add(row.Item("String"))
                End If
                ListViewActive.Items(anz).SubItems.Add(row.Item("CHANGED_WHEN"))
                ListViewActive.Items(anz).SubItems.Add(row.Item("CHANGED_WHO"))

                anz += 1
            Next
        Catch ex As Exception
            MsgBox("Error loading Data for Active:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try

        Try
            Dim DTACTIVE As DataTable = ClassDatabase.Return_Datatable("SELECT * FROM VWPMO_WF_OVERVIEW_AUTHORITY WHERE RECORD_ID = " & CURRENT_RECORD_ID & " AND STATE_ID = (SELECT WORKFLOW_FINAL_STATE1 FROM TBPMO_KONFIGURATION WHERE GUID = 1)")
            ListViewDone.Items.Clear()
            Dim anz As Integer = 0
            For Each row As DataRow In DTACTIVE.Rows

                Dim Colorstring = row.Item("COLOR")
                If Not IsDBNull(Colorstring) Then
                    If Colorstring <> "" Then
                        ListViewDone.Items.Add(row.Item("String")).BackColor = ColorTranslator.FromWin32(CInt(Colorstring))
                    Else
                        ListViewDone.Items.Add(row.Item("String"))
                    End If
                Else
                    ListViewDone.Items.Add(row.Item("String"))
                End If
                ListViewDone.Items(anz).SubItems.Add(row.Item("CHANGED_WHEN"))
                ListViewDone.Items(anz).SubItems.Add(row.Item("CHANGED_WHO"))
                anz += 1
            Next
        Catch ex As Exception
            MsgBox("Error loading Data for Inactive:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub
    Private Sub frmTaskOverview_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        ClassWindowLocation.SaveFormLocationSize(Me, 1, CURRENT_SCREEN_ID, "frmTaskOverview")
        My.Settings.Save()
    End Sub

    Private Sub frmTaskOverview_Load(sender As Object, e As EventArgs) Handles Me.Load
        ClassWindowLocation.LoadFormLocationSize(Me, 1, CURRENT_SCREEN_ID, "frmTaskOverview")
        Me.VWPMO_WF_OVERVIEW_AUTHORITYTableAdapter.Connection.ConnectionString = MyConnectionString
        chkinFront.Checked = Sett_TaskOverviewKeepInFront
        Refresh()

    End Sub

    Private Sub chkinFront_CheckedChanged(sender As Object, e As EventArgs) Handles chkinFront.CheckedChanged
        Sett_TaskOverviewKeepInFront = chkinFront.Checked
        SaveMySettingsValue("Sett_TaskOverviewKeepInFront", Sett_TaskOverviewKeepInFront, "ConfigMain")
        If chkinFront.Checked Then
            chkinFront.Text = "TaskOverview gepinnt"
        Else
            chkinFront.Text = "Keep in Front"
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        frmTask_Editor.ShowDialog()
    End Sub
End Class