« first  « prev 

Jump to:


Clever Contact Details

OK, didn't take long to get the contact details stuff working in a ncier way. I'm not going to go over the top with explaination here, since I didn't do anything I haven't already explained elsewhere.

First step was to add an "Address Type" combo box by dragging the field from the Data Sources pane and setting up the data binding. Then I replaced the nasty (in this case anyway) data grid view for a set of edit boxes...

An image

Only other thing to do was to create a new "FillByContactNoAndAddressType" method for the contactDetailsTableAdaptor. The two parameters will use ID values from the contacts list and the Address Type combo box we just added to select one contact details record.

Then I added an event handler to addressTypesBiungingSource.CurrentChanged and updated the code thusly...

private void updateContactDetails()
{
  DataRowView contactsRow = (DataRowView)this.contactsBindingSource.Current;
 
  if (!(contactsRow is DataRowView))
    return;
 
  int contactId = (int)contactsRow["CONTACTNO"];

  DataRowView addressTypeRow = (DataRowView)this.addressTypesBindingSource.Current;

  if (!(addressTypeRow is DataRowView))
    return;
   
  int addressTypeId = (Int16)addressTypeRow["ADDRESSTYPENO"];

  this.contactDetailsTableAdapter.FillByContactAndAddressType(
            this.phlabDataset.CONTACTDETAILS, contactId, addressTypeId);
}

private void contactsBindingSource_CurrentChanged(object sender, EventArgs e)
{
  updateContactDetails();
}

private void addressTypesBindingSource_CurrentChanged(object sender,
                                                        EventArgs e)
{
  updateContactDetails();
}


The event handlers call the "updateContactDetails()" method, which fetches the appropriate IDs and calls the fill method for contact details. The resulting data is then displayed, as may be expected, in the various edit boxes.

I think I might have enough to fill (easily) the my 50 minute presentation slot so I'm not going to develop this any further for the moment.

It's been quite a learning curve and such a change from working with components and development environments that actually require the writing of code! Here are some last minute screen shots, showing the contact details system...

An image

An image

An image

« first  « prev 

Jump to: