以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 目录树与用户冲突,报错 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=177390) |
-- 作者:lgz518 -- 发布时间:2022/5/19 22:41:00 -- 目录树与用户冲突,报错 目录树与用户冲突,报错 Dim Filter As String Dim dr As DataRow = e.Node.DataRow \'获取生成此节点的行 If e.Node.Text <> "显示所有行" Then Select Case e.Node.Level Case 0 Filter = "[品名] = \'" & dr("品名") & "\'" Case 1 Filter = "[品名] = \'" & dr("品名") & "\' And [规格] = \'" & dr("规格") & "\'" \' Case 2 \' Filter = "[品名] = \'" & dr("品名") & "\' And[规格] = \'" & dr("规格") & "\' And [材质] = \'" & dr("材质") & "\'" End Select End If Tables("查询_订单明细").Filter = Filter Dim Filter As String = "制单人=\'" & _Username & "\'" Dim dr2 As DataRow dr2 = DataTables("Users").Find("[Group] = \'" & _UserGroup & "\'") Dim s As String If dr2 IsNot Nothing Then s = dr2("Xjry") If s > "" Then Filter = Filter & " or UserID in (" & s.Replace(",", ",") & ")" End If End If DataTables("订单").LoadFilter = Filter \' DataTables("订单").Load() 执行上面红字代码,报错下面提示: .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2022.5.13.2 错误所在事件:窗口,查询,TreeView2,NodeMouseDoubleClick 详细错误信息: 此行已从表中移除并且没有任何数据。BeginEdit() 将允许在此行中创建新数据 取消红字代码,目录树就正常,不报错,但需求配合红字代码,那如何改?谢谢 |
-- 作者:有点蓝 -- 发布时间:2022/5/19 23:00:00 -- 目录树不能使用主表生成,必须通过临时表生成,类似:http://www.foxtable.com/webhelp/topics/2054.htm Dim cmd As New SQLCommand |
-- 作者:lgz518 -- 发布时间:2022/5/20 8:59:00 -- 问题一:表类型:Normal,副表,按上面方法试一下,报错 .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2022.5.13.2 错误所在事件: 详细错误信息: Microsoft Jet 数据库引擎找不到输入表或查询 \'~TMPCLP入库明细\'。 确定它是否存在,以及它的名称的拼写是否正确。 |
-- 作者:lgz518 -- 发布时间:2022/5/20 8:59:00 -- 问题二:下面代码,可不可不写?因为我是项目打开,只加载用户表,权限表,其他都不加载,其他都在窗口打开来加载,不然,做100表,要写100次。 If e.DataTableName = "入库明细" Then e.SelecLString = "Sel * From {入库明细} Where [_Identify] Is Null" End If |
-- 作者:有点蓝 -- 发布时间:2022/5/20 9:17:00 -- 问题一:没有指定数据源:http://www.foxtable.com/webhelp/topics/2344.htm 二: If e.DataTableName = "用户表" orelse e.DataTableName = "权限表" Then else e.SelecLString = "Sel * From {" & DataTableName & "} Where 1=2" End If |
-- 作者:lgz518 -- 发布时间:2022/5/20 11:22:00 -- 老师,下面是目录可以,但是与用户冲突,盖掉用户的代码 Dim cmd As New SQLCommand Dim dt As DataTable cmd.ConnectionName = "外部数据源名称" cmd.CommandText = "SELECT DISTINCT 产品,客户 From {订单}" dt = cmd.ExecuteReader() Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") trv.BuildTree(dt,"产品|客户") trv.Nodes.Insert("加载所有数据",0) 使下面代码失效,原来下面代码,当前用户,有下级ID是4.6,使用上面是把所有人都列出,失去指定人只能看指定记录,要如何解决?谢谢 Dim Filter As String = "制单人=\'" & _Username & "\'" Dim dr2 As DataRow dr2 = DataTables("Users").Find("[Group] = \'" & _UserGroup & "\'") Dim s As String If dr2 IsNot Nothing Then s = dr2("Xjry") If s > "" Then Filter = Filter & " or UserID in (" & s.Replace(",", ",") & ")" End If End If DataTables("订单").LoadFilter = Filter \' DataTables("订单").Load() |
-- 作者:有点蓝 -- 发布时间:2022/5/20 11:30:00 -- cmd.CommandText = "SELECT DISTINCT 产品,客户 From {订单} where " & Filter |
-- 作者:lgz518 -- 发布时间:2022/5/20 12:09:00 -- 老师,试一下,一样列出都是所有用户,不是当前用户及下级ID的记录 |
-- 作者:有点蓝 -- 发布时间:2022/5/20 12:10:00 -- Filter 有条件吗 |
-- 作者:lgz518 -- 发布时间:2022/5/20 14:32:00 -- Dim cmd As New SQLCommand Dim dt As DataTable cmd.ConnectionName = "订单" cmd.CommandText = "SELECT DISTINCT 产品,客户 From {订单}" dt = cmd.ExecuteReader() Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") trv.BuildTree(dt,"产品|客户") trv.Nodes.Insert("加载所有数据",0) Dim Filter As String = "制单人=\'" & _Username & "\'" Dim dr2 As DataRow dr2 = DataTables("Users").Find("[Group] = \'" & _UserGroup & "\'") Dim s As String If dr2 IsNot Nothing Then s = dr2("Xjry") If s > "" Then Filter = Filter & " or UserID in (" & s.Replace(",", ",") & ")" End If End If DataTables("订单").LoadFilter = Filter \' DataTables("订单").Load() 目录树节点 Dim Filter As String If e.node.Text = "加载所有数据" Then Filter = "" Else Dim dr As DataRow = e.Node.DataRow \'获取生成此节点的DataRow Select Case e.Node.Level Case 0 Filter ="[产品] = \'" & dr("产品") & "\'" Case 1 Filter ="[产品] = \'" & dr("产品") & "\' And [客户] = \'" & dr("客户") & "\'" End Select End If DataTables("订单").LoadFilter = Filter DataTables("订单").Load() 上面是完整代码, |