Public Class frmStatistiscsADDI

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

        'TODO: Diese Codezeile lädt Daten in die Tabelle "DD_ECMAdmin.VWDD_LOGIN_USER_HISTORY". Sie können sie bei Bedarf verschieben oder entfernen.
        Me.VWDD_LOGIN_USER_HISTORYTableAdapter.Connection.ConnectionString = MYDB_ECM.CurrentConnectionString
        Me.VWDD_LOGIN_USER_HISTORYTableAdapter.Fill(Me.DD_ECMAdmin.VWDD_LOGIN_USER_HISTORY)

    End Sub

    Private Sub XtraTabControl1_SelectedPageChanged(sender As Object, e As DevExpress.XtraTab.TabPageChangedEventArgs) Handles XtraTabControl1.SelectedPageChanged
        Select Case XtraTabControl1.SelectedTabPageIndex
            Case 1
                Load_Essentials()
        End Select
    End Sub

    Sub Load_Essentials()
        Try
            Me.Cursor = Cursors.WaitCursor
            Me.TBPMO_LOG_ESSENTIALSTableAdapter.Connection.ConnectionString = MYDB_ECM.CurrentConnectionString
            Me.TBPMO_LOG_ESSENTIALSTableAdapter.Fill(Me.DD_ECMAdmin.TBPMO_LOG_ESSENTIALS)
            Me.tslblEssential.Text = "Essential Logs (" & DD_ECMAdmin.TBPMO_LOG_ESSENTIALS.Rows.Count.ToString & ")"
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        Finally
            Me.Cursor = Cursors.Default
        End Try
     
    End Sub

    Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
        Try
            TBPMO_LOG_ESSENTIALSBindingSource.EndEdit()
            For Each row As DataRow In DD_ECMAdmin.TBPMO_LOG_ESSENTIALS.Rows
                If row.Item("Selection") = True Then
                    Dim del = String.Format("DELETE FROM TBPMO_LOG_ESSENTIALS WHERE GUID = {0}", row.Item("GUID"))
                    MYDB_ECM.ExecuteNonQuery(del)
                End If
            Next
            Load_Essentials()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub

 

    Private Sub GridViewLogEssentials_RowStyle(sender As Object, e As DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs) Handles GridViewLogEssentials.RowStyle
        If e.RowHandle = -1 Then
            Exit Sub
        End If
        If e.RowHandle = DevExpress.XtraGrid.GridControl.AutoFilterRowHandle Then
            e.Appearance.BackColor = Color.Orange
        End If
    End Sub

    Private Sub GridViewLoginHistory_ColumnFilterChanged(sender As Object, e As EventArgs) Handles GridViewLoginHistory.ColumnFilterChanged
        tslblLoginCountRecords.Text = "Count Records: " & GridViewLoginHistory.RowCount
    End Sub
    Private Sub GridViewLogEssentials_ColumnFilterChanged(sender As Object, e As EventArgs) Handles GridViewLogEssentials.ColumnFilterChanged
        tslblEssential.Text = "Essential logs-Count: " & GridViewLogEssentials.RowCount
    End Sub

    Private Sub GridViewLoginHistory_RowStyle(sender As Object, e As DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs) Handles GridViewLoginHistory.RowStyle
        If e.RowHandle = -1 Then
            Exit Sub
        End If
        If e.RowHandle = DevExpress.XtraGrid.GridControl.AutoFilterRowHandle Then
            e.Appearance.BackColor = Color.Orange
        End If
    End Sub

    Private Sub ToolStripButton2_Click(sender As Object, e As EventArgs) Handles ToolStripButton2.Click
        Dim listRecords As New ArrayList
        Dim collist As New ArrayList
        For i = 0 To GridViewLogEssentials.RowCount
            Dim recid = GridViewLogEssentials.GetRowCellValue(i, "GUID")
            If Not IsNothing(recid) Then
                listRecords.Add(recid)
            End If
        Next
        For Each row As DataRow In DD_ECMAdmin.TBPMO_LOG_ESSENTIALS.Rows
            For Each Record As String In listRecords
                If Record = row.Item("GUID") Then
                    row.Item("Selection") = True
                    Exit For
                End If
            Next
        Next
    End Sub
End Class