Sie sind auf Seite 1von 14

7,485,597 members and growing!

(22,575 online)
MenuBarForm Sign in true
Email Password
Remember me?   Lost password?

 Home online shop


 Articles
o Chapters and Sections


o Search
o Latest Articles
o Latest Tips/Tricks
o Top Articles
o Beginner Articles
o Technical Blogs
o Post an Article
o Post Tip & Trick
o Post your Blog
o Posting/Update Guidelines
o Article Competition
 Questions & Answers
o Ask a Question about this article
o Quick Answers
o Ask a Question
o View Unanswered Questions
o View All Questions...
o C# questions
o ASP.NET questions
o VB.NET questions
o C++ questions
o C#3.0 questions
o Programming Discussions
o All Message Boards...
o Application Lifecycle>
 Design and Architecture
 Running a Business
 Sales / Marketing
 Collaboration / Beta Testing
 Work & Training Issues
o C / C++ / MFC>
 ATL / WTL / STL
 Managed C++/CLI
o C#
o Database
o IT & Infrastructure>
 Hardware & Devices
 System Admin
o Java
o .NET Framework
o Mobile
o Sharepoint
o Silverlight / WPF
o Visual Basic
o Web Development>
 ASP.NET
 CSS
 Javascript
 PHP
o Site Bugs / Suggestions
o Other Languages>
 General Indian Topics
 General Chinese Topics
 Learning Zones
o The Commerce Zone
o The Mobile Zone
o The Cloud Zone
o The Hardware Zone
o The Parallelism Zone
o The WPF Silverlight Zone
o The SQL Zone
o WhitePapers / Webcasts
 Features
o Who's Who
o CodeProject MVPs
o Company Listings
o Component & Service Catalog
o Competitions
o News
o Daily Insider
o Newsletter archive
o Press Releases
o Surveys
o CodeProject Stuff
o CodeProject VS Addin
 Help!
o What is 'The Code Project'?
o General FAQ
o Post a Question
o Bugs and Suggestions
o Site Directory
o Advertise with us
o About Us
 The Lounge
o The Lounge  
o Clever Code
o Hall of Shame
o The Soapbox
o

» Web Development » Applications & Tools » Applications

Licence 
First Posted  20 Apr 2004
Views  245,541
Bookmarked 126 times
Tags  .NET1.1,
VS.NET2003, C# ...

Shopping Cart using C#.NET, Web Forms


and SQL Server
By Shruti Shrivastava | 20 Apr 2004
Shopping cart using C#.NET, Web Forms and SQL Server.

Print Article

Twitter
Digg
Facebook
Del.icio.us
Reddit
Stumbleupon
Newsvine
Technorati
Mr. Wong
Yahoo!
Google
Windows Live
Send as Email
Add to your CodeProject bookmarks

Discuss this article


90
Report this article as inappropriate

Article Browse Code StatsRevisions


  3.58 (51 votes)

1 2 3 4 5
Sponsored Links
 
See Also

 Articles like this


 Articles by this author

/w EPDw UKMTAy

 Download source files - 135 Kb

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:

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

Web Developer

United States

Member

Article Top
Sign Up to vote for this article
Add a reason or comment to your vote: x

Comments and Discussions


You must Sign In to use this message board.
 FAQ  38314 Search
 
38314 ?floc=%2fKB%2 /KB/applications/ Medium
Noise Tolerance   Layout
Normal 25 Update
  Per page    
  Msgs 1 to 25 of 90 (Total in Forum: 90) (Refresh) FirstPrevNext

pls send me database hellovatsu 6:04 1 Dec '10  


Hi Please send me database
V.A.Patel

Sign In·View Thread·PermaLink

Re: pls send me database DGamer 10:17 2 Dec '10  


I can send you the database. Do you have any experience or knowledge of C# or ASP
dot Net?
Sign In·View Thread·PermaLink

Is anyone here? DGamer 17:59 26 Nov '10  


Reply if you've downloaded this with the intent of making it work.
Sign In·View Thread·PermaLink

Author of this Script is not actively participating on this site. 14:08 20 Nov '10  
The author has not responded to any post here. I added the author to my
msn messenger email contact list. But still no reponse. Let's try and help
each other, perhaps collectively we can resolve each others issues. Reply to
this post with your e-mail and let's setup a group chat on msn messenger. It
would be helpful if someone with knowledge of asp and c# participate.
Remember why you came to this site, and downloaded this script. Let's
work together

Three things about this script I need to modify or fix. Seperating the shopping cart table
from the products page. I want the shopping cart to show in an iframe. I already
accomplished this by targeting the iframe, but the products table also displays there. It
updates at the target, not on the main page. But then, the shopping cart also displays on the
main page. Which also happens to be an iframe.

I need to setup multiple categories, so when a link such as cameras is clicked, another table
is queried displaying the cameras table. I did create another table and named it cameras
within the northwind database. Then copied main.aspx renaming it as cameras.aspx. I did
the same for main.aspx.cs and main.aspx.resx. I then edited cameras.aspx and named the
codefile to cameras.aspx.cs. Changed the queries from products to cameras inside both
files. But it didn't work, the application errored.

I need to have images in the products table, but have not been successful at adding them.
Also, the add to cart link would be more friendly to the touch screen if it were a graphic
button. A details page would be helpful to customers to provide more information than the
items name and price.

A couple of other things I noticed was the order details are not included in the emails or the
database. Also, new users are not validated or added to the database. Although, I
commented out the login page so that the next page that loads is the checkout. But then, I
don't require credit card numbers or billing zip codes from the users right now. I am using
this on my intranet in my store as a shopping portal, and have designed this to be used
from a touch screen.. After orders are submitted, they are sent to my email server. I use
popup peeper, it checks emails every single minute. Then pops up like msn messenger
notifying me of a new email. I open the emails and pull the items from the stock room,
then scan them at the register and complete the sale. Upon submission of order, the
shopping cart should cleared. If
Sign In·View Thread·PermaLink

User ID and Password + Order details DGamer 11:09 10 Nov '10  


Has anyone figured out why new user names and passwords are not stored or validated in
the database? Why are the order details not included in the email after order submission.
Also, the database is not recording the order details. :

Why isn't this working?

sqlDataAdapter1.Fill(dataSet11);
DataRow row1 = dataSet11.Tables["Order Details"].NewRow();

I deleted the order details dbo.table contents. Then tested some transactions, database
records nothing.
Sign In·View Thread·PermaLink

pls send me database pls....... udaya kumar g s 5:21 2 Nov '10  


pls send me the database. i want to complete my project so pls......
Sign In·View Thread·PermaLink

Re: pls send me database pls....... DGamer 13:00 2 Nov '10  


Here is the database:

http://www.microsoft.com/downloads/en/details.aspx?FamilyId=06616212-0356-46A0-
8DA2-EEBC53A68034&displaylang=en[^]
Sign In·View Thread·PermaLink

Regarding Database DGamer 18:31 1 Nov '10  


To everyone requesting the database, it is an example database that is
downloadable called Northwind. Search for Northwind Database, download, and
attach in MSSQL. Of course I have done all of this, but have not been able to
successfully connect to my database. I edited main.aspx.cd to change the
sqlconnectionstring, there was also a error in this line. Then I edited web.config
file to change the data source. Still doesn't work. If you have successfully tested
this script, let me know what you did please, step by step.
Sign In·View Thread·PermaLink

database required urgently preetibamania 5:06 27 Sep '10  


plzz send me the database .its urgent preetibamania@gmail.com
Sign In·View Thread·PermaLink

Re: database required urgently [modified] DGamer 13:01 2 Nov '10  


Here is the database:

http://www.microsoft.com/downloads/en/details.aspx?FamilyId=06616212-0356-46A0-
8DA2-EEBC53A68034&displaylang=en[^]
modified on Tuesday, November 2, 2010 6:21 PM

Sign In·View Thread·PermaLink

database nitinmodi 9:47 20 Sep '10  


plz send its database...........
Sign In·View Thread·PermaLink

Re: database [modified] DGamer 13:01 2 Nov '10  


Here is the database:

http://www.microsoft.com/downloads/en/details.aspx?FamilyId=06616212-0356-46A0-
8DA2-EEBC53A68034&displaylang=en[^]
modified on Tuesday, November 2, 2010 6:22 PM

Sign In·View Thread·PermaLink
Database popokatipetl 23:53 4 Sep '10  
Your project is great Can you send me the database to bojanadamovci@gmail.com ?
Thanks
Sign In·View Thread·PermaLink 1.00/5 (1 vote)

Re: Database [modified] DGamer 13:01 2 Nov '10  


Here is the database:

http://www.microsoft.com/downloads/en/details.aspx?FamilyId=06616212-0356-46A0-
8DA2-EEBC53A68034&displaylang=en[^]
modified on Tuesday, November 2, 2010 6:22 PM

Sign In·View Thread·PermaLink

Requesting Database apachex 23:39 26 Aug '10  


Will be thankful if you can share the database file too..
anadim@in.com

thanks.. nice work.


Sign In·View Thread·PermaLink

Re: Requesting Database DGamer 13:22 2 Nov '10  


http://www.microsoft.com/downloads/en/details.aspx?FamilyId=06616212-0356-46A0-
8DA2-EEBC53A68034&displaylang=en[^]
Sign In·View Thread·PermaLink

Please send me the database tneuber 13:30 25 Aug '10  


Hello i need the databse too.
Thanks
Tom
doktorneuber@gmail.com
Sign In·View Thread·PermaLink

Re: Please send me the database DGamer 13:22 2 Nov '10  


http://www.microsoft.com/downloads/en/details.aspx?FamilyId=06616212-0356-46A0-
8DA2-EEBC53A68034&displaylang=en[^]
Sign In·View Thread·PermaLink

Database minkzzii 20:40 24 Aug '10  


Hi, K.Shruti Shrivastava
Please send your database file to my e-mail: minkzzzzzzz@hotmail.com
Thanks !!
Sign In·View Thread·PermaLink

Re: Database DGamer 13:23 2 Nov '10  


http://www.microsoft.com/downloads/en/details.aspx?FamilyId=06616212-0356-46A0-
8DA2-EEBC53A68034&displaylang=en[^]
Sign In·View Thread·PermaLink

DataBase Steenrp 21:32 14 Aug '10  


Hi,

Very nice and useful project, can u please send me the database file? here is my emailid:
steenrp@hotmail.com
Thanks.
Sign In·View Thread·PermaLink

Re: DataBase DGamer 13:23 2 Nov '10  


http://www.microsoft.com/downloads/en/details.aspx?FamilyId=06616212-0356-46A0-
8DA2-EEBC53A68034&displaylang=en[^]
Sign In·View Thread·PermaLink

thanks seokid 12:25 6 Aug '10  


We're looking to make a shopping cart at my workplace. It's hard to figure out where to
begin, this really points me in the right direction and gives an idea on how to make it work
with our own database.

Thanks again.
Sign In·View Thread·PermaLink

database Kishalay Bairagi 5:13 5 Aug '10  


hii shruti your is shopping cart application is nice....can u send me
the database.......it's very urgently needed....my email address
is kishalayb27@gmail.com
Sign In·View Thread·PermaLink 1.00/5 (1 vote)

Re: database DGamer 13:24 2 Nov '10  


http://www.microsoft.com/downloads/en/details.aspx?FamilyId=06616212-0356-46A0-
8DA2-EEBC53A68034&displaylang=en[^]
Sign In·View Thread·PermaLink

/KB/applications/
Last Visit: 19:00 31 Dec '99     Last Update: 8:41 19 Dec '10
1234 Next »

General    News    Question    Answer    Joke    Rant    Admin   

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


Ctrl+PgUp/PgDown to switch pages.

PermaLink | Privacy | Terms of Use


Last Updated: 20 Apr 2004

Copyright 2004 by Shruti Shrivastava


Everything else Copyright © CodeProject, 1999-2010
Web24 | Advertise on the Code Project
Spread for ASP.NET by GrapeCity
FarPoint Spread for ASP.NET 5 by GrapeCity is...
www.farpointspread.com
ATI Stream SDK
The ATI Stream Software Development Kit (SDK)...
developer.amd.com
New Team Foundation Server 2010 Hosting - Click Here!
Get NEW Hosted Team Foundation Server (TFS)...
www.discountasp.net
See Also...
Creating PDF Documents in ASP.NET
How to create PDF documents in ASP.NET.
A Fast CSV Reader
A reader that provides fast, non-cached,...
A Simplified SQL-CSV Import/Export Functionality
A simplified SQL-CSV import/export functionality.
Importing CSV Data and saving it in database
This article shows how to import CSV data and...
Transferring Data Using SqlBulkCopy
An article on how to transfer data using...
Announcements
Mobile Virtual Tech Summit On Demand
Got an Azure app? Win an Xbox & Kinect
The Daily Insider
30 free programming books
Daily News: Signup now.

Das könnte Ihnen auch gefallen