VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Tx"
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.Tx"
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 GetByID(ByVal TxID As Long) As ADODB.Recordset
    On Error GoTo errorHandler
    
    Set GetByID = m_dbh.RunSPReturnRS("Tx_GetByID", Array(mp("@TxID", adInteger, 4, TxID)))
    
    Exit Function

errorHandler:
    
    RaiseError m_modName, "GetByID(" & TxID & ")"
End Function


Public Function AddSellOrder(ByVal AccountID As Long, _
        ByVal Ticker As String, _
        ByVal Shares As Long) As Long
        
    
    On Error GoTo errorHandler
    
    AddSellOrder = m_dbh.RunSPReturnInteger("Tx_AddSellOrder", Array( _
        mp("@AccountID", adInteger, 4, AccountID), _
        mp("@Ticker", adVarChar, 12, Ticker), _
        mp("@Shares", adInteger, 4, Shares)))
    
    
    Exit Function
    
errorHandler:
    
    RaiseError m_modName, "AddSellOrder(" & AccountID _
                          & "," & Ticker & "," & Shares & ")"
End Function


Public Function AddBuyOrder(ByVal AccountID As Long, _
        ByVal Ticker As String, _
        ByVal Shares As Long) As Long
        
    On Error GoTo errorHandler
    
    AddBuyOrder = m_dbh.RunSPReturnInteger("Tx_AddBuyOrder", Array( _
        mp("@AccountID", adInteger, 4, AccountID), _
        mp("@Ticker", adVarChar, 12, Ticker), _
        mp("@Shares", adInteger, 4, Shares)))
    
    
    Exit Function
    
errorHandler:
    
    RaiseError m_modName, "AddBuyOrder(" & AccountID _
                          & "," & Ticker & "," & Shares & ")"
End Function


