PLACING ORDERS- SHOPPPING CARTS. Introduction There are several stages to the order process, starting with an order page, which allows customers to add.

Slides:



Advertisements
Similar presentations
Microsoft Expression Web-Illustrated Unit K: Working with Behaviors.
Advertisements

Using EBSCOs Search Box Builder Tool Tutorial. Would you like to promote your EBSCOhost resources by adding an easy-to-use search box to your website?
With Folder HelpDesk for Outlook, support centres and other helpdesks can work efficiently with support cases inside Microsoft Outlook. The support tickets.
09/04/2015Unit 2 (b) Back-Office processes Unit 2 Assessment Criteria (b) 10 marks.
Microsoft Office XP Microsoft Excel
e-DMAS Consumer Web Order Entry (WEBOE8) An Enhancement For iSeries 400 DMAS from  Copyright I/O International, 2003, 2004, 2005 Skip Intro.
Welcome to Florida International University Online J.O.B.S. Link Applicant Tutorial.
Billing for Departmental Users
1 Chapter 12 Working With Access 2000 on the Internet.
DT228/3 Web Development multi page applications/ sharing data.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
Creating And Maintaining A Database. 2 Learn the guidelines for designing databases When designing a database, first try to think of all the fields of.
ASP.NET Programming with C# and SQL Server First Edition
1 Modified_ CIRCUIT PROTECTION SOLUTIONS Confidential and Proprietary to Littelfuse, Inc. ® Littelfuse, Inc All rights reserved. February,
Working with SharePoint Document Libraries. What are document libraries? Document libraries are collections of files that you can share with team members.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
A detailed guide on how to set-up your printing storefront. Please Note: Storefronts are compatible with all browsers, however for optimal use of the admin.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Microsoft ® Office Outlook ® 2007 Training See and Use Multiple Calendars ICT Staff Development presents:
FireRMS SQL Audit, Archiving & Purging Presented by Laura Small FireRMS Quality Assurance.
Getting started on informaworld™ How do I register my institution with informaworld™? How is my institution’s online access activated? What do I do if.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
IT533 Lectures Session Management in ASP.NET. Session Tracking 2 Personalization Personalization makes it possible for e-businesses to communicate effectively.
Moodle (Course Management Systems). Assignments 1 Assignments are a refreshingly simple method for collecting student work. They are a simple and flexible.
Page Up or Down to navigate through the program.
State Management. What is State management Why State management ViewState QueryString Cookies.
Data File Access API : Under the Hood Simon Horwith CTO Etrilogy Ltd.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
SHOPPING CARTS CHAPTER 19. E-COMMERCE Typically, an e-commerce site will have public pages and admin pages.
PHP meets MySQL.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Setting Up an on-line Store Tutorial Using SmartStore.biz This Tutorial assumes you have downloaded the software from This Tutorial.
COMP3121 E-Commerce Technologies Richard Henson University of Worcester November 2011.
1 OPOL Training (OrderPro Online) Prepared by Christina Van Metre Independent Educational Consultant CTO, Business Development Team © Training Version.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
C# Tutorial -1 ASP.NET Web Application with Visual Studio 2005.
Replacement Parts Pros How to…Order Products Home Page: Displays the different categories of product Drop down menu lists the.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
XP New Perspectives on Microsoft Access 2002 Tutorial 21 Microsoft Access Tutorial 2 – Creating And Maintaining A Database.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
1. To start the process, Warehouse Stationery (WSL) will invite you to use The Warehouse Group Supplier Electronic Portal and will send you the link to.
Key Applications Module Lesson 21 — Access Essentials
1 Chapter 12 – Web Applications 12.1 Programming for the Web, Part I 12.2 Programming for the Web, Part II 12.3 Using Databases in Web Programs.
ASP.NET The Clock Project. The ASP.NET Clock Project The ASP.NET Clock Project is the topic of Chapter 23. By completing the clock project, you will learn.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Christopher M. Pascucci Basic Structural Concepts of.NET Managing State & Scope.
iProcurement Features & Functions The Department of Procurement & Contracts.
Session and Cookie Management in.Net Sandeep Kiran Shiva UIN:
XP 1 New Perspectives on XML Binding XML Data with Internet Explorer.
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Microsoft ® Office Excel 2003 Training Using XML in Excel SynAppSys Educational Services presents:
Chapter 4: Working with ASP.NET Server Controls OUTLINE  What ASP.NET Server Controls are  How the ASP.NET run time processes the server controls on.
ASP.Net, Web Forms and Web Controls 1 Outline Session Tracking Cookies Session Tracking with HttpSessionState.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Bookstore Application: Middle Tier Introducing Code-Behind Files, Session State.
Module 4: Creating a Web Application with Web Forms
 Shopping Basket  Stages to maintain shopping basket in framework  Viewing Shopping Basket.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Word Create a basic TOC. Course contents Overview: table of contents basics Lesson 1: About tables of contents Lesson 2: Format your table of contents.
1.NET Web Forms Applications: Main Form © 2002 by Jerry Post.
ADO.NET Objects Data Adapters Dr. Ron Eaglin. Agenda Builds on Information in Part I Should have working knowledge of creating a database connection Continuation.
ITM © Port,Kazman 1 ITM 352 Cookies. ITM © Port,Kazman 2 Problem… r How do you identify a particular user when they visit your site (or any.
CSCI 6962: Server-side Design and Programming Shopping Carts and Databases.
Navigation: If the tutorial opens up in your web browser, simply click your mouse to advance to the next slide. Use the “Backspace”
VB.NET and Databases. ADO.NET VB.Net allows you many ways to connect to a database. The technology used to interact with a database or data source is.
Complete Ordering System for Promotional Literature and Samples Quick Reference and Training Guide.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Web Development Using ASP .NET
Presentation transcript:

PLACING ORDERS- SHOPPPING CARTS

Introduction There are several stages to the order process, starting with an order page, which allows customers to add products to a shopping cart. Once customers have selected their order items, they can then proceed to the checkout, where the delivery address and credit card details need to be collected. Finally, you create the order in the database, and all the updates to the database as well as the real delivery of the products are going to be done.

Essential Background Learn how to create custom classes See how to use the Session object to store the shopping cart Learn about the ObjectDataSource control

The Order Process Before building the order pages, you must work out the process of ordering items. This will give you an indication of exactly what you will need. Following are the things you will need: An order page, where you can select the product items. A shopping cart, to store the selected products. A page to collect the delivery details and credit card payment.

The Order Process-Continue Each of the previous pages needs some thought, with the process of ordering and storing data worked out in advance. For example, you must decide whether to have an order page that is separate from the catalogue page. Keeping them the same would mean that you can simply add a button alongside each item. This would add the item to the shopping cart. Alternatively, you could have a text area allowing the user to enter the number of items to be added. This makes the page a little harder to code.

Where to store orders Once you’ve decided on the way orders will be performed, you can decide where to store them before the order is confirmed—the shopping cart. There are places to store shopping carts: In a database —As the user adds items to the cart, the items could be added to a table in the database. When the order is confirmed, the entries could be copied into the OrderItems table. One problem with this approach is that if the user leaves the site without confirming the order, then the shopping cart table will have unused data in it, which will need to be removed. In the Profile —The Profile is a feature of ASP.NET 2.0 that allows storage of data against a user. We won’t be using the Profile, but one problem with using the Profile for storing the shopping cart is that the Profile is meant for long-lived data—data that persists across user sessions. Some sites allow shopping carts to keep their data for when you come back to the site. In the Session —The Session contains data about the active session. It starts when you first access the site and ends when you exit the site (plus a timeout value). Any data stored in the session will be held only while you are browsing the site.

Developing a Shopping Cart Many ecommerce web sites require a shopping cart as an essential part. There are many ways to develop these shopping carts. Some of them are - cookie based, session based and database driven. Each technique has advantages and disadvantages of its own. We will explore each technique with code sample and finally present you a generic solution that will work in any of these situations.

Using Cookies for state storage Any shopping cart essentially needs to store product details such as product code, product name, unit price and quantity. You will be presenting a product catalog to the user from which he can select the products. He may also navigate to other parts of the site while he is shopping. You need to maintain his selection across the pages so that finally when he visits the shopping cart page you can show collective details there. Cookies can be used to preserve this state information across the requests. In ASP.NET cookie is represented by a class called HttpCookie. We will be using multi-value cookies for our example.

Developing a simple product listing page We will first build a simple web form that lists the Products table of the database in a DataGrid. Add a web form called ProductCatalog.aspx to your project Drag and drop a DataGrid control on it. Write a function called BindGrid() as shown below:

BindGrid() private void BindGrid() { SqlDataAdapter da=new SqlDataAdapter ("select * from source=.\vsdotnet;initial catalog=_________;user id=__"); DataSet ds=new DataSet(); da.Fill(ds,"products"); DataGrid1.DataSource=ds; DataGrid1.DataBind(); }

In the Page_Load event handler private void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack) { BindGrid(); }

