How would you improve this?

The code below is what is mostly generated by Iron Speed code designer. I usually do most of the look up information linking on the database using foreign key links.

The look up table has three columns. A system id or code, a meta_type for categories and a description.

The filtering category is placed at the “somevalue” place holder. This whole thing is inserted into the section where the function affects the rows in question.

Some databases have multiple look up tables I use mostly one with categories to filtered for each look up.

Simple lookup table design.

Lookup table design.


#Region “Code Customization”

”’
”’ Override the PopulateSYS_IDDropDownList function to filter contents of Dropdown list.
”’
Protected Overrides Sub PopulateCODE_SYSIDDropDownList( _
ByVal selectedValue As String, _
ByVal maxItems As Integer)

‘ Set up the WHERE clause.
Dim wc As WhereClause = New WhereClause
wc.iAND(CODE_TABLETable.META_TYPE, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, “somevalue“)

Dim orderBy As OrderBy = New OrderBy(False, True)
orderBy.Add(CODE_TABLETable.SYS_ID, BaseClasses.Data.OrderByItem.OrderDir.Asc)

Me.CODE_SYSID.Items.Clear()
Dim itemValue As CODE_TABLERecord
For Each itemValue In CODE_TABLETable.GetRecords(wc, orderBy, 0, maxItems)

‘ Create the item and add to the list.
Dim cvalue As String = itemValue.SYS_ID.ToString()
Dim fvalue As String = itemValue.Format(CODE_TABLETable.DESCRIPTION)
Dim item As ListItem = New ListItem(fvalue, cvalue)
Me.CODE_SYSID.Items.Add(item)
Next

‘ Set up the selected item.
If Not selectedValue Is Nothing AndAlso _
selectedValue.Trim “” AndAlso _
Not SetSelectedValue(Me.CODE_SYSID, selectedValue) Then
Dim fvalue As String = OSERVICES_PROVIDEDTable.CODE_SYSID.Format(selectedValue)
Dim item As ListItem = New ListItem(fvalue, selectedValue)
item.Selected = true
Me.CODE_SYSID.Items.Insert(0, item)
End If

‘ Add the Please Select item.
Me.CODE_SYSID.Items.Insert(0, New ListItem(MiscUtils.GetValueFromResourceFile(“Txt:PleaseSelect”, “Application”), “–PLEASE_SELECT–“))
End Sub

#End Region

Advertisements

One Response to How would you improve this?

  1. […] This post was mentioned on Twitter by Otto Astorga. Otto Astorga said: Any suggestions? http://is.gd/bBjUX Looking up the look up! […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: