' ------------------------------------------------------------
' 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.Tx")> _ 
<Transaction(TransactionOption.RequiresNew)> _
Public Class Tx
	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.Tx"
	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 GetByID(ByVal TxID As Integer) As ADODB.Recordset
		On Error GoTo errorHandler 
		
		GetByID = m_dbh.RunSPReturnRS("Tx_GetByID", Array6(mp("@TxID", ADODB.DataTypeEnum.adInteger, 4, TxID)))
		VB6MtsMethods.GetObjectContext().SetComplete
		Exit Function
		
errorHandler:
		VB6MtsMethods.GetObjectContext().SetAbort
		RaiseError(m_modName, "GetByID(" & TxID & ")")
	End Function

	Public Function AddSellOrder(ByVal AccountID As Integer, ByVal Ticker As String, ByVal Shares As Integer) As Integer

		On Error GoTo errorHandler 
		
		AddSellOrder = m_dbh.RunSPReturnInteger("Tx_AddSellOrder", Array6(mp("@AccountID", ADODB.DataTypeEnum.adInteger, 4, AccountID), mp("@Ticker", ADODB.DataTypeEnum.adVarChar, 12, Ticker), mp("@Shares", ADODB.DataTypeEnum.adInteger, 4, Shares)))
		
		VB6MtsMethods.GetObjectContext().SetComplete
		Exit Function
		
errorHandler:
		VB6MtsMethods.GetObjectContext().SetAbort
		RaiseError(m_modName, "AddSellOrder(" & AccountID & "," & Ticker & "," & Shares & ")")
	End Function

	Public Function AddBuyOrder(ByVal AccountID As Integer, ByVal Ticker As String, ByVal Shares As Integer) As Integer
		
		On Error GoTo errorHandler 
		
		AddBuyOrder = m_dbh.RunSPReturnInteger("Tx_AddBuyOrder", Array6(mp("@AccountID", ADODB.DataTypeEnum.adInteger, 4, AccountID), mp("@Ticker", ADODB.DataTypeEnum.adVarChar, 12, Ticker), mp("@Shares", ADODB.DataTypeEnum.adInteger, 4, Shares)))
		
		VB6MtsMethods.GetObjectContext().SetComplete
		Exit Function
		
errorHandler:
		VB6MtsMethods.GetObjectContext().SetAbort
		RaiseError(m_modName, "AddBuyOrder(" & AccountID & "," & Ticker & "," & Shares & ")")
	End Function

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

End Class
