以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]关于逻辑型列的代码求助 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=149017) |
-- 作者:huangfanzi -- 发布时间:2020/4/21 13:18:00 -- [求助]关于逻辑型列的代码求助 老师,下面红字部分应该如何处理,谢谢! Dim tbl As Table = Tables(e.Form.Name & "_Table_对外采购") Dim tbx_加载树对外采购 As WinForm.TextBox = e.Form.Controls("TextBox_加载树对外采购") Dim nms As String() = tbx_加载树对外采购.Text.Split(",") \'指定生成目录树的各列 Dim qts As String() \'将各列的值括起来的符号数组,会从fh集合中引入 Dim fh As New List(Of String) \'将各列的值括起来的符号集合,字符与日期用单引号,数值不用符号,逻辑型怎么办啊 Dim jh As New List(of String) jh.AddRange(nms) \'将数组中的元素全部加入到集合中 For Each nm As String In jh If tbl.Cols(nm).IsString OrElse tbl.Cols(nm).IsDate Then fh.Add("\'") ElseIf tbl.Cols(nm).IsNumeric Then fh.Add("") Else If tbl.Cols(nm).IsBoolean Then fh.Add("") End If Next qts = fh.ToArray() \'集合转数组 Dim trv As WinForm.TreeView = e.Sender Dim flt As String Dim flt1 As String = "类型 = \'采购\'" Dim nd As WinForm.TreeNode For Each nd In e.node.allNodes \'清除子节点的选中标记 nd.Checked = False Next nd = e.Node.ParentNode Do While nd IsNot Nothing \'清除父节点的选中标记 nd.Checked = False nd = nd.ParentNode Loop For Each nd In trv.AllNodes If nd.Checked Then Dim rts() As String = nd.FullPath.Split("\\") Dim val As String = "" For i As Integer = 0 To rts.length - 1 If val > "" Then val = val & " And " End If val = val & nms(i) & " = " & qts(i) & rts(i) & qts(i) Next If flt > "" Then flt = flt & " Or (" & val & ")" Else flt = val End If End If Next If flt = Nothing Then flt = "[编号] Is Null" Else flt = flt1 & " And (" & flt & ")" End If Dim dt As DataTable = DataTables(e.Form.Name & "_Table_对外采购") With dt .LoadFilter = flt \'设置加载条件 .LoadPage = 0 \'加载第一页 .LoadTop = 2 \'每页加载的行数 .LoadOver = "编号" \'加载分页字段 .Load() e.Form.Controls("TextBox1").Value = 1 & "/" & .TotalPages End With
|
-- 作者:有点蓝 -- 发布时间:2020/4/21 13:40:00 -- 逻辑型和数值一样不需要单引号 |
-- 作者:huangfanzi -- 发布时间:2020/4/21 14:01:00 -- 可是不行,用逻辑列加载数据时报错,我在想,如果是假,数据库中是 0 ,真是 1,不是在FT中看到的 TRUE与FALSE [此贴子已经被作者于2020/4/21 14:01:36编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/4/21 14:04:00 -- 那么逻辑列就要另外处理了,如果是true,改为1这样 |
-- 作者:huangfanzi -- 发布时间:2020/4/21 14:17:00 -- 就是不会改啊,顶楼的代码是帮助文件中抄来的,放在AfterCheckNode中 蓝版,能帮我改下吗? |
-- 作者:有点蓝 -- 发布时间:2020/4/21 14:23:00 -- 比如 For Each nd In trv.AllNodes If nd.Checked Then Dim rts() As String = nd.FullPath.Split("\\") Dim val As String = "" For i As Integer = 0 To rts.length - 1 If val > "" Then val = val & " And " End If if rts(i).tolower = "true" val = val & nms(i) & " = 1" elseif rts(i).tolower = "false" val = val & nms(i) & " = 0" esle val = val & nms(i) & " = " & qts(i) & rts(i) & qts(i) end if Next If flt > "" Then flt = flt & " Or (" & val & ")" Else flt = val End If End If Next |