In the SelectedIndexChanged event of the DataGrid private void DataGrid1_SelectedIndexChanged (object sender, System.EventArgs e) { HttpCookie c=null; if(HttpContext.Current.Request.Cookies["shoppingcart"]==null) c=new HttpCookie("shoppingcart"); else c=HttpContext.Current.Request.Cookies["shoppingcart"]; string itemdetails; itemdetails=DataGrid1.SelectedItem.Cells[1].Text + "|" + DataGrid1.SelectedItem.Cells[2].Text + "|" + DataGrid1.SelectedItem.Cells[3].Text; c.Values[DataGrid1.SelectedItem.Cells[1].Text]=itemdetails; Response.Cookies.Add(c); }

Shopping Cart Cookies Here, we created a cookie called shoppingcart. This cookie further contains subkey-value pairs. Based on user selection we simply add sub keys to this cookie with product id as the key. Then we write that cookie to Response.Cookies collection. Drag and drop a button control on the web form and write the following code in the click event handler.

click event handler Here, we are simply navigating to the cart.aspx page which displays the shopping cart. So we also need to create the shopping cart web form private void Button1_Click (object sender, System.EventArgs e) { Response.Redirect("cart.aspx"); }

Creating the shopping cart web form Add another web form to your project called cart.aspx Create a class called CShoppingCartItem as shown below:

The Code for the CShoppingCartItem

Continue This class is going to represent one item of the shopping cart. Drag and drop a DataGrid on the web form. Create a function called FillCartFromCookies() as shown below Here, we are reading the cookies that we set previously and constructing CShoppingCartItem instances based on the selected values. These instances are then added to an ArrayList. Finally, this ArrayList is bound with the DataGrid.

Code for the FillCartFromCookies()

Write some code for the Recalculate event Drag and drop a button called Recalculate and write following code to its click event handler. This code calculates the total amount of the items selected based on the quantity entered and displays it in a label.

The Code for the Recalculate event

Code to delete items from the cart

Problems with the above Shopping Carts We saw how to use cookies to preserve shopping cart values. This approach is quick and easy to code but has one big disadvantage. Not all browsers will have cookies enabled. Hence, you should use this technique with care. NOTE I will give you a full working example using a Shopping Cart using COOKIES

Shopping Carts with Sessions In the previous slides we saw how to create a shopping cart using cookies. Continuing the concept further in the following slides we will illustrate how to use session variables to create a shopping cart. First we again have to develop a simple product listing page. We will then build a simple web form that lists Products table coming from our database in a DataGrid control. We also write a function called BindGrid() as shown below:

Code for the Datagrid

In the Page_Load event handler

Code in the SelectedIndexChanged event of the DataGrid

What Are Sessions? You can use the Session objects to store values that are global rather than page-specific for either a particular user (the Session) or to all users (the Application). The Session variables are stored on the server. Client browsers are then attached to the session through a cookie. As a result, the client must have cookies enabled in the browser for Session and Application variables to work. How to Use Session Variables The power of the Session object comes from the fact that it can store variables that are global to just that specific user; as a result, each user can have their own individual value for that variable. Session objects are not always created automatically for every user when they enter your application. However, storing or accessing a variable in the Session object creates the Session object and fires the Session_OnStart event. To demonstrate how to use the Session object in an ASP page, follow these steps:

