VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Chart"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit

'
' for internal use
Private cnn As New ADODB.Connection
Private rst As New ADODB.Recordset

'
' local enum type
Enum GraphType
    gtBar = VtChChartType3dBar
    gtLine = VtChChartType3dLine
    gtPie = VtChChartType2dPie
    gtArea = VtChChartType3dArea
End Enum

'
'local variable(s) to hold property value(s)
Private mvarOLEDBProvider As String 'local copy
Private mvarDataSource As String 'local copy
Private mvarSQLSelect As String 'local copy
Private mvarGraphTitle As String 'local copy
Private mvarGraphFootnote As String 'local copy
Private mvarGraphType As GraphType 'local copy
Private mvarGraphLegend As Boolean 'local copy

Public Sub ShowGraph()
Attribute ShowGraph.VB_Description = "Display graph in window"
    '
    ' display the results!
    '
    On Error GoTo LocalErr
    '
    Screen.MousePointer = vbHourglass
    InitDB
    Screen.MousePointer = vbNormal
    '
    Load frmChart
    With frmChart.chtData
        .ShowLegend = mvarGraphLegend
        .TitleText = mvarGraphTitle
        .chartType = mvarGraphType
        .FootnoteText = mvarGraphFootnote
        Set .DataSource = rst
    End With
    frmChart.Show vbModal
    '
    Exit Sub
    '
LocalErr:
    Err.Raise vbObjectError + 4, App.EXEName, "Error Displaying Graph"
    '
End Sub

Public Property Let GraphFootnote(ByVal vData As String)
    mvarGraphFootnote = vData
End Property

Public Property Get GraphFootnote() As String
    GraphFootnote = mvarGraphFootnote
End Property

Public Property Let GraphTitle(ByVal vData As String)
    mvarGraphTitle = vData
End Property

Public Property Get GraphTitle() As String
    GraphTitle = mvarGraphTitle
End Property

Public Property Let SQLSelect(ByVal vData As String)
Attribute SQLSelect.VB_Description = "SQL SELECT statement to create data set"
    mvarSQLSelect = vData
End Property

Public Property Get SQLSelect() As String
    SQLSelect = mvarSQLSelect
End Property

Public Property Let DataSource(ByVal vData As String)
Attribute DataSource.VB_Description = "Name of OLEDB Data Source"
    mvarDataSource = vData
End Property

Public Property Get DataSource() As String
    DataSource = mvarDataSource
End Property

Public Property Let OLEDBProvider(ByVal vData As String)
Attribute OLEDBProvider.VB_Description = "OLEDB Provider Name"
    mvarOLEDBProvider = vData
End Property


Public Property Get OLEDBProvider() As String
    OLEDBProvider = mvarOLEDBProvider
End Property

Public Property Get GraphType() As GraphType
    GraphType = mvarGraphType
End Property

Public Property Let GraphType(ByVal vData As GraphType)
    mvarGraphType = vData
End Property

Public Property Get GraphLegend() As Boolean
    GraphLegend = mvarGraphLegend
End Property

Public Property Let GraphLegend(ByVal vData As Boolean)
    mvarGraphLegend = vData
End Property

Private Sub InitDB()
    '
    ' open the database
    '
    cnn.Open "Provider=" & mvarOLEDBProvider & ";Data Source=" & mvarDataSource
    rst.Open mvarSQLSelect, cnn, adOpenStatic
    '
End Sub

Private Sub Class_Initialize()
    '
    ' setup defaults
    '
    mvarOLEDBProvider = "Microsoft.Jet.OLEDB.3.51"
    mvarGraphTitle = App.EXEName
    mvarGraphFootnote = ""
    mvarGraphType = gtBar
    mvarGraphLegend = False
    '
End Sub

Private Sub Class_Terminate()
    '
    ' close any open data objects
    '
    On Error Resume Next
    '
    rst.Close
    cnn.Close
    '
    Set rst = Nothing
    Set cnn = Nothing
    '
End Sub
