' ------------------------------------------------------------
' 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.Position")> _ 
<Transaction(TransactionOption.Supported)> _
Public Class Position
	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.Position"
	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 ListForAdjustment(ByVal AccountID As Integer, ByVal Ticker As String) As ADODB.Recordset
		On Error GoTo errorHandler 
		ListForAdjustment = m_dbh.RunSPReturnRS_RW("Position_ListForAdjustment", Array6(mp("@AccountID", ADODB.DataTypeEnum.adInteger, 4, AccountID), mp("@Ticker", ADODB.DataTypeEnum.adVarChar, 15, Ticker)))
		VB6MtsMethods.GetObjectContext().SetComplete
		Exit Function
		
errorHandler:
		VB6MtsMethods.GetObjectContext().SetAbort
		RaiseError(m_modName, "ListForAdjustment(" & AccountID & "," & Ticker & ")")
	End Function

	Public Function ListSummary(ByVal AccountID As Integer) As ADODB.Recordset
		On Error GoTo errorHandler 
		ListSummary = m_dbh.RunSPReturnRS("Position_ListSummary", Array6(mp("@AccountID", ADODB.DataTypeEnum.adInteger, 4, AccountID)))
		VB6MtsMethods.GetObjectContext().SetComplete
		Exit Function
		
errorHandler:
		VB6MtsMethods.GetObjectContext().SetAbort
		RaiseError(m_modName, "ListSummary(" & AccountID & ")")
	End Function

	Public Function ListForSale(ByVal AccountID As Integer) As ADODB.Recordset
		On Error GoTo errorHandler 
		ListForSale = m_dbh.RunSPReturnRS("Position_ListForSale", Array6(mp("@AccountID", ADODB.DataTypeEnum.adInteger, 4, AccountID)))
		VB6MtsMethods.GetObjectContext().SetComplete
		Exit Function
		
errorHandler:
		VB6MtsMethods.GetObjectContext().SetAbort
		RaiseError(m_modName, "ListForSale(" & AccountID & ")")
	End Function

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

End Class
