VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Ticker"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Const m_modName As String = "FMStocks_DB.Ticker"
Private m_dbh As DBHelper

Private Sub Class_Initialize()
    'must call CreateObject or COM+ will
    'not call IObjectConstructor inferface that DBHelper needs
    Set m_dbh = CreateObject("FMStocks_DB.DBHelper")
End Sub

Private Sub Class_Terminate()
    Set m_dbh = Nothing
End Sub
Public Function VerifySymbol(ByVal Ticker As String) As Boolean
    On Error GoTo errorHandler
    
    VerifySymbol = m_dbh.RunSPReturnInteger("Ticker_VerifySymbol", Array( _
        mp("@Ticker", adChar, 12, Ticker)))
   
    
    Exit Function

errorHandler:
    
    RaiseError m_modName, "VerifySymbol(" & Ticker & ")"
End Function

Public Function GetPrice(ByVal Ticker As String) As Currency
    On Error GoTo errorHandler
        
    Dim x As Variant
    x = m_dbh.RunSPReturnInteger("Ticker_GetPrice", Array(mp("@Ticker", adChar, 12, Ticker)))
    
    GetPrice = NullsToZero(x) 'changes a null return value into a zero, or returns x
   
    
    Exit Function
    
errorHandler:
    GetPrice = 0
    
    RaiseError m_modName, "GetPrice(" & Ticker & ")"
End Function


Public Function ListByTicker(ByVal Ticker As String) As ADODB.Recordset
    On Error GoTo errorHandler
    Set ListByTicker = m_dbh.RunSPReturnRS("Ticker_ListByTicker", Array( _
        mp("@Ticker", adVarChar, 12, Ticker)))
    
    Exit Function
        
errorHandler:
    
    RaiseError m_modName, "ListByTicker(" & Ticker & ")"
End Function


Public Function ListByCompany(ByVal Company As String) As ADODB.Recordset
    On Error GoTo errorHandler
    Set ListByCompany = m_dbh.RunSPReturnRS("Ticker_ListByCompany", _
        Array(mp("@Company", adVarChar, 60, Company)))
    
    Exit Function
        
errorHandler:
    
    RaiseError m_modName, "ListByCompany(" & Company & ")"
End Function


Public Function GetFundamentals(ByVal Ticker As String) As ADODB.Recordset
    On Error GoTo errorHandler
    Set GetFundamentals = m_dbh.RunSPReturnRS("Ticker_Fundamentals", Array( _
        mp("@Ticker", adVarChar, 12, Ticker)))
    
    Exit Function
        
errorHandler:
    
    RaiseError m_modName, "GetFundamentals(" & Ticker & ")"
End Function
