Click here to Skip to main content
6,596,602 members and growing! (22,492 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, ASP.NET, VS.NET2003, Dev
Posted:20 Apr 2004
Views:212,426
Bookmarked:113 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
49 votes for this article.
Popularity: 6.09 Rating: 3.60 out of 5
10 votes, 20.4%
1
2 votes, 4.1%
2
3 votes, 6.1%
3
14 votes, 28.6%
4
20 votes, 40.8%
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


Member
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
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 42 (Total in Forum: 42) (Refresh)FirstPrevNext
Generaldatabase Pinmembertwinvaibhav0:20 29 Oct '09  
GeneralVery good example PinmemberLajkó Sándor5:41 9 Jul '09  
GeneralMy vote of 1 Pinmembersham12345200716:55 1 Jul '09  
Generaldatabase Pinmembertaro800:53 25 Jun '09  
GeneralNo database Pinmemberakrd8623:20 22 Apr '09  
GeneralDatabase Pinmembersubrata10011:05 30 Mar '09  
Questionno database Pinmemberpatalport19:29 25 Mar '09  
Generalcredit card Pinmemberlukyfaxy22:17 6 Jul '08  
GeneralDatabase Pinmemberali1dc12:09 5 Jul '08  
AnswerRe: Database Pinmembermghanim18:59 9 Jul '08  
QuestionVisual web developper 2008 Pinmembercasper_mc8:41 22 Jun '08  
GeneralNo database PinmemberFrancis Belmin23:33 18 May '08  
Generalquestion Pinmembernithydurai0:51 23 Apr '08  
GeneralNo database in the sample Pinmembercyn85:23 22 Apr '08  
GeneralCan u gimme da solution? PinmemberNYSMITH7:57 14 Mar '08  
GeneralSQL Server Error PinmemberMember 47706112:23 17 Feb '08  
GeneralRe: SQL Server Error [modified] Pinmemberwsamuel22:26 29 Feb '08  
Generalxin chao cac ban Pinmembertutk1_phochome19:02 4 Jul '07  
GeneralRe: xin chao cac ban Pinmemberthanhducdn23:50 23 Sep '07  
GeneralAbout shopping Cart Pinmember6:10 5 Feb '07  
GeneralRe: About shopping Cart Pinmemberlukyfaxy22:18 6 Jul '08  
Questionadding extra details to each item PinmemberGoFast12420:20 30 Oct '06  
Generalhow to make it work? Pinmemberarun_maddy1:04 20 Sep '06  
GeneralDo u have a 2.0 version of this cart PinmemberMilton KB3:03 8 Aug '06  
GeneralSQL Script - Creare Tables PinmemberGreenWays6:13 2 Jul '06  

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-2009
Web09 | Advertise on the Code Project