asp.net c# shopping cart module

I have the code attached. It is my shopping cart (1 page) that I tried to get my small project done.
I would like to add Checkout button.

When it is clicked, it will do the following:

1. Add all of the selected products (qty, productname, description) into a database table (sql server). The table structure is exact same as datatable.

2. Email to someone with the selected data.

Thanks,
<%@ Page debug=true Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<html>
<head>
<title>Shopping Cart</title>
<script runat="server">
Dim objDT As System.Data.DataTable 
Dim objDR As System.Data.DataRow

Private Sub Page_Load(s As Object, e As EventArgs)
     If Not IsPostBack Then
          makeCart()
     End If
End Sub

    Function makeCart()
        
        objDT = New System.Data.DataTable("Cart")
        objDT.Columns.Add("ID", GetType(Integer))
        objDT.Columns("ID").AutoIncrement = True
        objDT.Columns("ID").AutoIncrementSeed = 1

        objDT.Columns.Add("Quantity", GetType(Integer))
        objDT.Columns.Add("Product", GetType(String))
        objDT.Columns.Add("Cost", GetType(Decimal))
 
        Session("Cart") = objDT
    End Function

Sub AddToCart(s As Object, e As EventArgs)
	objDT = Session("Cart")
	Dim Product = ddlProducts.SelectedItem.Text
	Dim blnMatch As Boolean = False

	For Each objDR In objDT.Rows
		If objDR("Product") = Product Then
			objDR("Quantity") += txtQuantity.Text
			blnMatch = True
			Exit For
		End If
	Next

	If Not blnMatch Then
	objDR = objDT.NewRow
	objDR("Quantity") = txtQuantity.Text
	objDR("Product") = ddlProducts.SelectedItem.Text
	objDR("Cost") = Decimal.Parse(ddlProducts.SelectedItem.Value)
	objDT.Rows.Add(objDR)
	End If
	Session("Cart") = objDT

	dg.DataSource = objDT
	dg.DataBind()
	
	lblTotal.Text = "$" & GetItemTotal()
End Sub

Function GetItemTotal() As Decimal
	Dim intCounter As Integer
	Dim decRunningTotal As Decimal
	
	For intCounter = 0 To objDT.Rows.Count - 1
		objDR = objDT.Rows(intCounter)
		decRunningTotal += (objDR("Cost") * objDR("Quantity"))
	Next
	
	Return decRunningTotal 
End Function

Sub Delete_Item(s As Object, e As DataGridCommandEventArgs)
     objDT = Session("Cart")
     objDT.Rows(e.Item.ItemIndex).Delete()
     Session("Cart") = objDT

     dg.DataSource = objDT
     dg.DataBind()

     lblTotal.Text = "$" & GetItemTotal()
End Sub

    
</script>

</head>
<body>
<form runat="server">
Product:<br>
<asp:DropDownList id=ddlProducts runat="server">
<asp:ListItem Value="4.99">Socks</asp:ListItem>
<asp:ListItem Value="34.99">Pants</asp:ListItem>
<asp:ListItem Value="14.99">Shirt</asp:ListItem>
<asp:ListItem Value="12.99">Hat</asp:ListItem>
</asp:DropDownList><br>
Quantity:<br>
<asp:textbox id="txtQuantity" runat="server" /><br><br>
<asp:Button id=btnAdd runat="server" Text="Add To Cart" onClick="AddToCart" /><br><br>
<asp:DataGrid id=dg runat="server" ondeletecommand="Delete_Item">
<columns>
<asp:buttoncolumn buttontype="LinkButton" commandname="Delete" text="Remove Item" />
</columns>
</asp:DataGrid>
<br><br>
Total: 
<asp:Label id=lblTotal runat="server" /><br /> 
</form>
</body>
</html>

Open in new window

Webboy2008Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Amandeep Singh BhullarCommented:
Since this is your Home work, so you should do it your self.

I have some suggestions for you:
1. Change the Database table structure. Added the UserID to it, to identify who ordered the products
2. To insert the DataTable into DB, loop throug it and insert data
3. Create a HTML structure and mail it to user. Check:
     http://www.codeproject.com/KB/aspnet/EmailApplication.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Webboy2008Author Commented:
I never said this is my home work? Are u ok?
0
Amandeep Singh BhullarCommented:
Apologies
Have you tried my suggestions
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.