using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Data;
using VBNET = Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using System.Linq;
using System.Collections.Generic;

namespace FMSStore_DB
{
   public class Product : System.IDisposable
   {
      bool _disposed = false;
      private const string m_modName = "FMSStore_DB.Product";
      // Declare the DBHelper Object--see class initialization
      private FMStocks_DB.DBHelper m_dbh = null;
      public Product() : base()
      {
         Class_Initialize();
      }
      private void Class_Initialize()
      {
         m_dbh = new FMStocks_DB.DBHelper();
      }
      public void Dispose()
      {
         Dispose(true);
         GC.SuppressFinalize(this);
      }
      protected virtual void Dispose(bool disposing)
      {
         if (_disposed)
         {
            return;
         }
         if (disposing)
         {
            Class_Terminate();
         }
         _disposed = true;
      }
      private void Class_Terminate()
      {
         m_dbh = null;
      }
      public gmRTL.DataLib.SqlClient.Recordset FindByDescription(string description)
      {
         gmRTL.DataLib.SqlClient.Recordset FindByDescription = default;

         try
         {
            gmRTL.Core.GlobalException.Clear();

            FindByDescription = m_dbh.RunSPReturnRS("Product_FindByDescription",new object[]{FMStocks_DB.Helpers.mp("@Description",System.Data.SqlDbType.VarChar,255,description)},String.Empty);

            return FindByDescription;

         }
         catch(System.Exception exc)
         {
            gmRTL.Core.GlobalException.Initialize(exc);

            FMStocks_DB.Helpers.RaiseError(m_modName,"FindByDescription",String.Empty,0,false);
         }
         return FindByDescription;
      }
      public gmRTL.DataLib.SqlClient.Recordset GetBySKU(int SKU)
      {
         gmRTL.DataLib.SqlClient.Recordset GetBySKU = default;

         try
         {
            gmRTL.Core.GlobalException.Clear();

            GetBySKU = m_dbh.RunSPReturnRS("Product_GetBySKU",new object[]{FMStocks_DB.Helpers.mp("@SKU",System.Data.SqlDbType.Int,4,SKU)},String.Empty);

            return GetBySKU;

         }
         catch(System.Exception exc)
         {
            gmRTL.Core.GlobalException.Initialize(exc);

            FMStocks_DB.Helpers.RaiseError(m_modName,"GetBySKU",String.Empty,0,false);
         }
         return GetBySKU;
      }
      public gmRTL.DataLib.SqlClient.Recordset List()
      {
         gmRTL.DataLib.SqlClient.Recordset List = default;

         try
         {
            gmRTL.Core.GlobalException.Clear();

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

            return List;

         }
         catch(System.Exception exc)
         {
            gmRTL.Core.GlobalException.Initialize(exc);

            FMStocks_DB.Helpers.RaiseError(m_modName,"List",String.Empty,0,false);
         }
         return List;
      }
   }
}
