Click here to Skip to main content
14,360,820 members

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

Rate this:
4.44 (61 votes)
Please Sign up or sign in to vote.
4.44 (61 votes)
20 Apr 2004
Shopping cart using C#.NET, Web Forms and SQL Server.

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

Image 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.

Image 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

Image 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

Share

About the Author

ShruSri
Web Developer
United States United States
No Biography provided

Comments and Discussions

 
GeneralSQL Server Error Pin
Member 477061117-Feb-08 2:23
memberMember 477061117-Feb-08 2:23 
GeneralRe: SQL Server Error [modified] Pin
wsamuel29-Feb-08 22:26
memberwsamuel29-Feb-08 22:26 
Generalxin chao cac ban Pin
tutk1_phochome4-Jul-07 19:02
membertutk1_phochome4-Jul-07 19:02 
GeneralRe: xin chao cac ban Pin
thanhducdn23-Sep-07 23:50
memberthanhducdn23-Sep-07 23:50 
GeneralAbout shopping Cart Pin
Member 33411835-Feb-07 6:10
memberMember 33411835-Feb-07 6:10 
GeneralRe: About shopping Cart Pin
lukyfaxy6-Jul-08 22:18
memberlukyfaxy6-Jul-08 22:18 
Questionadding extra details to each item Pin
GoFast12430-Oct-06 20:20
memberGoFast12430-Oct-06 20:20 
GeneralDo u have a 2.0 version of this cart Pin
Milton Karimbekallil8-Aug-06 3:03
memberMilton Karimbekallil8-Aug-06 3:03 
Do u have a 2.0 version of this cart
GeneralSQL Script - Creare Tables Pin
GreenWays2-Jul-06 6:13
memberGreenWays2-Jul-06 6:13 
GeneralGetCart Pin
htmlhenry3-Mar-06 7:34
memberhtmlhenry3-Mar-06 7:34 
Questionthis code is not working ?? Pin
mrsalikahmed31-Jan-06 22:37
membermrsalikahmed31-Jan-06 22:37 
Generalwhether to use datatable or arraylist or hashtable Pin
patilana9-Jan-06 2:21
memberpatilana9-Jan-06 2:21 
AnswerUmer ! Use a DataTable Pin
Muhammad Umer Iqbal11-Jan-06 22:42
memberMuhammad Umer Iqbal11-Jan-06 22:42 
GeneralHelp SQL Error Pin
drumboy196722-Nov-05 14:25
memberdrumboy196722-Nov-05 14:25 
GeneralRe: Help SQL Error Pin
drumboy196722-Nov-05 14:45
memberdrumboy196722-Nov-05 14:45 
QuestionRe: Help SQL Error Pin
shewTos5-Jun-07 0:22
membershewTos5-Jun-07 0:22 
GeneralRe: Help SQL Error Pin
patilana9-Jan-06 2:13
memberpatilana9-Jan-06 2:13 
GeneralGood tutorials Pin
sanchayan_rohan17-Oct-05 0:48
membersanchayan_rohan17-Oct-05 0:48 
Generalusing textboxes Pin
rooker000715-Sep-05 16:24
memberrooker000715-Sep-05 16:24 
QuestionRunning the sample Pin
Rookie10-Sep-05 15:06
memberRookie10-Sep-05 15:06 
QuestionWhat Version of Visual Studio .Net Pin
jcs20044-May-05 5:07
memberjcs20044-May-05 5:07 
AnswerRe: What Version of Visual Studio .Net Pin
NewbZ29-Mar-07 3:49
memberNewbZ29-Mar-07 3:49 
Generalgeneral questions Pin
Member 152905318-Nov-04 10:38
memberMember 152905318-Nov-04 10:38 
GeneralRe: general questions Pin
DimondWolfe18-Jul-05 20:29
memberDimondWolfe18-Jul-05 20:29 
GeneralRe: general questions Pin
MHBL1220-Nov-06 18:10
memberMHBL1220-Nov-06 18:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Article
Posted 20 Apr 2004

Stats

587.6K views
35.4K downloads
152 bookmarked