Option Strict Off
Option Explicit On
Imports System.Linq
Imports System.Collections.Generic
Namespace FMStocks_DB
   Public Class Position : Implements System.IDisposable
   Dim _disposed As Boolean = False
   Private Const m_modName As String = "FMStocks_DB.Position"
   Private m_dbh As DBHelper = Nothing
   Public Sub New()
      MyBase.New()
      Class_Initialize()
   End Sub
   Private Sub Class_Initialize()
      'must call CreateObject or COM+ will
      'not call IObjectConstructor inferface that DBHelper needs
      m_dbh = New FMStocks_DB.DBHelper
   End Sub
   Public Sub Dispose() Implements System.IDisposable.Dispose
      Dispose(True)
      GC.SuppressFinalize(Me)
   End Sub
   Protected Overridable Sub Dispose(disposing As Boolean)
      If _disposed Then
         Return
      End If
      If (disposing) Then
         Class_Terminate()
      End If
      _disposed = True
   End Sub
   Private Sub Class_Terminate()
      m_dbh = Nothing
   End Sub
   Public Function ListForAdjustment(ByVal AccountID As Integer,ByVal Ticker As String) As gmRTL.DataLib.SqlClient.Recordset
      ListForAdjustment = Nothing
      Try
         gmRTL.Core.GlobalException.ClearErrorObject()
         ListForAdjustment = m_dbh.RunSPReturnRS_RW("Position_ListForAdjustment",New Object(){Helpers.mp("@AccountID",System.Data.SqlDbType.Int,4,AccountID),Helpers.mp("@Ticker",System.Data.SqlDbType.VarChar,15,Ticker)})

         Exit Function

      Catch exc As System.Exception
         gmRTL.Core.GlobalException.SetErrorObject(exc)

         Helpers.RaiseError(m_modName,"ListForAdjustment(" & AccountID & "," & Ticker & ")")
      End Try
   End Function
   Public Function ListSummary(ByVal AccountID As Integer) As gmRTL.DataLib.SqlClient.Recordset
      ListSummary = Nothing
      Try
         gmRTL.Core.GlobalException.ClearErrorObject()
         ListSummary = m_dbh.RunSPReturnRS("Position_ListSummary",New Object(){Helpers.mp("@AccountID",System.Data.SqlDbType.Int,4,AccountID)})

         Exit Function

      Catch exc As System.Exception
         gmRTL.Core.GlobalException.SetErrorObject(exc)

         Helpers.RaiseError(m_modName,"ListSummary(" & AccountID & ")")
      End Try
   End Function
   Public Function ListForSale(ByVal AccountID As Integer) As gmRTL.DataLib.SqlClient.Recordset
      ListForSale = Nothing
      Try
         gmRTL.Core.GlobalException.ClearErrorObject()
         ListForSale = m_dbh.RunSPReturnRS("Position_ListForSale",New Object(){Helpers.mp("@AccountID",System.Data.SqlDbType.Int,4,AccountID)})

         Exit Function

      Catch exc As System.Exception
         gmRTL.Core.GlobalException.SetErrorObject(exc)

         Helpers.RaiseError(m_modName,"ListForSale(" & AccountID & ")")
      End Try
   End Function
   End Class
End Namespace
