Exercise 1: Modify DisplayTreeView so that it displays the phone numbers associated with each contact. The tree should display the set of phone numbers associated with a contact as a set of subnodes of the contact. Hint:
Each DataRow associated with the Contacts DataTable supports the GetChildRows method. This method returns the collection of rows of the PhoneNumbers data table that have a foreign key into the row of the Contacts table. That is, the method returns the children of the current Contacts row.
Exercise 2: Complete the DisplayPhoneNumber method. The method populates the fields of the Edit Phone Information panel with the data in the DataRow passed in to DisplayPhoneNumber an argument. The event handling code has been provided so that clicking on a phone number in the tree invokes DisplayPhoneNumber and passes it the correct DataRow. Here are some hints:
The names of the GUI elements on the Edit Phone Information panel are: txtPhoneId, txtNumber, and comboBox2.
Exercise 3: Complete the AddPhoneNumber method. The method creates a new Provider.PhoneNumber row in the database. The foreign key value, stored in the Contact field, comes from the txtConId element of the Edit Contact Information panel. The values for the remaining fields come from the Edit Phone Information elements. The method is invoked by the event handling code for the Create button. This code has been provided. Here's a big hint:
A value must be assigned to the ID column in the PhoneNumbers DataTable. Since the values in this row are type NVARCHAR the column cannot be AutoIncrement. So the “trick” used for the Contacts ID cannot be used. You can, however, mimic this technique with the following: Create a class variable phoneNumberID of type int with initial value 0. Decrement the value and use ToString to convert it to a string before assigning it to the column. The code looks like this:
... newRow["ID"] = (--phoneNumberID).ToString(); ...
Exercise 4: Complete the UpdatePhoneNumber method. The method modifies the selected phone number using the data displayed on Edit Phone Information and saves the changes to the database. The event handling for the Update button invokes UpdatePhoneNumber. The event handling code has been provided in PhoneForm.cs.
Exercise 5: Complete the DeletePhoneNumber method. The method deletes the selected phone number from the database. The event handling code for the Delete button invokes the method. The event handling code has been provided in PhoneForm.cs.