StrataFrame Forum

Validating fields

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

By Ger Cannoll - 10/28/2009

I have a no. of fields on a form that I want to validate and prevent saving of the form until these are validated. Sort of things would be Rep, Area, County, Country, Dept etc. These could all be on the one form and are on the one Lookup table, referenced by a Lookup type key.

I have a Business Object set up with these Lookup lists and know I can check the Business Object...and that will work fine.

However , what normally tends to happen, is that a user is entering the details, realises say that there is an invlaid Dept. Then either that use, or perhaps a supervisor on another screen,  will 'add' in the Dept so the Lookup table, so it  is now up to date.

But, back to the user, who does not want to leave the exisitng form because they may have spent the last 5 mins entering data, has the old business object wihout the new dept.

Is it necessary , in these situations, to interrogate the database , or can the business object be 'refreshed' without leaving the form, so that any recent additions to the lookup table will be reflected in the 'Lookup' business object

By Ger Cannoll - 10/28/2009

I have been giving this further thought , and I think what I need is as follows, but if there is a better/alternative way of doing this, please jump in

On Business rules of my mian BusinessObject that I am saving, do following:

  a)Do a MyLookupBO.FillAll  (Should refresh the Bus Object for the Lookup Table...is there any issue referencing another Bus Object like this)

  b)For each of my Fields that I want to validate from the Lookup Table, do a Seek or a Search for the sepcific key I am looking for

  c)If the key does not exist on the lookup table, add a record to the Broken Rules collection

If there are any entries on the Broken Rules collection, I should not be allowed to save the form

By Edhy Rijo - 10/29/2009

Hi Gerard,



When I have a combobox getting the data directly (not using the BO.CopyDataFrom) I simply add a button on the form that will requery() all comboboxes in a single pass. And when using BO.CopyDataFrom... to populate the combos I have a single method that will load all the lookup data using the BusinessLayer.FillMultipleDataTables and then requery all the combos.



When using a ChildFormDialog control, in those child forms I follow the logic used in the StrataFlix project to call the BO.CheckRules(True) in the OK button and act based on the result, this is very useful to validate data on the child forms (not that I am a real fan of modal child forms) but for now it has been working just fine.



Take a look at the StrataFilx project in your spare time, there are many good things in there.
By Trent L. Taylor - 10/29/2009

If that meets your needs then great.  Another approach that we use is a "Refresh" link (or button) on the dialog that refreshes all of the lookup combos or lists allowing this very behavior.  By doing this, I can leave the record I am working on intact, go add a record to a lookup, click the refresh (which may requery the combos) and the new value is there without me having to have saved the record I am working on. 

The above image is a menu that shows all of the possible lookup values.  If I click any of them, it takes me to the maintenance for them (while leaving the record I am working on alone and still up).  Once the new record is added to the lookup, the end-user can click the Refresh Controls link and the combos and lists on this dialog will refresh.

Another approach that we use on certain things is a custom control that allows us to search, modify, or add a new record without ever leaving the dialog.

In the above image, you can see that the user could search for an existing employer or add a new one.  If one were loaded, then you could edit the employer.  The last button is to clear out the value as we do not allow the end-user to just type in a value (for this control anyway).

By Edhy Rijo - 10/29/2009

Trent L. Taylor (10/29/2009)
... If I click any of them, it takes me to the maintenance for them (while leaving the record I am working on alone and still up). Once the new record is added to the lookup, the end-user can click the Refresh Controls link and the combos and lists on this dialog will refresh.


Hi Trent,



Obviously you are not using ChildFormDialog controls since this will show the form on a modal state. I really would like to get rid on some modal forms to allow this kind of flexibility to the user.
By Trent L. Taylor - 10/29/2009

Well, in this example no. But the only reason would be because the record is not a child of this data, but rather a foreign key value. That being said, you could actually use the ChildFormDialog if you needed to.