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

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

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      _t_head1 = New FMSWeb._t_head()
      _t_begin_cart1 = New FMSWeb._t_begin_cart()
      _t_end1 = New FMSWeb._t_end()
      _t_begin1 = New FMSWeb._t_begin()
      _t_begin_cart1.Include_Load(_t_head1, _t_begin1)
      _t_end1.Include_Load(_t_head1)
      _t_begin1.Include_Load(_t_head1)
   End Sub
   Dim bus As New FMStocks_Bus.Version
   Public Sub PerformCheckout()
      Dim rs As gmRTL.DataLib.SqlClient.Recordset = Nothing
      Dim total As Double = 0.0
      Dim quantity As Double = 0.0
      Dim price As Double = 0.0
      Dim subtotal As Double = 0.0
      rs = _t_begin_cart1.cart.ListByAccount(CInt(_t_head1.g_AccountID))
      If (rs.EOF) Then
         'nothing in the cart
         HttpContext.Current.Response.Write("		You have no items in your shopping cart." & vbCrLf)
      ElseIf (HttpContext.Current.Request("Action") = "Buy") Then
         _t_begin_cart1.cart.Buy(CInt(_t_head1.g_AccountID))
         'a buy was executed
         HttpContext.Current.Response.Write("<p><br><br>" & vbCrLf)
         HttpContext.Current.Response.Write("<font size='6'>Thank you for your purchase.</font></p> <br><br><p> An email will be sent" & vbCrLf)
         HttpContext.Current.Response.Write("that contains an itemized list of your items and shipping costs." & vbCrLf)
         HttpContext.Current.Response.Write("<br><br> If you do not recieve this email in the next 12 hours please call" & vbCrLf)
         HttpContext.Current.Response.Write("our customer support number." & vbCrLf)
         HttpContext.Current.Response.Write("</p>" & vbCrLf)
      Else
         'things are in the cart
         HttpContext.Current.Response.Write("		<form action='checkout.aspx' method='POST'>" & vbCrLf)
         HttpContext.Current.Response.Write("		<table border='0'>" & vbCrLf)
         HttpContext.Current.Response.Write("		<thead>" & vbCrLf)
         HttpContext.Current.Response.Write("			<tr><th>Quantity<th>Price<th>Sub-total<th>Description" & vbCrLf)
         HttpContext.Current.Response.Write("		<tbody>" & vbCrLf)
         total = 0
         Do Until rs.EOF
            quantity = gmRTL.Core.ConversionHelper.DBNullToValue(Of Double)(rs.Fields("Quantity").Value)
            price = gmRTL.Core.ConversionHelper.DBNullToValue(Of Double)(rs.Fields("Price").Value)
            subtotal = quantity * price
            HttpContext.Current.Response.Write("			<tr><td>" & quantity)
            HttpContext.Current.Response.Write("				<td>" & Strings.FormatCurrency(price,-1,TriState.UseDefault,TriState.UseDefault,TriState.UseDefault))
            HttpContext.Current.Response.Write("				<td>" & Strings.FormatCurrency(subtotal,-1,TriState.UseDefault,TriState.UseDefault,TriState.UseDefault))
            HttpContext.Current.Response.Write("				<td><a title='View this product' href='" & "ViewProduct.aspx?SKU=" & rs.Fields("SKU").Value & "'>" & HttpContext.Current.Server.HtmlEncode(Convert.ToString(rs.Fields("Description").Value)) & "</a></td>" & vbCrLf)
            rs.MoveNext()
            total = total + subtotal
         Loop
         HttpContext.Current.Response.Write("			<tr><td>&nbsp" & vbCrLf)
         HttpContext.Current.Response.Write("			<tr><td align='RIGHT' colspan='2'><b>Total:<td><b>" & Strings.FormatCurrency(total,-1,TriState.UseDefault,TriState.UseDefault,TriState.UseDefault) & "</b>" & vbCrLf)
         HttpContext.Current.Response.Write("			<tr><td colspan='2'><td colspan='2'><input type='SUBMIT' name='Action' value='Buy'>" & vbCrLf)
         HttpContext.Current.Response.Write("		</table>" & vbCrLf)
         HttpContext.Current.Response.Write("		</form>" & vbCrLf)
      End If
   End Sub
End Class
End Namespace
