以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]一个订单号有多个产品,一个产品也有多个订单号。  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=184459)

--  作者:mengxxaa
--  发布时间:2022/12/8 11:16:00
--  [求助]一个订单号有多个产品,一个产品也有多个订单号。
一个客户订单号有多个产品,一个产品也有多个客户订单号。如何实现在订单和产品对应上了,把客户的其他信息跨表引用过来。
--  作者:有点蓝
--  发布时间:2022/12/8 11:20:00
--  
参考:http://www.foxtable.com/webhelp/topics/1451.htm
--  作者:mengxxaa
--  发布时间:2022/12/8 11:48:00
--  
If (e.DataCol.Name = "dnd_so " and e.DataCol.Name = "dnd_wo_part " ) Then
    Dim nms() As String = {"dnd_cust","dnd_cust_part","dnd_xl","dnd_dy","dnd_rl","dnd_zj","dnd_gd","dnd_rc"}
    If e.NewValue Is Nothing Then
        For Each nm As String In nms
            e.DataRow(nm) = Nothing
        Next
    Else
        Dim dr As DataRow
        dr = DataTables("so_det").Find("(so_cust_dh = \'" & e.NewValue & "\') and(so_part = \'" & e.NewValue & "\')")
        If dr IsNot Nothing
            For Each nm As String In nms
                e.DataRow(nm) = dr(nm)
            Next
        End If
    End If
End If

这样的代码不生效呢。两个表,一个so_det表,一个dnd_det表,两个表通过so_part=dnd_wo_part和so_cust_dh=dnd_so建立了关联。在关联表上创建数据时,要把so_det上的一些数据引入到关联表上。

--  作者:有点蓝
--  发布时间:2022/12/8 11:57:00
--  
1、代码有多余的空格
If (e.DataCol.Name = "dnd_so " and e.DataCol.Name = "dnd_wo_part " ) Then

2、判断一个列才使用e.NewValue,多个列使用e.datarow,自己调试对比看看就明白了

msgbox(("(so_cust_dh = \'" & e.NewValue & "\') and(so_part = \'" & e.NewValue & "\')"))
msgbox(("(so_cust_dh = \'" & e.datarow("dnd_so") & "\') and(so_part = \'" & e.datarow("dnd_wo_part") & "\')"))


--  作者:mengxxaa
--  发布时间:2022/12/8 13:44:00
--  
If (e.DataCol.Name = "dnd_so" and e.DataCol.Name = "dnd_wo_part" ) Then
    Dim nms() As String = {"dnd_cust","dnd_cust_part","dnd_xl","dnd_dy","dnd_rl","dnd_zj","dnd_gd","dnd_rc"}
    If e.NewValue Is Nothing Then
        For Each nm As String In nms
            e.DataRow(nm) = Nothing
        Next
    Else
        Dim dr As DataRow
        dr = DataTables("so_det").Find("(so_cust_dh = \'" & e.datarow("dnd_so") & "\') and(so_part = \'" & e.datarow("dnd_wo_part") & "\')")
        msgbox(("(so_cust_dh = \'" & e.datarow("dnd_so") & "\') and(so_part = \'" & e.datarow("dnd_wo_part") & "\')"))
        If dr IsNot Nothing
            For Each nm As String In nms
                e.DataRow(nm) = dr(nm)
            Next
        End If
    End If
End If
还是一点反应都没有呢,也没任何提示信息蹦出来。我在子表dnd_det上用代码做了实时更新的目录树,又在关联表上做跨表引用,两者会不会冲突呢,什么时候做目录树,什么时候做跨表引用呢?还请老师指点一二,看下代码错在哪里?


--  作者:有点蓝
--  发布时间:2022/12/8 13:54:00
--  
If e.DataCol.Name = "dnd_so" orelse e.DataCol.Name = "dnd_wo_part"  Then

--  作者:mengxxaa
--  发布时间:2022/12/8 14:22:00
--  
If  e.DataCol.Name = "dnd_so" orelse e.DataCol.Name = "dnd_wo_part"  Then
    Dim nms() As String = {"dnd_cust", "dnd_cust_part", "dnd_xl", "dnd_dy", "dnd_rl", "dnd_zj", "dnd_gd", "dnd_rc"}
    If e.NewValue Is Nothing Then
        For Each nm As String In nms
            e.DataRow(nm) = Nothing
        Next
    Else
        Dim dr As DataRow
        dr = DataTables("so_det").Find("(so_cust_dh = \'" & e.DataRow("dnd_so") & "\') and(so_part = \'" & e.DataRow("dnd_wo_part") & "\')")
        msgbox(("(so_cust_dh = \'" & e.DataRow("dnd_so") & "\') and(so_part = \'" & e.DataRow("dnd_wo_part") & "\')"))
        If dr IsNot Nothing Then
            For Each nm As String In nms
                e.DataRow(nm) = dr(nm)
            Next
        End If
    End If
End If

提示列不属于表

--  作者:mengxxaa
--  发布时间:2022/12/8 14:23:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:3.png
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:2.png
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2022/12/8 14:30:00
--  
提示很明显了,如果2个表列名不一致,参考:http://www.foxtable.com/webhelp/topics/1533.htm,看第二段代码的用法
--  作者:mengxxaa
--  发布时间:2022/12/8 15:13:00
--  
If e.DataCol.Name = "dnd_so" OrElse e.DataCol.Name = "dnd_wo_part" Then
    Dim Cols1() As String = {"so_cust", "so_cust_part", "so_xl", "so_dy", "so_rl", "so_zj", "so_gd", "so_rc"}
    Dim Cols2() As String = {"dnd_cust", "dnd_cust_part", "dnd_xl", "dnd_dy", "dnd_rl", "dnd_zj", "dnd_gd", "dnd_rc"}
    For Each dr1 As DataRow In DataTables("so_det").Select("so_cust_dh", "so_part")
    Dim dr2 As DataRow = DataTables("dnd_det").AddNew()
    For i As Integer = 0 To Cols1.Length - 1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
Next
    Dim nms() As String = {"dnd_cust", "dnd_cust_part", "dnd_xl", "dnd_dy", "dnd_rl", "dnd_zj", "dnd_gd", "dnd_rc"}
    If e.NewValue Is Nothing Then
        For Each nm As String In nms
            e.DataRow(nm) = Nothing
        Next
    Else
        Dim dr As DataRow
        dr = DataTables("so_det").Find("(so_cust_dh = \'" & e.DataRow("dnd_so") & "\') and(so_part = \'" & e.DataRow("dnd_wo_part") & "\')")
        msgbox(("(so_cust_dh = \'" & e.DataRow("dnd_so") & "\') and(so_part = \'" & e.DataRow("dnd_wo_part") & "\')"))
        If dr IsNot Nothing Then
            For Each nm As String In nms
                e.DataRow(nm) = dr(nm)
            Next
        End If
    End If
End If


这里For Each dr1 As DataRow In DataTables("so_det").Select("so_cust_dh", "so_part")用什么条件查找呢,现在提示筛选表达式“so_cust_dh”的计算结果不是 Boolean 值项。