Hello!
Making a new desktop app, I'm trying to find an efficient way to fill dynamically EditText, Label, ComboBox and DatePicker objects of my forms.
So, I did the following steps:
1. I gave the exact database table field names as values to the Tags of the form objects.
2. I wrote a Sub to make a request to the jRDC2.
3. I wrote a Sub to fill dynamically the objects with database values.
The 3rd step is my question. Do you think that it's OK, or do you have to suggest another way?
The sub is the following:
Thank you in advance!
Making a new desktop app, I'm trying to find an efficient way to fill dynamically EditText, Label, ComboBox and DatePicker objects of my forms.
So, I did the following steps:
1. I gave the exact database table field names as values to the Tags of the form objects.
2. I wrote a Sub to make a request to the jRDC2.
3. I wrote a Sub to fill dynamically the objects with database values.
The 3rd step is my question. Do you think that it's OK, or do you have to suggest another way?
The sub is the following:
fillFormData:
Private Sub fillFormData(res As DBResult)
For Each n As Node In pnlItems.GetAllViewsRecursive
Private idx As Int = 0
If n.Tag = "" Then Continue
For Each col In res.Columns.Keys
If n.Tag = col Then
If n Is TextField Then
Private t As TextField = n
Private row() As Object = res.Rows.Get(0)
t.Text = utils.ifNull(row(idx),"")
End If
If n Is Label Then
Private l As Label = n
Private row() As Object = res.Rows.Get(0)
l.Text = utils.ifNull(row(idx),"")
End If
If n Is DatePicker Then
Private d As DatePicker = n
Private row() As Object = res.Rows.Get(0)
If utils.ifNull(row(idx),"") <> "" Then
d.DateTicks = row(idx)
Else
d.DateTicks = 0
End If
End If
If n Is ComboBox Then
Private c As ComboBox = n
Private row() As Object = res.Rows.Get(0)
c.SelectedIndex = utils.ifNull(row(idx),0)
c.Value = c.Items.Get(c.SelectedIndex)
End If
If n.Tag = "low_stock_alert_active" Then
swAlertStock.CheckState = utils.switchVal(swAlertStock, utils.ifNull(row(idx),"0"))
End If
If n.Tag = "next_order_alert_active" Then
swNextOrder.CheckState = utils.switchVal(swNextOrder, utils.ifNull(row(idx),"0"))
End If
If n.Tag = "discount_active" Then
swDiscountActive.CheckState = utils.switchVal(swDiscountActive, utils.ifNull(row(idx),"0"))
End If
End If
idx = idx + 1
Next
Next
txtCode.RequestFocus
End Sub
Last edited: