StrataFrame Forum

How to handle an editing issue

http://forum.strataframe.net/Topic11386.aspx

By Tim Dol - 9/7/2007

I'm using a legacy database whereby the customer data was split up into two databases, so I have two BO's, say CustA and CustB.  Relationships are not set right now.

I have a form with the two BO's (CustA and CustB).  CustA is the primaryBO.  I fill CustB within the CustA_Navigated event. Everything is fine when the customer record exists in both tables, however when the customer record does not exits in CustB, which it will on occasion, I get an error indicating that there are no rows in the current datatable (CustB), when I click on the edit button on the maintenance form tool strip.

What I want to do is add some code to automatically perform an 'Add' on CustB when the editing state on CustA changes to 'Edit ', however the error occurs before the event is fired.  I also tried the  CustB's EditingStateChanged event and the FormEditingStateChanged event, but the error occurs before these events are fired as well.

Any idea on how to handle this particular issue?

Thanks

Tim

By Greg McGuffey - 9/7/2007

There a couple of settings that you might want to check. On the form, is the IncludeInFormEditType set to All Business Objects or Determine By Business Object? And on CustB BO, is the IncludeInFormEdit set to True?



The combination of these determine if the BO changes state (add/edit/save/undo/delete) when a maintenance form toolstrip button is clicked. In your case I believe you want the IncludeInFormEditType set to Primary Business Object, assuming CustA is the primary business object. The primary business object is typically the first one dropped on the form, so that may be causing problems too, if CustB was dropped first. I think you can set the primary business object right in the designer on the form's property sheet.



Once you have CustB no longer being put into edit/add, etc., then I think reacting to the EditingStateChanged on CustA would work fine.



Hope that helps.
By StrataFrame Team - 9/10/2007

Yep, you might also fix this by testing on the CustB.IsEmpty or CustB.Count > 0 just after you fill it, and if it's empty, then call Add() on it.