Public Class frmGhostMode
    Private Sub frmGhostMode_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim oSQL = "SELECT CONFIG_VALUE FROM TBIDB_BASE WHERE CONFIG_NAME = 'GHOST_SELECT'"
        oSQL = ClassDatabase.Execute_Scalar_ConStr(oSQL, CONNECTION_STRING_IDB, "frmGhostMode_Load")
        Dim DT_USER = ClassDatabase.Return_Datatable(oSQL, "frmGhostMode_LoadDT")

        Try
            If Not IsNothing(DT_USER) Then
                GridControl1.DataSource = DT_USER
            End If


        Catch ex As Exception
            MsgBox("Error Load_Users:" & vbNewLine & ex.Message)
        End Try
    End Sub

    Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
        Dim oFocusedUserName
        Try
            oFocusedUserName = GridView1.GetFocusedRowCellValue(GridView1.Columns("UserName"))
            If IsNothing(oFocusedUserName) Then
                oFocusedUserName = GridView1.GetFocusedRowCellValue(GridView1.Columns("USERNAME"))
            End If
            If IsNothing(oFocusedUserName) Then
                oFocusedUserName = GridView1.GetFocusedRowCellValue(GridView1.Columns("USER_NAME"))
            End If
            If IsNothing(oFocusedUserName) Then
                oFocusedUserName = GridView1.GetFocusedRowCellValue(GridView1.Columns("USER"))
            End If
        Catch ex As Exception
            oFocusedUserName = GridView1.GetFocusedRowCellValue(GridView1.Columns("UserName"))
            If IsNothing(oFocusedUserName) Then
                MsgBox(ex.Message, MsgBoxStyle.Critical)
                Exit Sub
            End If
        End Try
        If oFocusedUserName <> String.Empty Then
            Dim result As MsgBoxResult = MsgBox("Do You really want to activate the Ghost-Mode?", MsgBoxStyle.YesNo, "")
            'wenn Speichern ja
            If result = MsgBoxResult.Yes Then
                USER_GHOST_MODE_USRNAME = oFocusedUserName
                USER_GHOST_MODE_ACTIVE = True
                Me.Close()
            End If
        Else
            MsgBox("Please choose an user for ghostmode!", MsgBoxStyle.Information)
        End If

    End Sub
End Class