This documentation is archived and is not being maintained.

Account Summary

Visual Studio .NET 2003

The Account Summary page, which displays the account balance for the currently logged on user, includes the following:

  • Securities Market Value
    United States currency value of the currently logged on user's securities market value.
  • Total Cash
    United States currency value of the currently logged on user's cash reserves.
  • Total Account Value
    United States currency value of the currently logged on user's total value, which is the sum of the securities value and cash reserve.

Implementation

The Account Summary process uses the following ASP.NET file and C# code behind files:

Process Overview

The Account Summary process is initiated in the User Services Layer (USL). A user selects View your balance from the list on the left side of the user interface, which calls the AccountSummary ASP.NET page. An Account object is used to pass the currently logged on user's account ID number to the DAL. The DAL calls the Account_Summary SPROC to retrieve the user's portfolio market value. The DAL also calls the GAM, which returns the user's account cash balance.

To find source code that applies to specific layers in this topic, click the appropriate link:

BLL Source Code | DAL Source Code | SPROC

USL Source Code

By default, the USL source code is located in the [Drive letter where Visual Studio .NET is installed]:\Program Files\Microsoft Visual Studio .NET 2003\Enterprise Samples\FMStocks7\Web\AccountSummary.aspx.cs file.

Key Points

  • The VerifyConnection method is called on every ASP.NET page to ensure that a client is still connected before proceeding. This method is inherited from the FMSPage class.
  • The AccountID property is used to provide the account number of the current user. This property is inherited from the FMSPage class. It obtains the account number by reading the current user identity (Forms Authentication).
    protected void Page_Load(object sender, EventArgs e)
       {
       if ( VerifyConnection() )
          {
          Account account = new Account();
          account.GetSummary( AccountID, out marketValueAmt, out cashBalanceAmt );
          }
       }
    

BLL Source Code

By default, the FMStocks7.BLL.Account.GetSummary method source code is located in the [Drive letter where Visual Studio .NET is installed]:\Program Files\Microsoft Visual Studio .NET 2003\Enterprise Samples\FMStocks7\BLL\Account.cs file.

///   <summary> 
///      Retrieve account summary information
///      <param name='accountID'>The accountID number</param>            
///      <param name='marketValueAmt'>Total market value (out)</param>
///      <param name='cashBalanceAmt'>Cash balance (out)</param>
///   </summary>

public void GetSummary(   int accountID, out decimal marketValueAmt, out decimal cashBalanceAmt )
   {
   DAL.Account account = new DAL.Account();

   try   {
      account.GetSummary( accountID, out marketValueAmt, out cashBalanceAmt );
      }
   finally
      {
      ServicedComponent.DisposeObject( account );
      }
   }

DAL Source Code

By default, the FMStocks7.DAL.Account.GetSummary method source code is located in the [Drive letter where Visual Studio .NET is installed]:\Program Files\Microsoft Visual Studio .NET 2003\Enterprise Samples\FMStocks7\DAL\Account.cs file.

Key Points

Getting the summary, which is a two-step process, extracts the summary via a stored procedure directly and calls a COM component — GAM — to get the account balance.

///   <summary>
///      Retrieve account summary information
///      <param name='accountID'>The accountID number</param>
///      <param name='marketValueOfPortfolio'>Total market value (out)</param>
///      <param name='cashBalance'>Cash balance (out)</param>
///   </summary>

[AutoComplete]

public void GetSummary( int accountID, out decimal marketValueOfPortfolio,  out decimal cashBalance )
{
   Debug.Assert( sproc == null );

   // Create parameter array

   SqlParameter[] parameters =
   {
      new SqlParameter( "@AccountID",      SqlDbType.Int,   4 ), // 0
      new SqlParameter( "@MarketValueAmt", SqlDbType.Money, 8 ), // 1
   };

   // Set parameter values and directions

   parameters[ 0 ].Value     = accountID;
   parameters[ 1 ].Direction = ParameterDirection.Output;

   // Run the stored procedure

   sproc = new StoredProcedure( "Account_Summary", parameters );
   sproc.Run();

   marketValueOfPortfolio = ( decimal )parameters[ 1 ].Value;
   IGAM gam = new FMStocks7.GAM.GAM();
   cashBalance = ( decimal )gam.GetAccountBalance( accountID );
}

SPROC

By default, the SQL stored procedure is located in the [Drive letter where Visual Studio .NET is installed]:\Program Files\Microsoft Visual Studio .NET 2003\Enterprise Samples\FMStocks7\Database\SQLScripts\Sprocs.Sql and GAMSprocs.Sql files.

Account_Summary SPROC in Sprocs.Sql:

---------------------------------------------------------------------------------
-- Name:    Account_Summary
--
-- Purpose: Get financial information for an account.
--
-- Returns: Value of @@ERROR.
---------------------------------------------------------------------------------

create procedure Account_Summary
   @AccountID          int,
   @MarketValueAmt     money out   
as
   declare @LastError int

   select  @MarketValueAmt = sum( cp.Last * p.Shares )         
   from    Positions p,
         CurrentPrices cp,
         TickerList t
   where   p.AccountID = @AccountID
   and     p.Ticker *= cp.Ticker
   and     p.Ticker = t.Ticker

   select   @LastError = @@ERROR
    
   -- make out parameters safer for caller

   if @MarketValueAmt is null
      select @MarketValueAmt = 0   

   return @LastError
go

AccountBalance_Get SPROC in GAMSprocs.Sql:

Key Points

This stored procedure is used by the COM component – GAM.

---------------------------------------------------------------------------------
-- Name:    AccountBalance_Get
--
-- Purpose: Retrieve account balance.
--
-- Return:  SQL error code.
---------------------------------------------------------------------------------

CREATE procedure AccountBalance_Get
   @AccountID  int, @Balance money out
as
   select @Balance =  Balance
   from    AccountBalances
   where   AccountID = @AccountID
    
   return @@ERROR
go

See Also

Behind the Scenes of Fitch and Mather 7.0 | Architectural Overview

Show: