Northwind Smart Client Sample

Note

This sample runs only in Microsoft Office Excel 2007 and Microsoft Office Word 2007.

This sample uses document-level customizations for Excel and Word to implement an order tracking system based on the Northwind sample database for Microsoft SQL Server. The sample includes the following features:

  • Northwind Catalog template. This Excel template is used by customers to browse the different product offerings of the Northwind Supply Company. The template retrieves product information from the SQL Server Northwind database by calling the Northwind Web service. Using this template, customers can purchase different products, view and update their orders, and complete their orders with shipping information. The workbook retains information about the order between uses to enable the customer to use the catalog offline.

    Note

    The template does not retrieve orders that have already been submitted; it only creates and edits new orders.

  • Northwind Web service. After customers complete their orders they click Checkout, which submits the order to the Northwind Web service. The Web service adds the order information to the Northwind Order Rollup workbook and returns an Order ID.

  • Northwind Order Rollup workbook. This Excel workbook provides a consolidated view of all the new orders that are submitted through the Northwind Catalog and Northwind Web service. Users can track the company's order history to see which products are being purchased, who is purchasing them, how often they are purchased, and how much is purchased.

  • Northwind Web site. Users can view a list of all orders that have been submitted to the Northwind Web service from an ASPX page. This page reads data from the Northwind Order Rollup workbook. Users can select an order and click the Create Invoice button to write the data for that order into a new document made from the Northwind Invoice template. They can also view invoices that have already been created by clicking View Invoice.

  • Northwind Invoice template. This Word template is used by employees of the Northwind Supply Company to create invoices for customers. When an employee opens the template, the invoice for the data is created if data has already been added to the data cache by the Northwind Web site. If there is no data in the data cache, a Windows Form is displayed and the user can select which customer and which order to create the invoice for. The Northwind Invoice template then creates an invoice from data in the Northwind Order Rollup workbook.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To run this sample

  1. In the App_Code subfolder of the NorthwindWebService project, open the file Service.vb (in Visual Basic) or Service.cs (in C#).

  2. Find the comment that is labeled TODO:.

  3. Change the value of the workbookLocation variable to point to the installation location of the sample.

  4. In the NorthwindWebSite project, open the file Default.aspx.vb (in Visual Basic) or Default.aspx.cs (in C#).

  5. Find the two comments that are labeled TODO:.

  6. Change the values of the invoiceDirectory and workbookLocation variables to point to the installation location of the sample.

  7. Select the project NorthwindInvoice.

  8. On the Project menu, click NorthwindInvoice Properties.

  9. Click the Settings tab.

  10. On the Settings page, change the value of RollupLocation to point to the location of NorthwindOrderRollup.xls on your computer.

  11. Press F5.

  12. On the actions pane, select a category of products.

  13. Select a product in the worksheet, and then click Order.

  14. Type a positive number in the dialog box, and then click OK.

  15. On the actions pane, click View Cart.

    You can delete a product from the order or change the quantity.

  16. Click Continue Shopping to add more products to the order.

    — or —

    Click Checkout to finish the order.

  17. Type the shipping information in the dialog box and then click OK to submit the order.

    The order is submitted to the Northwind Web service.

  18. To view order history for all products, open the Northwind Order Rollup workbook and view the reports that are available on the actions pane.

  19. To create an invoice for an order, open the Northwind Web site, click an Order ID, and then click Create Invoice.

    The Northwind Web site reads the order data from the data cache in the Northwind Order Rollup workbook and saves it in a new document that is created from the Northwind Invoice template.

  20. To view the invoice, click View Invoice on the Web page.

    — or —

    Open the new Word document in the NorthwindInvoice\bin or NorthwindInvoice\bin\Debug folder.

  21. To create another invoice, open the Northwind Invoice template, select a Customer and an Order ID, and then click OK.

Requirements

  • The SQL Server database Northwind.

Demonstrates

  • Reading data from a SQL Server database.

  • Data binding lists on protected worksheets.

  • Using Windows Forms.

  • Using the actions pane.

  • Caching datasets.

  • Caching custom business objects.

  • Server-side processing of Visual Studio Tools for Office documents.

  • Using Word XMLNodes host controls.

  • Using Excel data validation.

  • Determining whether the current client machine is online or offline.

  • Calling a Web service.

See Also

Concepts

Caching Data

Accessing Data in Documents on the Server

Actions Pane Overview

Host Items and Host Controls Overview

Other Resources

Document-Level Samples