Sessions Continue Paste the following code between the tags of the ASP page that you created earlier : Click View in Browser from the View menu. When you are prompted to save the file, click OK. The browser displays the information in the variable.

Need a Button for Handling Notice that we created an ArrayList for storing the selected products. We check whether if we have already stored it in the session or no. If we have already stored then we get hold of the existing session variable else we create a new session variable. Then we to Drag and drop a button control on the web form and write following code in the it's click event handler, simply navigating to the cart.aspx page which displays the shopping cart

Creation of the Cart Page- Creation of the CShoppingCartItem CLASS This class is going to represent one item of the shopping cart.

Addition of a DataGrid on the web form. Drag and drop a DataGrid on the web form. Create a function called FillCartFromSession() as shown below. Here, we get hold of the ArrayList that we saved in the session previously and then bind the grid with the arraylist.

Addition of the Recalculate button -- Its click event handler This code calculates the total amount of the items selected based on the quantity entered and displays it in a label.

The code to delete items from the cart We simply iterate through the ArrayList stored in the session and remove the item based on ProductID

Summary We saw how to use Session variables to store shopping cart. This approach has an advantage as compared to cookie driven cart that you need not worry whether client browser is supporting cookies. On the downside you are putting burden on the server because in default mode Session variables are stored in the memory of the web server. So, this technique is suitable to small to moderately trafficked web sites. In the next example we will see how to store shopping cart in SQL Server database. NOTE : I will give you a complete working example of shopping cart using Session Variables

Introduction to Database Driven Shopping Carts In the previous example we saw how to create a shopping cart using session variables. Continuing the concept further the following example will illustrate how to use the database in order to store your shopping cart in a database. This technique is more robust and scalable that the previous two techniques. Before you proceed with any coding, you need to create the following table

Creation of the Shopping Cart Table

Developing a simple product listing page We will first build a simple web form that lists Products from the corresponding table of your database in a DataGrid control. Add a web form called ProductCatalog.aspx t Drag and drop a DataGrid control on it. Write a function called BindGrid() as shown below:

Code for BindGrid()

In the Page_Load event handler private void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack) { BindGrid(); }

Code in the SelectedIndexChanged event of the DataGrid

The CShoppingCartItem class

Addition of a button to redirect to the Cart page private void Button1_Click (object sender, System.EventArgs e) { Response.Redirect("cart.aspx"); } Here, we are simply navigating to the cart.aspx page which displays the shopping cart.

The CShoppingCart class This is the most important class in our application because it actually performs the job of storing or retrieving shopping cart items into a database table. This class uses SqlConnection, SqlCommand and SqlDataReader classes to perform various tasks such as INSERT, UPDATE and SELECT. It consists of static methods and looks as shown below:

Creating the shopping cart web form Add another web form to the above project called cart.aspx Drag and drop a DataGrid on the web form. Create a function called FillCartFromDb() as shown below: private void FillCartFromDb() { DataSet ds=CShoppingCart.GetAll(Session.SessionID); DataGrid1.DataSource=ds; DataGrid1.DataBind(); Button1_Click(null,null); } Here, we call the GetAll method of the CShoppingCart class which returns a DataSet. This DataSet acts as a datasource for the DataGrid control.

The code for the Recalculate Button This code calculates the total amount of the items selected based on the quantity entered and displays it in a label.

Finally, the code to delete items from the cart. We simply simply delete a particular product by calling the DeleteItem method of CShoppingCart class.

Summary In this example we saw how to use SQL Server database to store a shopping cart. This approach though requires more coding is recommended for big sites. Since you are storing the data in a SQL server database, you are not putting any overhead on the web server (as against Session variables). Also, this approach is better than cookies because you are not dependent of client browser supporting cookies. In terms of performance this approach will however be slower than the other two techniques. However, overall it is more robust and scalable than cookies or sessions. Can somebody think of how to create a single wrapper to all he three approaches so that without any code change you can switch between these three techniques??????????