The Relations Application

Team Fly 

Page 535

The automated discount calculations impose another limitation on the design of the application's interface. The original NWOrders application allows you to switch tabs and select another customer even after adding detail lines to the order. We can't have this flexibility when the discount policy is based on the customer. To prevent users from selecting a new customer after having entered detail lines with discounts for another customer, we disable the Order Header tab. Another approach would be to allow users to select another customer and recalculate the discounts for the detail lines on the Order Detail tab.

The Relations Application

The Relations project demonstrates how to present related data on a Windows form. As you should guess, we're not going to use the DataGrid control, despite the fact that it's been designed to display related tables. The major disadvantage of the DataGrid as a data presentation tool is that it doesn't allow users to view the hierarchy of the data. The DataGrid control displays one level of data at any one time. Besides, users must select the relation they want to view on the control—certainly not the friendliest approach. We must give credit to the designers of the controls for the fact that the DataGrid can display any DataSet. A well-crafted application is very specific as to the data it handles and you can't expect a general tool to accommodate your needs as nicely as a custom solution. And this is what we'll do in this project: we'll write an interface that allows users to select a product from a list and see the customers who purchased the specific product, in how many of their orders it has appeared, and the total number of items of the same product each customer has ordered. The application's form is shown in Figure 18.6.

image

FIGURE 18.6 The Relations project displays sales data about each product.

The Application's Architecture

When the application's form is loaded, all the data are loaded into the ProductSales DataSet. In a real application you should provide an interface that enables users to limit the selection. For example, select orders placed in a time interval, the orders of customers from a specific country, and so on. The tables of the Northwind database are very small and we've chosen to download all their rows to the client.

Team Fly 


Visual Basic  .NET Power Tools
Visual Basic .NET Power Tools
ISBN: 0782142427
EAN: 2147483647
Year: 2003
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net