以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 求助 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=169737) |
-- 作者:cjl333333333 -- 发布时间:2021/6/28 15:10:00 -- 求助 老师,我想做一个窗口,库存表的查询窗口,然后窗口里用目录树的形式查询库存查询表的记录. 我希望打开时加载最后10记录就可以,然后窗口里的表只是查询表不要原始表. 然后里面要按年,月,还有类型这样做节点查询 下面是我写的代码,但执行总会出错 |
-- 作者:cjl333333333 -- 发布时间:2021/6/28 15:10:00 -- Dim dr As DataRow = e.Node.DataRow \'获取生成此节点的行 Dim Year As Integer = dr("年") Dim Month As Integer = dr("月") Dim nms As String() = {"年","月","出入库类型","出入库存单位名称","类型","材质"} \'指定生成目录树的各列 Dim qts As String() = {"\'","\'","\'","\'","\'","\'"} \'指定将各列的值括起来的符号,这里都是字符型,所以都是单引号 Dim trv As WinForm.TreeView = e.Sender Dim flt 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 Tables("库存表查询").Filter = flt
|
-- 作者:cjl333333333 -- 发布时间:2021/6/28 15:11:00 -- 这个是目录树节点代码 |
-- 作者:cjl333333333 -- 发布时间:2021/6/28 15:14:00 -- 还有一段窗口打开前代码总是发表不上来 |
-- 作者:cjl333333333 -- 发布时间:2021/6/28 15:16:00 -- 其实我想一个的查询表内容窗口不知结构怎么做更好 |
-- 作者:cjl333333333 -- 发布时间:2021/6/28 15:17:00 -- Dim jb As New SQLJoinTableBuilder("库存表查询","库存表主表") jb.C jb.AddTable("库存表主表","单据编号","库存表","单据编号") jb.AddCols("{库存表主表}.日期","{库存表主表}.单据编号","{库存表主表}.出入库存单位名称","{库存表主表}.承运人","{库存表主表}.出入库类型","{库存表主表}.出入库类型编号","{库存表主表}.简称","名称","编号","规格","类型","入库数量","出库数量","库存数量","单位","库存件数","重量","库存重量","备注","附件","生产单号","采购明细单号","订单编号","客户单号","包装","存放区","产品名称","入库件数","出库件数","结构","材质") jb.AddExp("年","Year({库存表主表}.日期)",True) jb.AddExp("月","month({库存表主表}.日期)",True) jb.Build() |
-- 作者:有点蓝 -- 发布时间:2021/6/28 15:17:00 -- 提示什么错误? |
-- 作者:cjl333333333 -- 发布时间:2021/6/28 15:21:00 -- Dim cmd As New SQLCommand Dim dt As DataTable cmd.C cmd.CommandText = "SELECT DISTINCT Year(日期) As 年, Month(日期) As 月,出入库类型,出入库存单位名称,类型,材质 Fr om {库存表}" dt = cmd.ExecuteReader() Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") trv.BuildTree(dt,"年|月|出入库类型|出入库存单位名称|类型|材质") Dim jb As New SQLJoinTableBuilder("库存表查询","库存表主表") jb.C jb.AddTable("库存表主表","单据编号","库存表","单据编号") jb.AddCols("{库存表主表}.日期","{库存表主表}.单据编号","{库存表主表}.出入库存单位名称","{库存表主表}.承运人","{库存表主表}.出入库类型","{库存表主表}.出入库类型编号","{库存表主表}.简称","名称","编号","规格","类型","入库数量","出库数量","库存数量","单位","库存件数","重量","库存重量","备注","附件","生产单号","采购明细单号","订单编号","客户单号","包装","存放区","产品名称","入库件数","出库件数","结构","材质") jb.AddExp("年","Year({库存表主表}.日期)",True) jb.AddExp("月","month({库存表主表}.日期)",True) jb.Build() e.form.controls("Table1").Select e.form.controls("Table1").Table.focus |
-- 作者:cjl333333333 -- 发布时间:2021/6/28 15:25:00 -- 窗口一开就出现"选择列表中的列 \'库存表主表.日期\' 无效,因为该列没有包含在聚合函数或 GROUP BY 子句中。" 这个错误对话框 |
-- 作者:有点蓝 -- 发布时间:2021/6/28 15:30:00 -- jb.AddExp("年","Year({库存表主表}.日期)",True) jb.AddExp("月","month({库存表主表}.日期)",True) 改为 jb.AddExp("年","Year({库存表主表}.日期)") jb.AddExp("月","month({库存表主表}.日期)") |