Imports DevExpress.DataAccess
Imports DevExpress.DataAccess.ConnectionParameters
Imports DevExpress.DataAccess.Sql

Public Class DashboardDesignerUserControl
    Private _DashboardViewerInfo As String
    Private _UserName As String
    Private _Password As String
    Private _Database As String
    Private _SQLServer As String
    Private _SQLType As eSQLType

    Public ReadOnly Property DashboardDesigner() As DevExpress.DashboardWin.DashboardDesigner
        Get
            Return Me.DashboardDesigner1
        End Get
    End Property
    Public ReadOnly Property BarManger As DevExpress.XtraBars.BarManager
        Get
            Return BarManager1
        End Get
    End Property

    Public Property DashboardViewerInfo As String
        Get
            Return _DashboardViewerInfo
        End Get
        Set(value As String)
            _DashboardViewerInfo = value
        End Set
    End Property
    Public Property UserName As String
        Get
            Return _UserName
        End Get
        Set(value As String)
            _UserName = value
        End Set
    End Property
    Public Property Password As String
        Get
            Return _Password
        End Get
        Set(value As String)
            _Password = value
        End Set
    End Property
    Public Property Database As String
        Get
            Return _Database
        End Get
        Set(value As String)
            _Database = value
        End Set
    End Property
    Property SQLServer As String
        Get
            Return _SQLServer
        End Get
        Set(value As String)
            _SQLServer = value
        End Set
    End Property
    Public Property SQLType As eSQLType
        Get
            Return _SQLType
        End Get
        Set(value As eSQLType)
            _SQLType = value
        End Set
    End Property
    Private Sub DashboardDesigner1_ConfigureDataConnection(sender As Object, e As ConfigureDataConnectionEventArgs) Handles DashboardDesigner1.ConfigureDataConnection
        Select Case Me.SQLType.ToString
            Case "MySQL"
                Dim _ConnectionParameters As New MySqlConnectionParameters

                _ConnectionParameters.DatabaseName = Me.Database
                _ConnectionParameters.UserName = Me.UserName
                _ConnectionParameters.Password = Me.Password
                _ConnectionParameters.ServerName = Me.SQLServer

                e.ConnectionParameters = _ConnectionParameters
            Case "PostgreSQL"
                Dim _ConnectionParameters As New PostgreSqlConnectionParameters
                _ConnectionParameters.DatabaseName = Me.Database
                _ConnectionParameters.UserName = Me.UserName
                _ConnectionParameters.Password = Me.Password
                _ConnectionParameters.ServerName = Me.SQLServer

                e.ConnectionParameters = _ConnectionParameters
            Case "MSSQL"
                Dim _ConnectionParameters As New MsSqlConnectionParameters
                _ConnectionParameters.DatabaseName = Me.Database
                _ConnectionParameters.UserName = Me.UserName
                _ConnectionParameters.Password = Me.Password
                _ConnectionParameters.ServerName = Me.SQLServer

                e.ConnectionParameters = _ConnectionParameters
        End Select
    End Sub
End Class
