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 FMStocks_DB
{
   public class Position : System.IDisposable
   {
      bool _disposed = false;
      private const string m_modName = "FMStocks_DB.Position";
      private DBHelper m_dbh = null;
      public Position() : base()
      {
         Class_Initialize();
      }
      private void Class_Initialize()
      {
         // must call CreateObject or COM+ will
         // not call IObjectConstructor inferface that DBHelper needs
         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 ListForAdjustment(int AccountID,string Ticker)
      {
         gmRTL.DataLib.SqlClient.Recordset ListForAdjustment = default;

         try
         {
            gmRTL.Core.GlobalException.Clear();
            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)},String.Empty);

            return ListForAdjustment;

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

            Helpers.RaiseError(m_modName,"ListForAdjustment(" + AccountID + "," + Ticker + ")","",0,false);
         }
         return ListForAdjustment;
      }
      public gmRTL.DataLib.SqlClient.Recordset ListSummary(int AccountID)
      {
         gmRTL.DataLib.SqlClient.Recordset ListSummary = default;

         try
         {
            gmRTL.Core.GlobalException.Clear();
            ListSummary = m_dbh.RunSPReturnRS("Position_ListSummary",new object[]{Helpers.mp("@AccountID",System.Data.SqlDbType.Int,4,AccountID)},String.Empty);

            return ListSummary;

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

            Helpers.RaiseError(m_modName,"ListSummary(" + AccountID + ")","",0,false);
         }
         return ListSummary;
      }
      public gmRTL.DataLib.SqlClient.Recordset ListForSale(int AccountID)
      {
         gmRTL.DataLib.SqlClient.Recordset ListForSale = default;

         try
         {
            gmRTL.Core.GlobalException.Clear();
            ListForSale = m_dbh.RunSPReturnRS("Position_ListForSale",new object[]{Helpers.mp("@AccountID",System.Data.SqlDbType.Int,4,AccountID)},String.Empty);

            return ListForSale;

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

            Helpers.RaiseError(m_modName,"ListForSale(" + AccountID + ")","",0,false);
         }
         return ListForSale;
      }
   }
}
