Click here to Skip to main content
15,888,610 members
Articles / Web Development / ASP.NET
Article

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

Rate me:
Please Sign up or sign in to vote.
4.41/5 (62 votes)
20 Apr 20041 min read 687.8K   36.2K   153   164
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:

C#
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


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalxat chat siteleri - xat sohbet sitesi xat Pin
sohbet2-Jul-10 3:26
sohbet2-Jul-10 3:26 
GeneralMy vote of 1 Pin
cyberboy_mann1-Jul-10 21:35
cyberboy_mann1-Jul-10 21:35 
GeneralIs it possible to convert this app to use it without web interface Pin
DamiRocK6-May-10 10:39
DamiRocK6-May-10 10:39 
Generalpls database Pin
langkhach_codon13-Apr-10 5:50
langkhach_codon13-Apr-10 5:50 
GeneralRe: pls database Pin
DGamer2-Nov-10 12:03
DGamer2-Nov-10 12:03 
GeneralRe: pls database Pin
DGamer2-Nov-10 12:25
DGamer2-Nov-10 12:25 
Generalrequesting database Pin
Member 39167875-Apr-10 5:06
Member 39167875-Apr-10 5:06 
GeneralRe: requesting database Pin
DGamer2-Nov-10 12:25
DGamer2-Nov-10 12:25 
Generaldatabase of shopping cart Pin
bmnot22-Feb-10 4:06
bmnot22-Feb-10 4:06 
Generalplase send me the shopping cart database... Pin
akshi36421-Feb-10 0:07
akshi36421-Feb-10 0:07 
Generalneed database... Pin
anishkumarv31-Jan-10 10:25
anishkumarv31-Jan-10 10:25 
Generalcould you send me the database also. many thanks. Pin
BigMice30-Jan-10 21:17
BigMice30-Jan-10 21:17 
Generalxcellent demo! Pin
touhid29-Jan-10 11:12
touhid29-Jan-10 11:12 
Generalhi guy Pin
sruchit8-Jan-10 9:07
sruchit8-Jan-10 9:07 
GeneralHi Pin
cathli4-Jan-10 19:24
cathli4-Jan-10 19:24 
GeneralDatabase Pin
Adam5734-Jan-10 18:38
Adam5734-Jan-10 18:38 
Generalhelp me soon please shopping cart Pin
fereshhte3-Jan-10 23:38
fereshhte3-Jan-10 23:38 
GeneralNo Database in the zip folder. Pin
kishore30916-Dec-09 18:31
kishore30916-Dec-09 18:31 
GeneralDatabase Pin
koo kok seng14-Dec-09 19:59
koo kok seng14-Dec-09 19:59 
GeneralThank you for sending database Pin
Nguyen Hoang Thinh8-Dec-09 3:51
Nguyen Hoang Thinh8-Dec-09 3:51 
GeneralFOR DATABASE Pin
hardesh sharma6-Dec-09 22:39
hardesh sharma6-Dec-09 22:39 
QuestionCan u send me the Database Pin
Soumitra 19805-Dec-09 0:39
Soumitra 19805-Dec-09 0:39 
GeneralDatabase Pin
Dipak mahadik28-Nov-09 0:32
Dipak mahadik28-Nov-09 0:32 
Generaldatabase asap Pin
sweetybhanu15-Nov-09 22:12
sweetybhanu15-Nov-09 22:12 
GeneralVery good example Pin
Lajkó Sándor9-Jul-09 4:41
Lajkó Sándor9-Jul-09 4:41 

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.