ASP.NET
  Home arrow ASP.NET arrow Page 7 - Order-Related Modules for an ASP.NET AJAX ...
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Order-Related Modules for an ASP.NET AJAX Server-Centric Based Online Shopping Website
By: Xianzhong Zhu
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2007-12-26

    Table of Contents:
  • Order-Related Modules for an ASP.NET AJAX Server-Centric Based Online Shopping Website
  • Behind the Scenes
  • More Behind the Scenes Code
  • Web Handler
  • Buying Goods
  • Viewing the Shopping Cart
  • Page Initialization

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    At the virtual BlackBerry Technical Seminar 2008, you can ask your development questions directly of Research In Motion® (RIM) experts, and take advantage of learning opportunities designed uniquely for BlackBerry solution developers. Register Today!

    Order-Related Modules for an ASP.NET AJAX Server-Centric Based Online Shopping Website - Page Initialization


    (Page 7 of 7 )

    At the start of the initialization of the "order.aspx," related data are bound to the ProductView control, i.e. displaying the products within the cart, then continue to show the detailed info about the user and the order. The following code corresponds to the initializing process.

    protected void Page_Load(object sender,EventArgs e){

    if(!Page.IsPostBack){

    ///get the info about the cart

    ShowCartInfo();

    if(Session["UserID"]!=null)

    BindUserData(Int32.Parse(Session["UserID"].ToString()));

    }

    }

    private void BindUserData(int nUserID){

    ///Get the data

    User user = new User();

    SqlDataReader recr = user.GetSingleUser(nUserID);

    ///Read the data

    if(recr.Read()){

    ///display data

    UserName.Text = recr["UserName"].ToString();

    RealName.Text = recr["RealName"].ToString();

    Address.Text = recr["Address"].ToString();

    Email.Text = recr["Email"].ToString();

    Phone.Text = recr["Phone"].ToString();

    Mobile.Text = recr["Mobile"].ToString();

    Remark.Text = recr["Remark"].ToString();

    }

    recr.Close();///Close the data source

    }

    private void ShowCartInfo(){

    ///judge if there are data in the cart

    if(Session[Session.SessionID + OrderForm.Cart] == null) {

    return;

    }

    OrderInfo order = (OrderInfo)Session[Session.SessionID + OrderForm.Cart];

    ProductView.DataSource = order.OrderItemList;

    ProductView.DataBind();

    ProductView.FooterRow.Cells[0].Text = "Total amount: " +
    order.TotalNumber.ToString() + ", Total price: " +
    order.TotalMoney.ToString();

    }

    Notwithstanding the fact that it is pretty long, the inner logic is rather easy. The key sentence is 'SqlDataReader recr = user.GetSingleUser(nUserID);' while the key variable still lies in Session. OK, by calling the two helper functions, namedShowCartInfoand BindUserData, all the required info is displayed on the screen.

    Submitting the Order

    The following shows the click event handler for the "Confirm the shopping info and commit the order" in the above Figure 18.

    protected void CommitBtn_Click(object sender,EventArgs e){

    ///judge if there are data in the cart

    if(Session[Session.SessionID + OrderForm.Cart] == null) {

    return;

    }

    OrderInfo order = (OrderInfo)Session[Session.SessionID + OrderForm.Cart];

    OrderForm orderform = new OrderForm();

    int nOrderFormID = orderform.AddOrderForm(Int32.Parse(Session
    ["UserID"].ToString()),

    order.TotalNumber,

    order.TotalMoney);

    if(nOrderFormID > -1) {

    OrderItem orderItem = new OrderItem();

    foreach(OrderItemInfo item in order.OrderItemList) {

    orderItem.AddOrderItem(item.ProductID,item.Number,nOrderFormID);

    }

    }

    ///display the hint message

    Response.Write("<script>alert("You have succeeded in committing the
    order!")</script>");

    }

    Here, we first obtain the order info out of the Session variable, then submit it to the remote SQL Server database, and at last create an order. That's it.

    Author's Note: First, because this is just a demonstration application, we have not attached all the order-related info to the popular online payment systems, such as PayPal or any other famous system. Thus, in practical development, you will have to do this by yourself. Second, to grasp all the data relations introduced in the above several modules you should carefully study the relationships between some classes such as OrderForm, OrderInfo, and OrderItemInfo.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    ASP.NET ARTICLES

    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ
    - Developing a Dice Game Using ASP.NET Futures...
    - Completing an ASP.NET AJAX Server-Centric Ba...
    - Information Management for an ASP.NET AJAX S...
    - Comment and Order Management for an ASP.NET ...
    - Back-end Management Tasks for an ASP.NET AJA...
    - User Information Management for an ASP.NET A...
    - Adding Comments and Search to an ASP.NET AJA...
    - Order-Related Modules for an ASP.NET AJAX Se...
    - User and Role Management for an ASP.NET AJAX...
    - Programming an ASP.NET AJAX Server-Centric B...

    Click Here




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway