StrataFrame Forum

Use BrowseDialog to fill some fields

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

By Juan Carlos Pazos - 6/24/2008

Hi

I'm using BrowseDialog in may forms in my application, of course the BrowseDialog is always used to find an specific record.

I have the idea of use BrowseDialog just to fill some fields in my form, not to recover a record.

I will try to describe the idea:

I have a form to contacts, is a normal maintenance form, it has a BrowseDialog for find contacts. Part of the information of contacts is State - City - Locality - Postal Code. Some we have a field for each value, I use combos to select the state, based on selected other combo is filled with the city in locality I can use another combo too. But as the Postal Codes table has the information of locality, city and state, I think users can select a postal code and the fields of locality, city and state can be filled.

The idea is use a BrowseDialog where users can search by postal code, state, or any other of the fields there, once the found the desired record, when go back to the form this will fill the text boxes according to their selection. Is this possible with BrowseDialog?

Waiting for your valuable comments.

Regards.

By Guillermo Vilas - 6/24/2008

Hello Juan Carlos

It is possible, although I'm not sure the best approach.



The way I'm implementing this is:

1. Create a table that will contain zip codes, state, county information.

2. Create a BO to map that table: ZipCodesBO

3. Add the BO to the Customer Form (CustomerBO and ZipCodeBO)

4. Drop a BrowseDialog to the form and setup to fill de ZipCodeBO with the results

5. You may want to add a custom button to handle the ZipCodeBrowseDialog call or add the call method in a text validated event so after the user types a zip code the ZipCodeBrowseDialog will show but I'm not sure if you can pass the text entered as initial SearchField.

6. The if you have a TextBox to populate with the results it will need to map to the ZipCodeBO not the CustomerBO.



Hope it helps
By Edhy Rijo - 6/25/2008

Juan Carlos, Guillermo,

As far as I know the Dialog Browser will always display the records found in the search so the user can select the one they want to show in the form.  With this in mind, Juan Carlos, unless you want your end user to be always presented with the Dialog Browser to choose the data, then that may work.

On the other hand, your requirement is pretty simple, you just need a function, probably a Shared one which will return the City/State values when passed the zipcode value.  There are many variations of this one, also there are a couple of free Web Services which will accept the zip code value as a parameter and return you an XML file with the City/State values.

I believe that using the Dialog Browser for this would be overkill for the application and mostly the end user.

By Dustin Taylor - 6/25/2008

Juan,

The above ideas are good and would certainly work, but I'd actually recommend using a shared class rather than trying to plug additional logic into the browse dialog. 

In our medical app, we have a shared, non-inheratible class that can be referenced from any maintenance form.  Whenever a zip code is entered on a maintenance form, we call a method on that shared zip code class that will return the associated area code, city, and state so that those values may be used to populate the appropriate fields.  Our class does a few more fancy things than just that, but returing the derived information is it's core purpose, and it works very well.

Browsing on the zip code is somewhat unecessary since that is one thing people will typically know without having to search for it.  Once it is entered, you can then use that value to populate the remaining fields automatically without ever needing to use a browsedialog.

Hope it helps,

Dustin

By Juan Carlos Pazos - 6/25/2008

Hi Guillermo, Edjy and Dustin

Thanks for your ideas. Dustin yours is the more close to what I want to do. The web service is fine, but the postal codes are from Mexico and the information is not complete, I have all the complete database of postal codes with all details of information.

Can you put some code for have an starting point?

Thanks in advance.

By Dustin Taylor - 6/25/2008

Sure Smile

Here is a slightly simplified version of what we do:

Public Shared Function GetZipCode(ByVal ZipCode As String) As ZipCodeItem
   '-- Establish Locals
   Dim loReturn As ZipCodeItem
   '-- Create a new item
   loReturn = New ZipCodeItem()
   '-- Load the BO
   ZipCodesBO.FillByZipCode(ZipCode)
   '-- See if a record was found
   If ZipCodesBO.Count > 0 Then
      loReturn.AreaCode = ZipCodesBO.AreaCode.Trim()
      loReturn.City = ZipCodesBO.City.Trim()
      loReturn.State = ZipCodesBO.State.Trim()
      loReturn.ZipCode = ZipCode.Trim()
   End If
   '-- Return the results
   Return loReturn
End Function

 

We call the above method on the shared class whenever we want to get the details for a given zip code. A "ZipCodeItem" is returned, containing the details found there (AreaCode, City, State, ZipCode). As you can see, within the method we pull the zip code information into a temporary instance of our own ZipCode BO, but you could do the same with a straight SQL query if you would prefer and cut out that temporary BO all together.

By Guillermo Vilas - 6/25/2008

You can notice the experience from a far distance BigGrin,

Dustin approach is quite simple and effective at the same time.