' ------------------------------------------------------------
' Code generated automatically by Code Architects' VB Migration Partner
' ------------------------------------------------------------

Option Strict Off      ' Code migrated from VB6 has Option Strict disabled by default

<System.Runtime.InteropServices.ProgID("FMStocks_DB.Ticker")> _ 
<Transaction(TransactionOption.Supported)> _
Public Class Ticker
	Inherits ServicedComponent

	#Region "Constructor"
	
	'A public default constructor
	Public Sub New()
		Class_Initialize_VB6()
		' Add initialization code here
	End Sub
	
	#End Region
	
	#Region "Static constructor"
	
	' This static constructor ensures that the VB6 support library be initialized before using current class.
	Shared Sub New()
		EnsureVB6LibraryInitialization()
	End Sub
	
	#End Region
	
	Private Const m_modName As String = "FMStocks_DB.Ticker"
	Private m_dbh As DBHelper
	
	Private Sub Class_Initialize_VB6()
		'must call CreateObject or COM+ will
		'not call IObjectConstructor inferface that DBHelper needs
		m_dbh = CreateObject6("FMStocks_DB.DBHelper")
	End Sub

	Private Sub Class_Terminate_VB6()
		m_dbh = Nothing
	End Sub
	
	Public Function VerifySymbol(ByVal Ticker As String) As Boolean
		On Error GoTo errorHandler 
		
		VerifySymbol = m_dbh.RunSPReturnInteger("Ticker_VerifySymbol", Array6(mp("@Ticker", ADODB.DataTypeEnum.adChar, 12, Ticker)))
		
		VB6MtsMethods.GetObjectContext().SetComplete
		Exit Function
		
errorHandler:
		VB6MtsMethods.GetObjectContext().SetAbort
		RaiseError(m_modName, "VerifySymbol(" & Ticker & ")")
	End Function

	Public Function GetPrice(ByVal Ticker As String) As Decimal
		On Error GoTo errorHandler 
		
		Dim x As Object = m_dbh.RunSPReturnInteger("Ticker_GetPrice", Array6(mp("@Ticker", ADODB.DataTypeEnum.adChar, 12, Ticker)))
		
		GetPrice = NullsToZero(x) 'changes a null return value into a zero, or returns x
		
		VB6MtsMethods.GetObjectContext().SetComplete
		Exit Function
		
errorHandler:
		GetPrice = 0
		VB6MtsMethods.GetObjectContext().SetAbort
		RaiseError(m_modName, "GetPrice(" & Ticker & ")")
	End Function

	Public Function ListByTicker(ByVal Ticker As String) As ADODB.Recordset
		On Error GoTo errorHandler 
		ListByTicker = m_dbh.RunSPReturnRS("Ticker_ListByTicker", Array6(mp("@Ticker", ADODB.DataTypeEnum.adVarChar, 12, Ticker)))
		VB6MtsMethods.GetObjectContext().SetComplete
		Exit Function
		
errorHandler:
		VB6MtsMethods.GetObjectContext().SetAbort
		RaiseError(m_modName, "ListByTicker(" & Ticker & ")")
	End Function

	Public Function ListByCompany(ByVal Company As String) As ADODB.Recordset
		On Error GoTo errorHandler 
		ListByCompany = m_dbh.RunSPReturnRS("Ticker_ListByCompany", Array6(mp("@Company", ADODB.DataTypeEnum.adVarChar, 60, Company)))
		VB6MtsMethods.GetObjectContext().SetComplete
		Exit Function
		
errorHandler:
		VB6MtsMethods.GetObjectContext().SetAbort
		RaiseError(m_modName, "ListByCompany(" & Company & ")")
	End Function

	Public Function GetFundamentals(ByVal Ticker As String) As ADODB.Recordset
		On Error GoTo errorHandler 
		GetFundamentals = m_dbh.RunSPReturnRS("Ticker_Fundamentals", Array6(mp("@Ticker", ADODB.DataTypeEnum.adVarChar, 12, Ticker)))
		VB6MtsMethods.GetObjectContext().SetComplete
		Exit Function
		
errorHandler:
		VB6MtsMethods.GetObjectContext().SetAbort
		RaiseError(m_modName, "GetFundamentals(" & Ticker & ")")
	End Function

	Protected Overrides Sub Dispose(ByVal disposing As Boolean)
		Try
				Class_Terminate_VB6()
		Finally
			MyBase.Dispose(disposing)
		End Try
	End Sub

End Class
