<!--#INCLUDE FILE="adovbs.inc"-->
<% 
'===================================================
'(c) 2003-2004 efreedownloads.com
'===================================================
    Session( "empty" ) = False
    Session( "notequal" ) = False
    Session( "Fail" ) = False
    Session( "PC" ) = False
    Session( "continue" ) = False  

    Session( "notfull" ) = False
    Session( "email" ) = False     
    Session( "Forgot" ) = False
    Session( "Remember" ) = False

    Session( "empt" ) = False
    Session( "mail" ) = False
    Session( "noteq" ) = False
    Session( "RFail" ) = False
    Session( "RC" ) = False 
    Session( "exist" ) = False
    Session( "register" ) = False
    Session( "illegalusername" ) = False
    Session( "illegalpass" ) = False

   Session( "loginFailure" ) = False  
   Session( "out" ) = False

    Session( "khali" ) = False
    Session( "tapal" ) = False
    Session( "Contact" ) = False
    Session( "send" ) = False
    Session( "illegalF_Name" ) = False
    Session( "illegalL_Name" ) = False
    Session( "FNkhali" ) = False
    Session( "LNkhali" ) = False
    Session( "EMkhali" ) = False
    Session( "MBkhali" ) = False
    Session( "MSkhali" ) = False
    session("MesLen") = False  

session("FName")=""
session("LName")=""
session("St")=""
session("Cty")=""
session("Cntry")=""
session("HomePhone")=""
session("Mob")=""
session("Emailaddress")="" 
session("Mes")=""

session("User_Name")=""
session("Sec_Qsn")=""
session("answer")=""

session("finalcheck") = false  

  If Session( "login" ) = 1 Then
  sCartItemNums = session("cartitemnumarray")
  nCartItemQtys = session("cartitemqtyarray")
  nNumCartItems = ubound(sCartItemNums)
  
  IF nNumCartItems = 0 Then
  session("current") = True
  End If
 
  'Determine the mode of this page's operation. If we got here from a
  '  link that had a "mode" querystring of "add", mode is add:
  sMode = request.querystring("mode")

  'Or, we could have gotten here from a form:
  select case request.form("cmdSubmit")
    case "Proceed to Checkout"
      sMode = "checkout"
    case "Recalculate Order"
      sMode = "recalc"
    case "Continue Shopping"
      sMode = "continue"
  end select

  if sMode = "add" then
  session("current") = False
    nThisItemIndex = 0
    sItemNo = ucase(request.querystring("itemno"))
    if nNumCartItems > 0 then
      for i = 1 to nNumCartItems
        if ucase(scartitemnums(i)) = sItemNo then
          nThisItemIndex = i
          exit for
        end if
      next
    end if
    if nThisItemIndex = 0 then
      nThisItemIndex = nNumCartItems + 1
      redim Preserve sCartItemNums(nThisItemIndex)
      redim Preserve nCartItemQtys(nThisItemIndex)
      sCartItemNums(nThisItemIndex) = sItemNo
      nCartItemQtys(nThisItemIndex) = 1
    else
      nCartItemQtys(nThisItemIndex) = nCartItemQtys(nThisItemIndex) + 1
    end if
    session("cartitemnumarray") = sCartItemNums
    session("cartitemqtyarray") = nCartItemQtys
    nNumCartItems = ubound(sCartItemNums)
  end if

  if sMode = "recalc" or sMode = "checkout" or sMode = "continue" then
    session("current") = False 
    nTotalItems = 0   
    for i = 1 to nNumCartItems
    

      nThisQty = int(request.form("txtItemQty" & i))
      nTotalItems = nTotalItems + nThisQty
      nCartItemQtys(i) = nThisQty
    next

    If nTotalItems = 0 Then
    session("current") = true
    End If 
    session("cartitemnumarray") = sCartItemNums
    session("cartitemqtyarray") = nCartItemQtys
  end if

  if sMode = "checkout" then
  
session("finalcheck") = true  

  end if


  'Move to another page based on mode.
  '  If mode is "add" or "recalc", we stay here.
  '  If mode is "continue", we move back to the main page so the user
  '    can shop more.
  '  If mode is "checkout", we stay here but change the mode th
  select case sMode
    case "continue"
    
    session("current") = False 
    nTotalItems = 0   
    for i = 1 to nNumCartItems
      nThisQty = int(request.form("txtItemQty" & i))
      nTotalItems = nTotalItems + nThisQty
      nCartItemQtys(i) = nThisQty
      
    next
    If nTotalItems = 0 Then
    session("current") = true
    End If 
    session("cartitemnumarray") = sCartItemNums
    session("cartitemqtyarray") = nCartItemQtys
    response.redirect("default.asp")
  end select

set db2con = server.createobject("adodb.connection")
constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("./db/project_database.mdb")& ";"
db2con.open constr

  if sMode = "checkout" then
    sPageHead = "Online Book Store Checkout"
    sPageCaption = "Checkout"
  else
    sPageHead = "Online Book Store Shopping Cart"
    sPageCaption = "Shopping Cart"
  end if

%>
<html>

<!--#INCLUDE FILE="header.inc"-->

<br>
<font face="Verdana,Arial" color="#008000" size="-1">
<% if sMode = "checkout" then %>
<form action="submitorder.asp" method="POST">
<% else %>
<form action="shopcart.asp" method="POST">
<% end if %>
<font size=2 color="#ff0000"><center><b>

<%
  
  if session("current") = true then
   
    response.write "Your shopping cart is empty.<br>"
    response.write "<br>"
    response.write "<br>"
    response.write "<U><font face='Verdana, Arial' color='#0000ff' size='4'>"
  response.write "<a href='default.asp"
  response.write "'>"
  response.write "Continue Shopping</font></U></a>"
  response.write "<br>"
  response.write "<br>"
 response.write "<br>"
response.write "<br>"
response.write "<br>"
response.write "<br>"
response.write "<br>"
response.write "<br>"
response.write "<br>"
  response.write vbcrlf
  else
    if sMode = "checkout" then

%>
Please provide the following information and click the "Submit Order" button to submit order.
<br><br>
</b></center></font>


