'' asp code Generated by Basic Processor
'' Original Page Name: C:\gmTestBed\FMStocks\src\FMSWeb\ASP\Portfolio.asp

Imports System.Web
NameSpace FMSWeb
Public Partial class _Portfolio : Inherits System.Web.UI.Page
   Public _t_head1 As FMSWeb._t_head
   Public _t_begin1 As FMSWeb._t_begin
   Public _t_end1 As FMSWeb._t_end

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      _t_head1 = New FMSWeb._t_head()
      _t_begin1 = New FMSWeb._t_begin()
      _t_end1 = New FMSWeb._t_end()
      _t_begin1.Include_Load(_t_head1)
      _t_end1.Include_Load(_t_head1)
   End Sub
   Dim objAccount As New FMStocks_Bus.Account
   Public Sub ListPositions()
      On Error Resume Next
      Dim rs As gmRTL.DataLib.SqlClient.Recordset = Nothing
      Dim rownum As Integer = 0
      Dim total As Double = 0.0
      Dim mv As Double = 0.0
      Dim tempMarketValue As Double = 0.0
      Dim tempYouPaid As Double = 0.0
      rs = objAccount.ListPositions(CInt(_t_head1.g_AccountID))
      If (Err.Number <> 0) Then
         _t_head1.BuildErrorMessage()
         Exit Sub
      End If
      On Error Goto 0
      rownum = 0
      total = 0
      mv = 0
      If (Not (rs.EOF And rs.BOF)) Then
         EmitHeader()
         Do Until rs.EOF
            rownum = rownum + 1
            If (rownum Mod 2 = 0) Then
               HttpContext.Current.Response.Write("<tr bgcolor=""#D8D8D8"">")
            Else
               HttpContext.Current.Response.Write("<tr bgcolor=""#FFFFCC"">")
            End If
            tempMarketValue = CDbl(rs.Fields("SharesOwned").Value) * CDbl(rs.Fields("LastPrice").Value)
            tempYouPaid = CDbl(rs.Fields("SharesOwned").Value) * CDbl(rs.Fields("AvgPricePaid").Value)
            Item(rs.Fields("ticker").Value,"left")
            Item(rs.Fields("company").Value,"left")
            Item(rs.Fields("SharesOwned").Value,"right")
            Item(rs.Fields("LastPrice").Value,"right")
            Item(Strings.FormatCurrency(tempMarketValue,-1,TriState.UseDefault,TriState.UseDefault,TriState.UseDefault),"right")
            Item(rs.Fields("AvgPricePaid").Value,"right")
            Item(Strings.FormatCurrency(tempYouPaid,-1,TriState.UseDefault,TriState.UseDefault,TriState.UseDefault),"right")
            HttpContext.Current.Response.Write("</tr>")
            total = total + tempYouPaid
            mv = mv + tempMarketValue
            rs.MoveNext()
         Loop
         EmitFooter(total,mv)
      Else
         HttpContext.Current.Response.Write("<p>Your portfolio is empty. Click <a href='buystock.aspx'>here</a> to purchase stocks.</p>")
      End If
      rs = Nothing
   End Sub
   Public Sub Item(ByVal text As Object,ByVal align As String)
      HttpContext.Current.Response.Write("	<td nowrap class='StockItem' align='" & align & "'>" & text & "</td>" & vbCrLf)
   End Sub
   Public Sub EmitHeader()
      HttpContext.Current.Response.Write("<tr>" & vbCrLf)
      HttpContext.Current.Response.Write("	<td><p class='section'>Your portfolio</p>" & vbCrLf)
      HttpContext.Current.Response.Write("<tr>" & vbCrLf)
      HttpContext.Current.Response.Write("	<td>" & vbCrLf)
      HttpContext.Current.Response.Write("	<table cellpadding='0' cellspacing='0' border='0'>" & vbCrLf)
      HttpContext.Current.Response.Write("	<tr>" & vbCrLf)
      HttpContext.Current.Response.Write("		<td class='StockHeading'>Symbol&nbsp;&nbsp;" & vbCrLf)
      HttpContext.Current.Response.Write("		<td class='StockHeading'>Name" & vbCrLf)
      HttpContext.Current.Response.Write("		<td class='StockHeading' align='right' width='50'>Qty" & vbCrLf)
      HttpContext.Current.Response.Write("		<td class='StockHeading' width='50' align='right'>Last Price" & vbCrLf)
      HttpContext.Current.Response.Write("		<td class='StockHeading' align='right'>Current Value" & vbCrLf)
      HttpContext.Current.Response.Write("		<td class='StockHeading' align='right'>Avg. Price" & vbCrLf)
      HttpContext.Current.Response.Write("		<td class='StockHeading' align='right'>Total Investment" & vbCrLf)
      HttpContext.Current.Response.Write("	<tr>" & vbCrLf)
      HttpContext.Current.Response.Write("		<td colspan='14' bgcolor='purple'>" & vbCrLf)
      HttpContext.Current.Response.Write("		<img src='images/dot_clear.gif' width='1' height='1'></td></tr>" & vbCrLf)
   End Sub
   Public Sub EmitFooter(ByVal total As Double,ByVal mv As Double)
      Dim net As Decimal = 0.00
      net = CDec(mv - total)
      Dim msg As String = ""
      If (net > 0) Then
         msg = "Gain"
      Else
         msg = "Loss"
      End If
      HttpContext.Current.Response.Write("	<tr><td height='8'></td></tr>" & vbCrLf)
      HttpContext.Current.Response.Write("	<tr bgcolor='#FFCC00'>" & vbCrLf)
      HttpContext.Current.Response.Write("		<td colspan='2' class='StockItemNoBorder'>Subtotals:</td>" & vbCrLf)
      HttpContext.Current.Response.Write("		<td colspan='3' class='StockItemNoBorder' align='right'>" & Strings.FormatCurrency(mv,-1,TriState.UseDefault,TriState.UseDefault,TriState.UseDefault) & "</td>" & vbCrLf)
      HttpContext.Current.Response.Write("		<td class='StockItemNoBorder' align='right'>&nbsp</td>" & vbCrLf)
      HttpContext.Current.Response.Write("		<td class='StockItemNoBorder' align='right'>" & Strings.FormatCurrency(total,-1,TriState.UseDefault,TriState.UseDefault,TriState.UseDefault) & "</td>" & vbCrLf)
      HttpContext.Current.Response.Write("		<td colspan='4'>" & vbCrLf)
      HttpContext.Current.Response.Write("		<img src='images/dot_clear.gif' width='1' height='1'></td>" & vbCrLf)
      HttpContext.Current.Response.Write("	</tr>" & vbCrLf)
      HttpContext.Current.Response.Write("	<tr bgcolor='#FFCC00'>" & vbCrLf)
      HttpContext.Current.Response.Write("		<td colspan='99' class='StockItemNoBorder'><b>Net " & msg & "&nbsp " & Strings.FormatCurrency(net,-1,TriState.UseDefault,TriState.UseDefault,TriState.UseDefault) & "</b></td>" & vbCrLf)
      HttpContext.Current.Response.Write("	</tr>" & vbCrLf)
      HttpContext.Current.Response.Write("		<td>&nbsp</td>" & vbCrLf)
      HttpContext.Current.Response.Write("	<tr>" & vbCrLf)
      HttpContext.Current.Response.Write("	</tr>" & vbCrLf)
      HttpContext.Current.Response.Write("	<tr><td colspan='9'><table><tr>" & vbCrLf)
      HttpContext.Current.Response.Write("		<td><p class='section'></p></td>" & vbCrLf)
      HttpContext.Current.Response.Write("		<td align='right'><img src='images/djianasd.png'></td>" & vbCrLf)
      HttpContext.Current.Response.Write("	</tr></table></td></tr>" & vbCrLf)
      HttpContext.Current.Response.Write("	</table>" & vbCrLf)
   End Sub
End Class
End Namespace
