5,401,186 members and growing! (18,424 online)
Email Password   helpLost your password?
Web Development » Applications & Tools » Applications     Intermediate

Shopping Cart using C#.NET, Web Forms and SQL Server

By Shruti Shrivastava

Shopping cart using C#.NET, Web Forms and SQL Server.
C#, Windows, .NET 1.1, .NET, ASP.NET, Visual Studio, VS.NET2003, Dev

Posted: 20 Apr 2004
Updated: 20 Apr 2004
Views: 162,592
Bookmarked: 82 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
41 votes for this Article.
Popularity: 5.63 Rating: 3.49 out of 5
9 votes, 22.0%
1
2 votes, 4.9%
2
3 votes, 7.3%
3
13 votes, 31.7%
4
14 votes, 34.1%
5

Introduction

This application is a Shopping Cart where users can select items and place an order. I have added the features of login, and adding new users if user does not exist. Validations are performed wherever needed like email format validation, zipcode etc.

Fig. 1

Database: For the purpose, I have used the NorthWind database and SQL Server.

The two main tables used are:

  1. Products table
  2. Order Details table.

I have used two classes:

public class CartRow
{
    public string id;
    public string name;
    public string price;
    public string items;
};
public class Cart
{
    public System.Collections.ArrayList list = new ArrayList(20);
};

The two main web-forms are Main.aspx and CheckOut.aspx. Main.aspx contains a grid showing all items present in the products table along with the price per unit and the quantity per unit. Fig 1 shows the Main.aspx page, where user can select items from the products grid (left). As he selects an item, it is added to his cart and the item is displayed in the right panel. The total price is displayed in the label above. As the user adds more items to his cart, the recalculated price is shown. Upon clicking the clear cart button, the cart gets empty.

If the user now wants to finalize the order and presses the CheckOut button, he is redirected to the Login.aspx page (Fig 2). I have set the default username as “user” for the sample and password is “u”.

Fig 2.

And finally, the user is asked to enter the Credit Card number, billing PIN code and his email address. It does the client side validations and then confirms the order placed by sending a mail to the user as shown in (Fig 3).

And the order is finalized. For more advanced shopping cart, this information plus the item information has to be stored in some database.

Fig 3

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Shruti Shrivastava


I have done Master’s in Computer Science. Also I am Microsoft Certified Application Developer (MCAD .NET). I am working with Visual C# .NET since two years. Currently I am looking for a job as C# Developer. You can reach me at shru27@hotmail.com.
Occupation: Web Developer
Location: United States United States

Other popular Applications & Tools articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 35 (Total in Forum: 35) (Refresh)FirstPrevNext
Subject  Author Date 
Generalcredit cardmemberlukyfaxy22:17 6 Jul '08  
GeneralDatabasememberali1dc12:09 5 Jul '08  
AnswerRe: Databasemembermghanim18:59 9 Jul '08  
QuestionVisual web developper 2008membercasper_mc8:41 22 Jun '08  
GeneralNo databasememberFrancis Belmin23:33 18 May '08  
Generalquestionmembernithydurai0:51 23 Apr '08  
GeneralNo database in the samplemembercyn85:23 22 Apr '08  
GeneralCan u gimme da solution?memberNYSMITH7:57 14 Mar '08  
GeneralSQL Server ErrormemberMember 47706112:23 17 Feb '08  
GeneralRe: SQL Server Error [modified]memberwsamuel22:26 29 Feb '08  
Generalxin chao cac banmembertutk1_phochome19:02 4 Jul '07  
GeneralRe: xin chao cac banmemberthanhducdn23:50 23 Sep '07  
GeneralAbout shopping Cartmember6:10 5 Feb '07  
GeneralRe: About shopping Cartmemberlukyfaxy22:18 6 Jul '08  
Questionadding extra details to each itemmemberGoFast12420:20 30 Oct '06  
Generalhow to make it work?memberarun_maddy1:04 20 Sep '06  
GeneralDo u have a 2.0 version of this cartmemberMilton KB3:03 8 Aug '06  
GeneralSQL Script - Creare TablesmemberGreenWays6:13 2 Jul '06  
GeneralGetCartmemberhtmlhenry7:34 3 Mar '06  
Questionthis code is not working ??membermrsalikahmed22:37 31 Jan '06  
Generalwhether to use datatable or arraylist or hashtablememberpatilana2:21 9 Jan '06  
AnswerUmer ! Use a DataTablememberMuhammad Umer Iqbal22:42 11 Jan '06  
GeneralHelp SQL Errormemberdrumboy196714:25 22 Nov '05  
GeneralRe: Help SQL Errormemberdrumboy196714:45 22 Nov '05  
QuestionRe: Help SQL ErrormembershewTos0:22 5 Jun '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 20 Apr 2004
Editor: Smitha Vijayan
Copyright 2004 by Shruti Shrivastava
Everything else Copyright © CodeProject, 1999-2008
Web07 | Advertise on the Code Project