以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  查询与赋值并存  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=108178)

--  作者:蓝蚂蚁
--  发布时间:2017/10/17 20:47:00
--  查询与赋值并存
Dim l2 As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox2")  ‘计划类型列表
Dim l3 As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox3")  ‘配送公司列表
Dim l5 As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox5")  ‘清单列入月份列表
If e.Form.Controls("TextBox1").text<>"" Then  
    For Each r As Row In Tables("高值耗材病人使用登记表").Rows
        Dim dr As DataRow = DataTables("高值耗材病人使用登记表").Find("配送公司=\'"& l3.value &"\' and 清单列入月份=\'"& l5.value &"\' and 计划类型=\'"& l2.value &"\'" )
        If dr IsNot Nothing Then
            dr("结入月份")=e.Form.Controls("TextBox1").text
        Else
            MessageBox.show("未找到")
        End If
    Next
Else
    MessageBox.show("结入月份无数据")
End If
上面的代码想要实现的功能: 如果TextBox1里面不为空时,则在【高值耗材病人使用登记表】查找符合Find后面括号条件的数据,如果找到则在【结入月份】列填上TextBox1里面的数据。但在执行上面的代码时只在找到第一个符合条件的行填上TextBox1里面的数据,搞了很久不知道哪里出现问题。帮助里面的

Dim lst1 As New List(of DataRow)
Dim
lst2 AS New List(of DataRow)
For Each
dr As DataRow In DataTables("表A").DataRows
If DataTables(
"表A").Find("第二列 = " & dr("第一列")) Is Nothing Then
lst1
.Add(dr)
Else

lst2
.Add(dr)
End If
Next
For Each
dr As DataRow In lst1
dr
("第三列") = True
Next
For Each
dr As DataRow In lst2
dr
("第三列") = False
Next

又看不懂,麻烦老师帮解决一下,谢谢!


--  作者:有点蓝
--  发布时间:2017/10/17 20:59:00
--  
Dim l2 As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox2")  \'计划类型列表
Dim l3 As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox3")  \'配送公司列表
Dim l5 As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox5")  \'清单列入月份列表
Dim txt As String = e.Form.Controls("TextBox1").text 
If txt > "" Then
    Dim drs As List(Of  DataRow) = DataTables("高值耗材病人使用登记表").Select("配送公司=\'"& l3.value &"\' and 清单列入月份=\'"& l5.value &"\' and 计划类型=\'"& l2.value &"\'" )
    For Each dr As DataRow In drs
        dr("结入月份") = txt
    Next
Else
    MessageBox.show("结入月份无数据")
End If

--  作者:蓝蚂蚁
--  发布时间:2017/10/17 21:10:00
--  
非常感谢有点蓝老师,按您的代码问题解决了。