Click here to Skip to main content
15,868,236 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 682.8K   36.1K   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

 
QuestionDatabase Script or file. Pin
David E Vera F15-Dec-19 16:18
David E Vera F15-Dec-19 16:18 
QuestionPlease send me database Pin
Member 1437625931-May-19 8:32
Member 1437625931-May-19 8:32 
GeneralPlease send me database Pin
Member 134986305-Dec-18 16:53
Member 134986305-Dec-18 16:53 
Questionsend me database Pin
ngaynangmoi16-Mar-18 6:00
ngaynangmoi16-Mar-18 6:00 
QuestionHelp Database Pin
Member 1358680821-Dec-17 1:25
Member 1358680821-Dec-17 1:25 
Questiondatabase please Pin
Member 134513017-Oct-17 3:35
Member 134513017-Oct-17 3:35 
Questiondatabase required Pin
Member 129826194-Feb-17 4:47
Member 129826194-Feb-17 4:47 
Questionhi Pin
Member 1284580911-Nov-16 6:50
Member 1284580911-Nov-16 6:50 
QuestionExcellent Project Pin
Member 1242474722-Sep-16 15:53
Member 1242474722-Sep-16 15:53 
QuestionDATABASE Pin
barakkadosh5-Oct-15 23:05
barakkadosh5-Oct-15 23:05 
Questiondatabase Pin
Member 1186822127-Jul-15 23:15
Member 1186822127-Jul-15 23:15 
QuestionDatabase Required Pin
Ankush Mahajan0471-Jul-15 21:27
Ankush Mahajan0471-Jul-15 21:27 
QuestionDatabase Pin
Member 1135379017-Apr-15 8:34
Member 1135379017-Apr-15 8:34 
QuestionQuestion & Requesting for Database Pin
Member 1147412523-Feb-15 14:31
Member 1147412523-Feb-15 14:31 
Generali need your help if you can Pin
Member 1131694021-Dec-14 21:10
Member 1131694021-Dec-14 21:10 
QuestionDatabase Required Pin
Member 22853789-Dec-14 2:38
Member 22853789-Dec-14 2:38 
Questiondatabase Pin
rajusingh09227-Oct-14 23:47
rajusingh09227-Oct-14 23:47 
Questionany one help me tomorrow review last date Pin
Member 110514198-Oct-14 4:06
Member 110514198-Oct-14 4:06 
QuestionRe: Database Pin
Member 110514198-Oct-14 4:05
Member 110514198-Oct-14 4:05 
QuestionRegarding About Database Pin
AnoopGharu27-Sep-14 1:06
AnoopGharu27-Sep-14 1:06 
AnswerRe: Regarding About Database Pin
Member 110514198-Oct-14 4:05
Member 110514198-Oct-14 4:05 
Questionregarding to database Pin
Member 107864643-May-14 3:24
Member 107864643-May-14 3:24 
Questiondatabase request Pin
Member 1033854630-Mar-14 9:12
Member 1033854630-Mar-14 9:12 
QuestionDatabase Missing Pin
bitsshah_html20-Feb-14 19:20
bitsshah_html20-Feb-14 19:20 
GeneralMy review and request regarding database Pin
ApoorvSrivastava14-Feb-14 20:56
ApoorvSrivastava14-Feb-14 20:56 

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.