Programming Lab 5: Strongly-typed Customer DataSet with Filtering, due Thursday, 11/2
Objective: To write a program using a strongly-typed DataSet and filtering via a DataView
Here are the details and rules:
- Write a program to allow the user to view, enter and save Customer and Order data like shown
here:
- Add two DataAdapter controls to your form and use the configuration wizard with each to setup SQL
statements in code. One DataAdapter will interface with the Customer table, the other with the Order
table.
- Use the Generate DataSet menu option to generate a Typed DataSet control that contains DataTables
for both tables.
- Use the View Schema feature to add the foreign key relationship and enforced constraints to the
typed DataSet.
- Add the visual controls to your form (DataGrid, Label, TextBox, Buttons)
- VB 2005 users: You'll need to use a DataGrid for this program instead of a DataGridView. So add
the DataGrid to your Toolbox using "Choose Items" like you did for the SqlDataAdapter.
- In the form's load event procedure you should load the data into the DataSet and display the
DefaultView of the Customer table in the DataGrid (by setting the DataSource). (or you may use a DataView
control on your form instead of the DefaultView, for this and the filter)
- In the "Apply Filter" button's event procedure, you should use the Customer table's DefaultView to
filter the data using the user-entered filter string. Here is an example of the results you should get:
- The user should be able to view and change all data in the Customer and Order tables via the
DataGrid. If your relationship is setup properly, Orders for a particular customer may be expanded on
the grid. Here is an example:
- Sorting of data is done automatically by the grid if you click on the column header.
- The Save button should save all changes to the database, in the proper order to avoid foreign key
and related problems. (As described at the end of Chapter 6). Test this by adding a new Customer record
and a corresponding order.
- All of your code should use the typed DataSet syntax, e.g. DsCustomer.tblCustomer instead of
DsCustomer.Tables("tblCustomer")
- When turning in your homework, turn in a zip file containing your entire solution.
For 10% Extra Credit
Make the user's filter criteria apply to the currently-displayed data; so for example if the user changes
the Filter Expression textbox in the screen above to contain "Amount > 200" and clicks "Apply Filter", they
would see just one record: order ID 13822. To do this, you may have to change the grid's data source to
only the Order table, thus changing its apperance and functionality. That's okay, as long as the user has a
way to revert back to the original Customer view, maybe by clearing the Filter Criteria and clicking "Apply
Filter" again. You can get partial extra credit for allowing some other way for the user to filter Order
data as well as Customer data.
Return to main CS 112D page