Click here to Skip to main content
15,884,176 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 686.5K   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

 
QuestionRequest for database and code Pin
Atul.Sharma0087-Aug-12 23:10
Atul.Sharma0087-Aug-12 23:10 
QuestionRequest for database Pin
Steve Pearson17-Jun-12 14:39
Steve Pearson17-Jun-12 14:39 
AnswerRe: Request for database and code Pin
ktnotoch3-Feb-13 20:48
ktnotoch3-Feb-13 20:48 
Questionrequest for the database Pin
Mark Norman11-Jun-12 3:18
Mark Norman11-Jun-12 3:18 
QuestionRegarding Database Pin
fahedk4-Jun-12 22:08
fahedk4-Jun-12 22:08 
GeneralMy vote of 2 Pin
saeedm1227-Feb-12 10:19
saeedm1227-Feb-12 10:19 
Questiondatabase Pin
durllavi14-Feb-12 22:07
durllavi14-Feb-12 22:07 
Questiondatabase Pin
vinay chauhan4204-Feb-12 18:44
vinay chauhan4204-Feb-12 18:44 
Questiondatabase Pin
varsti30-Jan-12 1:46
varsti30-Jan-12 1:46 
Questionhi Pin
saranyajana22-Jan-12 21:43
saranyajana22-Jan-12 21:43 
Questiondatabase Pin
moeym9-Jan-12 21:50
moeym9-Jan-12 21:50 
QuestionDAtabase attachment Pin
meestersumit26-Dec-11 3:07
meestersumit26-Dec-11 3:07 
GeneralMy vote of 5 Pin
meestersumit26-Dec-11 3:06
meestersumit26-Dec-11 3:06 
QuestionDatabase Pin
payam100025-Dec-11 4:52
payam100025-Dec-11 4:52 
QuestionDatabase Pin
payam100025-Dec-11 4:32
payam100025-Dec-11 4:32 
GeneralRequest for database Pin
Member 848659713-Dec-11 23:51
Member 848659713-Dec-11 23:51 
Questionhi Pin
shirin_k197-Dec-11 20:33
shirin_k197-Dec-11 20:33 
Questionshopping cart Pin
kanika bhagat7-Dec-11 2:55
kanika bhagat7-Dec-11 2:55 
QuestionRequest for Database Pin
Alifawad4092-Dec-11 21:57
Alifawad4092-Dec-11 21:57 
Questionrequest for database Pin
mage1628-Nov-11 10:22
mage1628-Nov-11 10:22 
QuestionRequest for database Pin
facelesslucifer19-Nov-11 21:14
facelesslucifer19-Nov-11 21:14 
Questiondatabase Pin
sarita khotani12-Nov-11 6:42
sarita khotani12-Nov-11 6:42 
Generaldatabase Pin
Member 39994768-Nov-11 8:38
Member 39994768-Nov-11 8:38 
QuestionDatabase Pin
Dinesh Balendran25-Sep-11 21:06
Dinesh Balendran25-Sep-11 21:06 
Questioneshopping Pin
Member 816773617-Aug-11 4:07
Member 816773617-Aug-11 4:07 

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.