6: Building a Shopping Cart Application in .NET
6: Building a Shopping Cart Application Create Bar Code In Visual Studio .NET Using Barcode encoder for ASP.NET Control to generate, create barcode image in ASP.NET applications. data into another table that also has an identity column In that case, the @@IDENTITY function returns the identity value for the second table Fortunately, the Cart database doesn t use triggers, so the @@IDENTITY function will correctly return the identity value generated by the Orders table Create Code 3 Of 9 In C# Using Barcode encoder for .NET framework Control to generate, create Code-39 image in VS .NET applications. Connecting to the database
Generating USS Code 39 In .NET Framework Using Barcode maker for .NET Control to generate, create Code 3 of 9 image in .NET applications. The connection string used to access the Cart database is stored in the application s webconfig file, like this: <connectionStrings> <add name= ConnectionString connectionString= Data Source=localhost\SQLExpress; Initial Catalog=Cart;Integrated Security=True /> </connectionStrings> The only place in the application that references this connection string is here in the webconfig file This makes it easy to relocate the database when you put the application into production Creating Code39 In Visual Basic .NET Using Barcode generation for .NET Control to generate, create Code 39 image in VS .NET applications. The Application s Folders
Drawing Bar Code In .NET Using Barcode printer for ASP.NET Control to generate, create barcode image in ASP.NET applications. The Shopping Cart application includes the following folders: (Root): The application s root folder contains the application s six pages (Defaultaspx, Productaspx, Cartaspx, CheckOutaspx, and Completedaspx) as well as the Master Page (Defaultmaster) App_Data: This folder is designed to store databases used by the application However, this particular application uses a database that s stored in a location that s determined by SQL Server So the database for our Cart isn t actually stored in this folder (If you use the script presented in Listing 6-1 to create the database, the database file is stored in C:\Apps) App_Code: This folder contains the C# or Visual Basic code files that define the classes used by the application For more information about these classes, see the section Designing the Classes later in this chapter Images: Here, you ll find the banner image displayed by the Master Page and the image files that show pictures of the store s products Print Bar Code In .NET Framework Using Barcode encoder for ASP.NET Control to generate, create bar code image in ASP.NET applications. Part III: Building E-Commerce Applications
Make UPC-A In Visual C# Using Barcode generator for .NET Control to generate, create UPC Code image in .NET applications. Designing the Classes
Drawing Code-39 In C# Using Barcode printer for .NET Control to generate, create USS Code 39 image in Visual Studio .NET applications. Unlike most of the other applications presented in this book, the Shopping Cart application depends on several classes that both define the business objects used by the program as well as provide the database access In particular, the application uses the following classes: Customer: Represents a single customer ShoppingCart: Represents the user s shopping cart CartItem: Represents an item in the user s shopping cart Order: Represents an order OrderDB: Handles the details of writing an order to the database The following sections describe each of these classes in detail Make Barcode In VB.NET Using Barcode printer for VS .NET Control to generate, create barcode image in .NET framework applications. The Customer class
Code 128B Generator In Visual C#.NET Using Barcode generation for .NET framework Control to generate, create Code 128 Code Set C image in .NET applications. The Customer class represents a single customer Its constructors and properties are spelled out in Table 6-4 Read Code 128A In Visual Studio .NET Using Barcode recognizer for .NET Control to read, scan read, scan image in .NET applications. Table 6-4 ECC200 Creation In C# Using Barcode printer for .NET Control to generate, create Data Matrix ECC200 image in .NET applications. Constructor
Universal Product Code Version A Creator In VB.NET Using Barcode generation for .NET framework Control to generate, create UPC A image in .NET framework applications. Customer() EAN13 Reader In Visual Studio .NET Using Barcode decoder for VS .NET Control to read, scan read, scan image in .NET framework applications. The Customer Class
Read UCC - 12 In Visual Studio .NET Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications. Description
Generate Barcode In Java Using Barcode maker for Java Control to generate, create bar code image in Java applications. Creates an instance of the Customer class with default property values Creates an instance of the Customer class with the specified property values Make Bar Code In Visual Studio .NET Using Barcode drawer for Visual Studio .NET Control to generate, create bar code image in .NET applications. Customer(string lastName, string firstName, string address, string city, string state, string zipCode, string phoneNumber, string email) Print Bar Code In Visual C# Using Barcode generation for .NET framework Control to generate, create barcode image in .NET framework applications. Property
Print European Article Number 13 In .NET Framework Using Barcode drawer for .NET Control to generate, create EAN 13 image in VS .NET applications. string LastName string FirstName
Barcode Drawer In Java Using Barcode encoder for Java Control to generate, create bar code image in Java applications. Description
The customer s last name The customer s first name
6: Building a Shopping Cart Application
Property
string Address string City string State string zipCode string phoneNumber string email
Description
The customer s street address The customer s city The customer s state The customer s Zip code The customer s phone number The customer s e-mail address The ShoppingCart class
The ShoppingCart class represents a user s shopping cart Its constructors, properties, and methods are listed in Table 6-5 Table 6-5 Constructor
ShoppingCart() The ShoppingCart class
Description
Creates a new shopping cart with no items
Property
int Count
Description
The number of items in the shopping cart
Method
List<CartItem> GetItems() Description
Returns a List object that contains one CartItem object for each item in the shopping cart Adds a new item with the specified product ID, name, and price Updates the quantity at the specified index Deletes the item at the specified index The customer s phone number void AddItem(string id, string name, decimal price) void UpdateQuantity (int index, int quantity) void DeleteItem(int index) string PhoneNumber Part III: Building E-Commerce Applications
The CartItem class
The CartItem class represents an item in the user s shopping cart Its constructors and properties are listed in Table 6-6 Table 6-6 Constructor
CartItem() CartItem(string ID, string name, decimal price, int quantity) The CartItem class
Description
Creates a new CartItem object with default property values Creates a new CartItem object with the specified ID, name, price, and quantity Property
string ID string Name decimal Price int Quantity decimal Total
Description
The Product ID for the product represented by the item The product name The price per unit The quantity The total for the item (read-only)
|
|
|
|
| ALL RIGHTS RESERVED. Business Refinery (c) 2006 - 2010. | Terms of Use | Privacy Policy |