I am trying to create a form which will be fed by an underlying database to create multiple form fields for each entry in an underlying database table. This is for a program to monitor patients under anesthesia, and prior to surgery, the doctor will choose which monitors they will be using. Then, on the actual monitor screen which will pop up every X minutes, there will be a text box and a check box for each chosen monitor. I am relatively new to VB, so I have tried to illustrate what I am needing but using the logic that I know from my previous life in PHP.
I am using DevExpress's layout control to place the form fields, so that is the code in the middle of the first loop (on_load), and I know that part works, I just need to know how to name the fields and then recover those fields and commit the values to the database. (the text boxes are added to the database, the check boxes are used to determine if an entry is made for that monitor- i.e. at the end of surgery if a monitor is turned off)
I know that my syntax for naming the fields is no where close to correct, and it probably would not work in PHP, but I remember doing something like this in a PHP application I built long ago.
How do I do this?????? Any help would be greatly appreciated!
Imports DevExpress.XtraLayout
Imports DevExpress.XtraEditors
Public Class frmMonitorRecord
Private m_dtDataTable As New VDARSQLDATASET.Monitor_ValueDataTable
Private tableAdapter As New VDARSQLDATASETTableAdapters.Monitor_ValueTableAdapter
Private drDataRow As DataRow
Private dtCaseMonitors As New VDARSQLDATASET.caseMonitorsDataTable
Private taCaseMonitors As New VDARSQLDATASETTableAdapters.caseMonitorsTableAdapter
Private caseMonitors As DataRow
Private tableAdapterInsert As New VDARSQLDATASETTableAdapters.inductionMaint_ParameterValueTableAdapter
Private Sub frmMonitorRecord_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SystemSounds.Exclamation.Play()
lblRecordTime.Text = CStr(frmMainForm.curTime) + CStr(" Minutes")
dtCaseMonitors = taCaseMonitors.GetDataByCaseID(frmMainForm.SelectedCase)
For i = 0 To dtCaseMonitors.Rows.Count - 1 Step 1
caseMonitors = dtCaseMonitors.Rows(i)
'Create a layout item and add it to the root group.
Dim item As LayoutControlItem = LayoutControl1.Root.AddItem
' Set the item's Control and caption.
item.Name = "Layout Item " + i
item.TextVisible = False
Dim spinBox = New SpinEdit()
spinBox.Name = "spn" + i
item.Control = spinBox
'Create a layout item and add it to the root group.
Dim item2 As LayoutControlItem = LayoutControl1.Root.AddItem
' Set the item's Control and caption.
item2.Name = "Layout Item " + i + "b"
item2.TextVisible = True
Dim chkBox = New CheckEdit()
chkBox.Name = "chk" + i
item2.Control = chkBox
item2.Text = caseMonitors("monitorName")
item2.TextLocation = DevExpress.Utils.Locations.Right
item2.Move(item, Utils.InsertType.Right)
m_dtDataTable = tableAdapter.GetDataByIndvParameter(frmMainForm.SelectedCase, frmMainForm.prevTime, caseMonitors("monitorID"))
If Not frmMainForm.prevTime = Nothing Then
If Not m_dtDataTable.Rows.Count = 0 Then
drDataRow = m_dtDataTable.Rows(0)
spinBox.Value = CDec(drDataRow("parameterValue"))
chkBox.CheckState = CheckState.Checked
Else
spinBox.Value = Nothing
chkBox.CheckState = CheckState.Unchecked
End If
End If
Next
End Sub
Private Sub btnAccept_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAccept.Click
For i As Integer = 0 To dtCaseMonitors.Rows.Count - 1 Step 1
If "chk" + i.CheckState = CheckState.Checked Then
tableAdapterInsert.InsertQuery(frmMainForm.SelectedCase, 1, frmMainForm.curTime, spin + i.Value)
End If
Next
Me.Close()
End Sub
Private Sub tmrSound_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSound.Tick
SystemSounds.Exclamation.Play()
End Sub
End Class