Option Strict Off
Option Explicit On
Imports System.Linq
Imports System.Collections.Generic
Namespace FMSStore_DB
   Public Class Product : Implements System.IDisposable
   Dim _disposed As Boolean = False
   Private Const m_modName As String = "FMSStore_DB.Product"
   'Declare the DBHelper Object--see class initialization
   Private m_dbh As FMStocks_DB.DBHelper = Nothing
   Public Sub New()
      MyBase.New()
      Class_Initialize()
   End Sub
   Private Sub Class_Initialize()
      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 FindByDescription(ByVal description As String) As gmRTL.DataLib.SqlClient.Recordset
      FindByDescription = Nothing
      Try
         gmRTL.Core.GlobalException.ClearErrorObject()

         FindByDescription = m_dbh.RunSPReturnRS("Product_FindByDescription",New Object(){FMStocks_DB.Helpers.mp("@Description",System.Data.SqlDbType.VarChar,255,description)},String.Empty)

         Exit Function

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

         FMStocks_DB.Helpers.RaiseError(m_modName,"FindByDescription",String.Empty,0,False)
      End Try
   End Function
   Public Function GetBySKU(ByVal SKU As Integer) As gmRTL.DataLib.SqlClient.Recordset
      GetBySKU = Nothing
      Try
         gmRTL.Core.GlobalException.ClearErrorObject()

         GetBySKU = m_dbh.RunSPReturnRS("Product_GetBySKU",New Object(){FMStocks_DB.Helpers.mp("@SKU",System.Data.SqlDbType.Int,4,SKU)},String.Empty)

         Exit Function

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

         FMStocks_DB.Helpers.RaiseError(m_modName,"GetBySKU",String.Empty,0,False)
      End Try
   End Function
   Public Function List() As gmRTL.DataLib.SqlClient.Recordset
      List = Nothing
      Try
         gmRTL.Core.GlobalException.ClearErrorObject()

         List = m_dbh.RunSPReturnRS("Product_List",,String.Empty)

         Exit Function

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

         FMStocks_DB.Helpers.RaiseError(m_modName,"List",String.Empty,0,False)
      End Try
   End Function
   End Class
End Namespace
