Private Sub LoadLabViewData()
Try
If objConn.State = ConnectionState.Closed Then
ConDB()
Else
End If
dtLbVw.Clear()
'pLabNoLV = "100535" 'Tmp value
strSQL = "SELECT Z.result_id,Z.lab_item_code,Z.lab_item_name,Z.result_machine,Z.lab_item_normal,Y.progress_detail " &
"FROM worklist_result Z LEFT JOIN progress Y ON Z.order_status=Y.progress_code " &
"WHERE Z.lab_number=" & pLabNoLV & " ORDER BY Z.display_order;"
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(dtLbVw)
If dtLbVw.Rows.Count > 0 Then
gvLabViewData.DataSource = dtLbVw
gvLabViewData.Columns("result_id").Visible = False
gvLabViewData.Columns("lab_item_code").Visible = False
gvLabViewData.Columns("lab_item_name").HeaderText = "รายการตรวจ"
gvLabViewData.Columns("result_machine").HeaderText = "ผลการตรวจ"
gvLabViewData.Columns("lab_item_normal").HeaderText = "ค่าปกติ"
gvLabViewData.Columns("progress_detail").HeaderText = "สถานะ"
gvLabViewData.ReadOnly = False
For Each dgvc As DataGridViewColumn In gvLabViewData.Columns
dgvc.ReadOnly = True
Next
gvLabViewData.Columns("result_machine").ReadOnly = False 'ทำไว้ให้สามารถพิมพ์ได้ แต่ให้ user เลือกจะดีกว่า
If gvLabViewData.Columns.Count >= 7 Then
Else
Dim cmb As New DataGridViewComboBoxColumn()
cmb.HeaderText = "SelectResult"
cmb.Name = "cmb"
'cmb.MaxDropDownItems = 4
'cmb.Items.Add("True")
'cmb.Items.Add("False")
For Each row As DataGridViewRow In gvLabViewData.Rows
If Not row.IsNewRow Then
GetResultList(row.Cells(1).Value)
cmb.DataSource = dt
cmb.DisplayMember = "auto_result_text"
cmb.ValueMember = "auto_result_text"
Else
End If
Next
gvLabViewData.Columns.Add(cmb)
End If
Else
gvLabViewData.DataSource = Nothing
End If
Catch ex As Exception
Throw ex
End Try
End Sub
Public Function GetResultList(ByVal pLabItemCode As Integer) As DataTable
Try
If objConn.State = ConnectionState.Closed Then
ConDB()
Else
End If
dt.Clear()
Dim str As String
str = "SELECT A.auto_result_text FROM auto_result A WHERE A.lab_item_code=" & pLabItemCode & " ORDER BY A.dis_order;"
With objCmd
.Connection = objConn
.CommandText = str
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(dt)
Return dt
Catch ex As Exception
Throw ex
End Try
End Function