Reviewing the Application

In this exercise, you will review a complete solution to this lab so that you clearly understand how it works. This solution will show how the application loads data into the disconnected application.

Then you will review a starter solution that will be the starting point for the application you will complete in the other exercises of Labs 6.1 and 6.2.

Scenario The "On The Road" Windows application is used by Northwind Traders sales people to track customer orders while the user is on the road, and do not therefore have access to the central database servers.

The application will run on the users' laptops. While in the office, the user can connect to the corporate network and get the latest order data for their customers. This will be a subset of the order data stored on the central database server. The user creates the subset of data by choosing their name from a list of employees, and this information is used to only return customer and order data for that employee.

When the application closes, it automatically saves a copy of the current data set to the local disk drive of the laptop. When the application is next executed, it automatically opens the saved data set so that the user can immediately continue working on the data.

While on the road, users can add new orders, and edit and delete existing orders. When the user returns to the office, they can choose a menu item to update the central database with the changes they have made to the data set. You will implement this functionality in Lab 6.2.

The application allows the user to specify the server name that hosts the central database. It also has an About dialog to display copyright information.

Application Startup This is the decision tree for when the "On The Road" application starts up.

Decision Tree

Application Startup This is the decision tree for when the "On The Road" application starts up.

Decision Tree

Exercise Steps Now you will open the solution and test the complete application.

► To open and rebuild the complete solution

1. Start the Microsoft Visual Studio .NET development environment.

2. Open an existing project named OnTheRoad. The location is

<install path>\2389\Labs\Lab06_2\Solution\Ex3\xx\ where xx is either VB or CS. This project contains the complete solution for all the work you will do in Labs 6.1 and 6.2.

3. Rebuild the solution.

4. Exit the Microsoft Visual Studio .NET development environment.

5. Start the Microsoft SQL Server Query Analyzer.

6. Open the script named lab6setup.sql in this folder: <install path>\2389\Labs\Lab06_1\

7. Run the script.

8. Exit the Microsoft SQL Server Query Analyzer.

► To test the application settings

1. Open Windows Explorer and go to one of the following folders: <install path>\2389\Labs\Lab06_2\Solution\Ex3\VB\OnTheRoad\bin\ - or -

<install path>\2389\Labs\Lab06_2\Solution\Ex3\CS\OnTheRoad\bin\debug\

2. There should be two files, named OnTheRoad.exe (the application executable) and OnTheRoad.pdb (program debug database). If there is a file named OnTheRoad.xml, delete it (this is where the data set is saved while on the road).

3. Double-click the executable OnTheRoad.exe to run it.

4. You will see a warning message saying that a data set was not found, and offering to connect to the central database to create one. Click No.

5. Choose the Tools - Options menu item. Notice you can change the server name for the central database, and that it is currently set to (local). Click Cancel. We do not want to change this option yet.

6. Close the application.

7. In Windows Explorer, notice that a file was created named OnTheRoad.xml. Double-click the file to open it in Internet Explorer.

8. Review the contents of the OnTheRoad.xml file in Internet Explorer. Notice that it currently contains the ID of the currently selected employee (it defaults to zero) and the server name for the central database.

9. Close Internet Explorer.

10. Double-click the executable OnTheRoad.exe to run it again.

11. Choose No to the warning message, because you are still not ready to connect to the central database.

12. Choose the Tools - Options menu item, and change the server name to the name of your computer.

13. Close the application.

14. Double-click the OnTheRoad.xml file to open it in Internet Explorer again, and note that the server name has changed.

► To test the local data set caching

1. Rerun the executable, and choose Yes to the warning message. This will connect to the central database, and download a list of employees from the database.

2. In the Get from central database dialog box, choose Dodsworth, Anne for the employee name and click OK. You will then see all the customers (and their orders and order details) managed by Anne.

3. Close the application. This will automatically save the data set into the same XML file that stored the application settings.

4. Reopen the OnTheRoad.xml file using Internet Explorer.

5. Choose the Edit - Find (on This Page)... menu item to search for the XML elements that begin with: <Products, <Employees, <Customers, <Orders, <OrderDetails, and <AppSettings. Review the contents.

6. Rerun the executable. Notice you are no longer shown the warning message because the XML file contains a complete and valid data set.

7. In the data grid, expand the customer with the company name of Around The Horn. Notice it currently has two orders. Change the order date of the first order to today's date.

8. Expand the first order and add a third order detail row, for a product ID 1, with a unit price of 25 and a quantity of 4. Click on the first or second row to make sure the change is made to the data set.

9. Choose the Update to central database menu item. In the central database, one row will be added to the OrderDetails table and one row in the Orders table will be modified.

10. Use the Server Explorer to check that the changes were successfully made.

Note Lab 6.1 only deals with retrieving data from the central database. Lab 6.2 deals with updating the central database.

► To remove the stored procedures used by the solution

1. Start the Microsoft SQL Server Query Analyzer.

2. Open the script named lab6reset.sql in this folder: <install path>\2389\Labs\Lab06_1\

3. Run the script.

4. Exit the Microsoft SQL Server Query Analyzer.

► To review the starter solution

1. Start the Microsoft Visual Studio .NET development environment.

2. Open the existing project named OnTheRoad. The location is

<install path>\2389\Labs\Lab06_1\Starter\xx\ where xx is either VB or CS.

3. Open each of the following files using the Designer view and notice that they each provide a very simple dialog box user interface for performing certain tasks.

Form Description

About Shows copyright and version information.

Logon Allows the user to pick a named employee from a list and then retrieves the customer data associated with that employee from the central database.

Options Allows the user to change the SQL Server name of the central database.

4. Open the file named MainForm in Designer view, and review the menu and its items. The menu items will perform the following tasks.

Menu Task

File - Get from central database... Shows the Logon form

File - Update to central database Updates the central database with the

latest changes made in the grid Ends the application Shows the Options form Shows the About form

► To test the starter solution

• Run the starter solution and click each of the menu items.

0 0

Post a comment