<table align="center" border="0">
  <tr bgcolor="#0000ff">
    <B><td colspan="2" align="center"><font color="#FFFFFF" face="Verdana,Arial" size="3">
      Customer Information</td></B>
  </tr>
  <tr>
    <td align="right"><font face="Verdana,Arial" size="-1">Full Name:</td>
    <td><font face="Verdana,Arial" size="-1">
      <input type="Text" name="txtCustomerName" size="30" maxlength="40">
      </td>
  </tr>
  <tr>
    <td align="right"><font face="Verdana,Arial" size="-1">Address:</td>
    <td><font face="Verdana,Arial" size="-1">
      <input type="Text" name="txtAddress" size="30" maxlength="40"></td>
  </tr>
  <tr>
    <td align="right"><font face="Verdana,Arial" size="-1">
      City/State/ZIP:</td>
    <td><font face="Verdana,Arial" size="-1">
      <input type="Text" name="txtCity" size="15" maxlength="15">
      <input type="Text" name="txtState" size="15" maxlength="15">
      <input type="Text" name="txtZIP" size="7" maxlength="7"></td>
  </tr>
  <tr>
    <td align="right"><font face="Verdana,Arial" size="-1">
      Daytime Phone:</td>
    <td><font face="Verdana,Arial" size="-1">
      <input type="Text" name="txtPhone" size="15" maxlength="25"></td>
  </tr>
  <tr bgcolor="#0000ff">
    <B><td colspan="2" align="center"><font color="#FFFFFF" face="Verdana,Arial" size="3">
      Shipping Information(If different from Customer's Information)</td></B>
  </tr>
  <tr>
    <td align="right"><font face="Verdana,Arial" size="-1">Full Name:</td>
    <td><font face="Verdana,Arial" size="-1">
      <input type="Text" name="shipCustomerName" size="30" maxlength="40">
      </td>
  </tr>
  <tr>
    <td align="right"><font face="Verdana,Arial" size="-1">Address:</td>
    <td><font face="Verdana,Arial" size="-1">
      <input type="Text" name="shipAddress" size="30" maxlength="40"></td>
  </tr>
  <tr>
    <td align="right"><font face="Verdana,Arial" size="-1">
      City/State/ZIP:</td>
    <td><font face="Verdana,Arial" size="-1">
      <input type="Text" name="shipCity" size="15" maxlength="15">
      <input type="Text" name="shipState" size="15" maxlength="15">
      <input type="Text" name="shipZIP" size="7" maxlength="7"></td>
  </tr>
  <tr>
    <td align="right"><font face="Verdana,Arial" size="-1">
      Daytime Phone:</td>
    <td><font face="Verdana,Arial" size="-1">
      <input type="Text" name="shipPhone" size="15" maxlength="25"></td>
  </tr>
  <tr bgcolor="#0000ff">
    <B><td colspan="2" align="center"><font color="#FFFFFF" face="Verdana,Arial" size="3">
      Payment Information</td></B>
  </tr>
  <tr>
    <td align="right"><font face="Verdana,Arial" size="-1">
      Payment Method:</td>
    <td><font face="Verdana,Arial" size="-1">
      <input type="Radio" name="optPaymentType" value="visa">
        Visa&nbsp;
      <input type="Radio" name="optPaymentType" value="mastercard">
        Mastercard&nbsp;
      <input type="Radio" name="optPaymentType" value="americanexpress">
        American Express</font>
    </td>
  </tr>
  <tr>
    <td align="right"><font face="Verdana,Arial" size="-1">
      Account Number:</td>
    <td><font face="Verdana,Arial" size="-1">
      <input type="Text" name="txtAcctNo" size="20" maxlength="20"></td>
  </tr>
  <tr>
    <td align="right"><font face="Verdana,Arial" size="-1">
      Expiration (MM/YYYY):</td>
    <td><font face="Verdana,Arial" size="-1">
      <input type="Text" name="txtExpDate" size="7" maxlength="7"></td>
  </tr>
</table>
<%
    else
    
  response.write "Hint: To remove Items from your shopping cart, Enter zero(0) in respective quantity text field"
  response.write "<br>"
  response.write "<br>"
  response.write "<br>"
  response.write "Your shopping cart currently contains these items:"
       

    end if
%>
<br><br>
<table align="center" border="0">
  <tr bgcolor="#0000ff">
    <th><font face="Verdana,Arial" color="#ffffff" size="-1">
      Quantity</font></td>
    <th><font face="Verdana,Arial" color="#ffffff" size="-1">
      Item No.</font></td>
    <th><font face="Verdana,Arial" color="#ffffff" size="-1">
      Item Name</font></td>
    <th><font face="Verdana,Arial" color="#ffffff" size="-1">
      Price</font></td>
    <th><font face="Verdana,Arial" color="#ffffff" size="-1">
      Extension</font></td>
  </tr>
<%
  Quantity = 0
  cSubTotal = 0
  nNumItems = 0
  for i = 1 to nNumCartItems
confirm = Request.Form("selected" & CStr(i))
      Set rsProducts = Server.CreateObject("ADODB.Recordset")
    sSQL = "SELECT * FROM products WHERE itemproductnumber = '" & sCartItemNums(i) & "'"
    rsProducts.open sSQL, db2con, adopenstatic, adlockpessimistic, adcmdtext
sTemp = "<input type='Text' name='txtItemQty" & i & "' value='" & _
    nCartItemQtys(i) & "' MAXLENGTH=3 size='3'>"
  Quantity = nCartItemQtys(i)
  nNumItems = nNumItems + nCartItemQtys(i)



If Quantity > 0 Then

%>
  <tr bgcolor="#99ccff">
<%

  %>
    <td align="center">
      <font face="Verdana,Arial" color="#000000" size="-1">
      <% = sTemp %></font></td>
    <td align="center">
      <font face="Verdana,Arial" color="#000000" size="-1">
      <% = rsProducts("itemproductnumber") %></font></td>
    <td><font face="Verdana,Arial" color="#000000" size="-1">
      <% = rsProducts("itemname") %></font></td>
<%
  if rsProducts("ItemSalePrice") > 0 then
    cPrice = rsProducts("ItemSalePrice")
  else
    cPrice = rsProducts("ItemRegularPrice")
  end if
%>
    <td align="center">
      <font face="Verdana,Arial" color="#000000" size="-1">
      <% = formatcurrency(cPrice) %></font></td>
<%
  cExtension = nCartItemQtys(i) * cPrice
  cSubTotal = cSubTotal + cExtension
%>
    <td align="right">
      <font face="Verdana,Arial" color="#000000" size="-1">
      <% = formatcurrency(cExtension) %></font></td>
  </tr>
<% 
End If
next %>
  <tr bgcolor="#c5c5c5">
    <td align="center" colspan="4">
      <font face="Verdana,Arial" size="-1">Subtotal</font></td>
    <td align="right"><font face="Verdana,Arial" size="-1">
      <% = formatcurrency(cSubTotal) %></font></td>
  </tr>
<% cShipping = 4.50 + (1.25 * nNumItems) %>
  <tr bgcolor="#c5c5c5">
    <td align="center" colspan="4">
      <font face="Verdana,Arial" size="-1">Shipping & Handling</font></td>
    <td align="right"><font face="Verdana,Arial" size="-1">
      <% = formatcurrency(cShipping) %></font></td>
  </tr>
<% cTotal = cSubTotal + cShipping %>
  <tr bgcolor="#0000ff">
    <td align="center" colspan = "4">
      <font face="Verdana,Arial" color="#ffffff" size="-1">Grand Total</font></td>
    <td align="right"><font face="Verdana,Arial" color="#ffffff" size="-1">
      <% = formatcurrency(cTotal) %></font></td>
  </tr>
</table>
<br><div align="center">
<%
if Not session("finalcheck") = true then
%>
<input type="Submit" name="cmdSubmit" value="Continue Shopping">
<input type="Submit" name="cmdSubmit" value="Recalculate Order">
<br><br>
<% end if %>
<% if sMode = "checkout" then %>
<input type="Submit" name="cmdSubmit" value="Submit Order">
<% else %>
<input type="Submit" name="cmdSubmit" value="Proceed to Checkout">
<% end if %>
</div></form>
<% end if 
Else
Call Response.Redirect( "loginhere.asp" )
End If
%>

<!--#INCLUDE FILE="footer.inc"-->
</html>





