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

Imports System.Web
NameSpace FMSWeb
Public Partial class _cart : 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 AddToShoppingCart()
      Dim sku As String = ""
      sku = HttpContext.Current.Request("Add")
      If (gmRTL.Core.InformationHelper.IsNumeric(sku)) Then
         _t_begin_cart1.cart.Add(CInt(_t_head1.g_AccountID),CInt(sku))
      End If
   End Sub
   Public Sub UpdateShoppingCart()
      Dim i As Integer = 0
      Dim sku As String = ""
      Dim quantity As String = ""
      i = 0
      Do
         sku = HttpContext.Current.Request("SKU" & i)
         If (String.IsNullOrEmpty(sku)) Then
            Exit Do
         End If
         quantity = HttpContext.Current.Request("Quantity" & i)
         If (Not String.IsNullOrEmpty(quantity) And gmRTL.Core.InformationHelper.IsNumeric(quantity)) Then
            _t_begin_cart1.cart.SetQuantity(CInt(_t_head1.g_AccountID),CInt(sku),CInt(quantity))
         End If
         i = i + 1
      Loop
   End Sub
   Public Sub EmitShoppingCart()
      Dim rs As gmRTL.DataLib.SqlClient.Recordset = Nothing
      Dim i As Integer = 0
      rs = _t_begin_cart1.cart.ListByAccount(CInt(_t_head1.g_AccountID))
      If (rs.EOF) Then
         HttpContext.Current.Response.Write("		You have no items in your shopping cart." & vbCrLf)
      Else
         HttpContext.Current.Response.Write("		<form action='cart.aspx' method='POST' onsubmit='return validate()'>" & 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>Description" & vbCrLf)
         HttpContext.Current.Response.Write("		<tbody>" & vbCrLf)
         i = 0
         Do Until rs.EOF
            HttpContext.Current.Response.Write("			<tr><td><input onchange='changed=true' name='" & "Quantity" & i & "' value='" & rs.Fields("Quantity").Value & "' size='8'>" & vbCrLf)
            HttpContext.Current.Response.Write("					<input type='HIDDEN' name='" & "SKU" & i & "' value='" & rs.Fields("SKU").Value & "'>" & vbCrLf)
            HttpContext.Current.Response.Write("				<td>" & Strings.FormatCurrency(rs.Fields("Price").Value,-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()
            i = i + 1
         Loop
         HttpContext.Current.Response.Write("		</table><br>" & vbCrLf)
         HttpContext.Current.Response.Write("		<table border='0'>" & vbCrLf)
         HttpContext.Current.Response.Write("			<tr><td colspan='4'><input type='SUBMIT' name='Change' value='Update Shopping Cart'>" & vbCrLf)
         HttpContext.Current.Response.Write("				<input type='BUTTON' value='Proceed to Checkout'" & vbCrLf)
         HttpContext.Current.Response.Write(" onclick='location.href=""checkout.aspx""'>" & vbCrLf)
         HttpContext.Current.Response.Write("		</table>" & vbCrLf)
         HttpContext.Current.Response.Write("		</form>" & vbCrLf)
      End If
   End Sub
End Class
End Namespace
