PDA

View Full Version : Ecommerce Using ASP


mel
05-31-2003, 05:14 AM
Hi there.. im new here... im Romel.. just call me mel... any 1 can help me... about ecommerce using asp... can any 1 give me a tutorial of that... i need it badly... :(

Please.....

chinnababu
05-31-2003, 02:23 PM
If this is what you are looking for,
I can help and will forward the code.
Check the following and let me know.

http://www.chinnababu.net/css/default.asp

http://www.chinnababu.net/css/addNewItems.asp

sunpost
05-31-2003, 05:44 PM
here is a link to a free cart that might help too...
http://www.comersus.com/

mel
06-02-2003, 01:04 AM
Yes Chinnababu i need that thing and also... the proccessing of the payments... thanks a lot

chinnababu
06-02-2003, 06:31 PM
default.asp
addNewItems.asp
checkOut.asp

code follows.
-----------------------------------------
default.asp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Shopping Cart - Online Shopping Center</title>
<link rel="STYLESHEET" type="text/css" href="../css/cbStyles.css">
</head>
<body bgcolor="#faebd7">
<%
set cn = server.createObject("ADODB.Connection")
cn.open "dsn=northwind"
%>
<%
sqlGetData = "select * from shop order by itemno"
set rs = server.createObject("ADODB.RecordSet")
rs.open sqlGetData, cn
response.write "<br><br>"
'response.write sqlGetData
%>
<div align="center">
<font class="bigheaderlink">Shopping Cart </font>
<br>
<font class="sub">Item Available for Online Shopping</font>
<br>
<br>
<table cellpadding="0" cellspacing="0" width="500" border="1">
<tr height="20" bgcolor="#FFFF00">
<td width="" nowrap><font class="txt">&nbsp;Item Id</font></td>
<td width="" nowrap><font class="txt">&nbsp;Item No</font></td>
<td width="" nowrap><font class="txt">&nbsp;Item</font></td>
<td width="" nowrap><font class="txt">&nbsp;Price</font></td>
<td width="" nowrap><font class="txt">&nbsp;Quantity</font></td>
</tr>
<%
do until rs.eof
%>
<form action='default.asp?action=add&ITEMID=<%=rs("ITEMID") %>' method="post">
<tr height="" bgcolor="">
<td nowrap width=""><font class="txt">&nbsp;<input name="ITEMID" type="text" value='<%= ucase(rs("ITEMID")) %>' size="20" readonly></font></td>
<td nowrap width=""><font class="txt">&nbsp;<input name="ITEMNO" type="text" value='<%= ucase(rs("ITEMNO")) %>' size="20" readonly></font></td>
<td nowrap width=""><font class="txt">&nbsp;<input name="ITEM" type="text" value='<%= ucase(rs("ITEM")) %>' size="30" readonly></font></td>
<td nowrap width=""><font class="txt">&nbsp;<input name="PRICE" align="right" type="text" value='<%= formatNumber(rs("PRICE"),2) %>' size="20" readonly></td>
<td nowrap width="">
<input name="quantity" type="text" value="1" size="5">
<input type="submit" value="add">
</font>
</td>
</tr>

</form>
<%
rs.movenext
loop
%>
</table>
<br>
<% if request.querystring("action") = "add" then %>

<% ITEMID = request.querystring("ITEMID") %>
<% 'response.write "<br>Item ID - " & ITEMID %>

<% ITEMNO = request.form("ITEMNO") %>
<% 'response.write "<br>Item No - " & ITEMNO %>

<% ITEM = request.form("ITEM") %>
<% 'response.write "<br>Item - " & ITEM %>

<% PRICE = request.form("PRICE") %>
<% 'response.write "<br>Price - " & PRICE %>

<% QUANTITY = request.form("QUANTITY") %>
<% 'response.write "<br>Quantity - " & QUANTITY %>

<%TOTALPRICE = QUANTITY * PRICE %>
<% 'response.write "<br>Total Price - " & TOTALPRICE %>

<%
set rs = server.createObject("ADODB.RecordSet")
sql="insert into SHOP2 (ITEMID,ITEMNO,ITEM,PRICE,QUANTITY,TOTALPRICE) values ('" &ITEMID & "','" & ucase(ITEMNO) & "','" & ucase(ITEM) & "','" & PRICE & "','" & QUANTITY & "'," & TOTALPRICE & ")"
rs.open sql, cn
'response.write sql
%>
<div align="center">

<% if errnumber <> 0 then %>
<b>Error. New Item Did Not Added.</b>
<% else%>
<b>New Item Added.</b><br>
<hr size="1" width="100%">
<a href="checkOut.asp">Check Out</a>
<% end if %>
<br>
<% %>
<% end if
%>
</div>
</body>
</html>
*********************
addNewItems.asp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Shopping Cart - New Items</title>
<link rel="STYLESHEET" type="text/css" href="../css/cbStyles.css">
<script language=JavaScript>
<!--
function validate() {
if((document.addNewItems.itemno.value==""))
{
alert("Item No Cannot Be Blank. Try Again.")
return false
}
if((document.addNewItems.item.value==""))
{
alert("Item Cannot Be Blank. Try Again.")
return false
}
if((document.addNewItems.price.value==""))
{
alert("Price Cannot Be Blank. Try Again.")
return false
}
}
//-->
</script>
</head>
<body bgcolor="#faebd7">
<%
set cn = server.createObject("ADODB.Connection")
cn.open "dsn=northwind"
%>
<div align="center">
<% if request.form("item") = "" then %>
<br>
<br>
<font class="bigheaderlink">Shopping Cart </font>
<br>
<font class="sub">Add New Item</font>
<form action="addNewItems.asp" method="post" name="addNewItems" onSubmit="return validate()">
<table cellpadding="3" cellspacing="1" border="10" width="40%">
<tr>
<td>&nbsp;Item No</td>
<td>&nbsp;<input type="text" name="itemno" size="0" maxlength="30"></td>
</tr>
<tr>
<td>&nbsp;Item</td>
<td>&nbsp;<input type="text" name="item" size="0" maxlength="30"></td>
</tr>
<tr>
<td>&nbsp;Price</td>
<td>&nbsp;<input type="text" name="price" value="" size="0" maxlength="30"></td>
</tr>
<tr>
<td>&nbsp;Photo Name</td>
<td>&nbsp;<input type="text" name="photoName" value="" size="0" maxlength="30"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="reset" name="reset" value="Reset">&nbsp;<input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form>
<% else %>
<%
set cn = server.createObject("ADODB.Connection")
cn.open "dsn=northwind"
%>
<% itemno = request.form("itemno") %>
<% item = request.form("item") %>
<% price = request.form("price") %>
<% photoName = request.form("photoName") %>
<% response.write "<br>Item No - " & itemno %>
<% response.write "<br>Item - " & item %>
<% response.write "<br>Price - " & price %>
<% response.write "<br>Photo Name - " & photoName %>
<%
set rs = server.createObject("ADODB.RecordSet")
sql="insert into SHOP (itemno,item,price,photoName) values ('" & itemno & "','" & item & "'," & price & ",'" & photoName & "')"
rs.open sql, cn
'response.write sql
%>
<div align="center">
<hr size="1" width="100%">
<% if errnumber <> 0 then %>
<b>Error. New Item Did Not Added.</b>
<% else%>
<b>New Item Added.</b><br>
<a href="addNewItems.asp">Add</a>&nbsp;&nbsp;&nbsp;<a href="default.asp">Shop</a>
<% end if %>
</div>
<% end if %>
</body>
</html>
************************************

checkout.asp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Shopping Cart - Online Shopping Center</title>
<link rel="STYLESHEET" type="text/css" href="../css/cbStyles.css">
</head>
<body bgcolor="#faebd7">
<%
set cn = server.createObject("ADODB.Connection")
cn.open "dsn=northwind"
%>
<%
sqlGetData = "select * from shop2 order by item"
set rs = server.createObject("ADODB.RecordSet")
rs.open sqlGetData, cn
response.write "<br><br>"
'response.write sqlGetData
%>
<%
Set RS1 = Server.CreateObject("ADODB.Recordset")
sSQL1 = "SELECT SUM(totalprice) AS checkAmountSubTotal FROM shop2"
Set RS1 = cn.Execute(sSQL1)
checkAmountSubTotal = RS1(0)
'Response.Write ("checkAmountSubTotal = " & FormatCurrency(checkAmountSubTotal))
%>
<div align="center">
<font class="bigheaderlink">Shopping Cart </font>
<br>
<font class="sub">Check Out for Online Shopping</font>
<br>
<table cellpadding="0" cellspacing="0" width="500" border="1">
<tr height="20" bgcolor="#FFFF00">
<td width="" nowrap><font class="txt">&nbsp;Item ID&nbsp;</font></td>
<td width="" nowrap><font class="txt">&nbsp;Item No&nbsp;</font></td>
<td width="" nowrap><font class="txt">&nbsp;Item&nbsp;</font></td>
<td width="" nowrap><font class="txt">&nbsp;Quantity&nbsp;</font></td>
<td width="" nowrap align="right"><font class="txt">&nbsp;Total Price&nbsp;</font></td>
</tr>
<%
dim total
total = formatNumber(("0"),2)
do until rs.eof
%>
<tr height="" bgcolor="">
<td nowrap width=""><font class="txt">&nbsp;<%= rs("ITEMID") %>&nbsp;</font></td>
<td nowrap width=""><font class="txt">&nbsp;<%= rs("ITEMNO") %>&nbsp;</font></td>
<td nowrap width=""><font class="txt">&nbsp;<%= ucase(rs("ITEM")) %>&nbsp;</font></td>
<td nowrap width=""><font class="txt">&nbsp;<%= rs("QUANTITY") %>&nbsp;</font></td>
<td nowrap width="" align="right"><font class="txt">&nbsp;<%= formatNumber(rs("TOTALPRICE"),2) %>&nbsp;</font></td>
</tr>
<%
total = total + rs("TOTALPRICE")
rs.movenext
loop
%>
<tr height="" bgcolor="#00ff00">
<td colspan="4" nowrap width="" align="left"><font class="txt">&nbsp;Total&nbsp;</font></td>
<td colspan="" nowrap width="" align="right"><font class="txt">&nbsp;<%= FormatCurrency(RS1("checkAmountSubTotal")) %>&nbsp;</font></td>
</tr>
</table>
<br>
<table>
<tr>
<td><form><input type=submit value="Shop" onClick="this.form.action='default.asp';"> </form></td>
<td><form><input type=submit value="Payments" onClick="javascript:alert('This is demo purpose only. For real application, please contact.');"></form></td>
</tr>
</table>
</div>
</body>
</html>
***************************************