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

namespace FMSWeb
{
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using VBNET=Microsoft.VisualBasic;
using gmRTL.Core;

public partial class _cart : System.Web.UI.Page
{
   public FMSWeb._t_head _t_head1 = null;
   public FMSWeb._t_begin_cart _t_begin_cart1 = null;
   public FMSWeb._t_end _t_end1 = null;
   public FMSWeb._t_begin _t_begin1 = null;

   protected void Page_Load(object sender, EventArgs e)
   {
      _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);
   }
   private FMStocks_Bus.Version bus = new FMStocks_Bus.Version();
   public void AddToShoppingCart()
   {
      string sku = "";
      sku = HttpContext.Current.Request["Add"];
      if (gmRTL.Core.InformationHelper.IsNumeric(sku))
      {
         _t_begin_cart1.cart.Add(_t_head1.g_AccountID.ToInt(),sku.ToInt());
      }
   }
   public void UpdateShoppingCart()
   {
      int i = 0;
      string sku = "";
      string quantity = "";
      i = 0;
      do
      {
         sku = HttpContext.Current.Request["SKU" + i];
         if (String.IsNullOrEmpty(sku))
         {
            break;  // Exit Do
         }
         quantity = HttpContext.Current.Request["Quantity" + i];
         if (!String.IsNullOrEmpty(quantity) && gmRTL.Core.InformationHelper.IsNumeric(quantity))
         {
            _t_begin_cart1.cart.SetQuantity(_t_head1.g_AccountID.ToInt(),sku.ToInt(),quantity.ToInt());
         }
         i = i + 1;
      } while(true);
   }
   public void EmitShoppingCart()
   {
      gmRTL.DataLib.SqlClient.Recordset rs = null;
      int i = 0;
      rs = _t_begin_cart1.cart.ListByAccount(_t_head1.g_AccountID.ToInt());
      if (rs.EOF)
      {
         HttpContext.Current.Response.Write("		You have no items in your shopping cart." + "\n");
      }
      else
      {
         HttpContext.Current.Response.Write("		<form action='cart.aspx' method='POST' onsubmit='return validate()'>" + "\n");
         HttpContext.Current.Response.Write("		<table border='0'>" + "\n");
         HttpContext.Current.Response.Write("		<thead>" + "\n");
         HttpContext.Current.Response.Write("			<tr><th>Quantity<th>Price<th>Description" + "\n");
         HttpContext.Current.Response.Write("		<tbody>" + "\n");
         i = 0;
         while (!(rs.EOF))
         {
            HttpContext.Current.Response.Write("			<tr><td><input onchange='changed=true' name='" + "Quantity" + i + "' value='" + rs.Fields["Quantity"].Value + "' size='8'>" + "\n");
            HttpContext.Current.Response.Write("					<input type='HIDDEN' name='" + "SKU" + i + "' value='" + rs.Fields["SKU"].Value + "'>" + "\n");
            HttpContext.Current.Response.Write("				<td>" + gmRTL.Core.FormatHelper.FormatCurrency(rs.Fields["Price"].Value,-1,gmRTL.Core.Enums.TriState.UseDefault,gmRTL.Core.Enums.TriState.UseDefault,gmRTL.Core.Enums.TriState.UseDefault));
            HttpContext.Current.Response.Write("				<td><a title='View this product' href='" + "ViewProduct.aspx?SKU=" + rs.Fields["SKU"].Value + "'>" + HttpContext.Current.Server.HtmlEncode(rs.Fields["Description"].Value.ToStr()) + "</a></td>" + "\n");
            rs.MoveNext();
            i = i + 1;
         }
         HttpContext.Current.Response.Write("		</table><br>" + "\n");
         HttpContext.Current.Response.Write("		<table border='0'>" + "\n");
         HttpContext.Current.Response.Write("			<tr><td colspan='4'><input type='SUBMIT' name='Change' value='Update Shopping Cart'>" + "\n");
         HttpContext.Current.Response.Write("				<input type='BUTTON' value='Proceed to Checkout'" + "\n");
         HttpContext.Current.Response.Write(" onclick='location.href=\"checkout.aspx\"'>" + "\n");
         HttpContext.Current.Response.Write("		</table>" + "\n");
         HttpContext.Current.Response.Write("		</form>" + "\n");
      }
   }
}
}
