以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  跨表引用  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=125165)

--  作者:cd_tdh
--  发布时间:2018/9/21 11:13:00
--  跨表引用

老师,跨表引用怎么引用没加载表的数据呢?

\'跨表引用
If  e.DataCol.Name = "项目名称" Then
    Dim nms() As String = {"合同编码","所属机构","合同工期","开工日期","竣工日期","项目经理","项目总工"}
    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("合同签订").SQLFind("[项目名称] = \'" & 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


--  作者:有点甜
--  发布时间:2018/9/21 11:56:00
--  

一般,尽量加载表进来吧,不加载数据即可。这样可以用sqlfind、sqlselect等等。

 

如果你表格都不加载的话,只能写sqlcommand了 http://www.foxtable.com/webhelp/scr/0696.htm

 


--  作者:cd_tdh
--  发布时间:2018/9/21 12:41:00
--  

老师,还是请教一下Sqlcommand用法。目前有两种情况,B表加载,不管是打开审批还是直接打开都能判断

第一种情况是在A表选择项目名称,B表继承部分列,以前是加载后的方法:

\'跨表引用
If  e.DataCol.Name = "项目名称" Then
    Dim nms() As String = {"合同编码","所属机构","合同工期","开工日期","竣工日期","项目经理","项目总工"}
    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("合同签订").SQLFind("[项目名称] = \'" & 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

 

第二种情况是当B表审批状态为审批完成,C表新增行,继承B表相关数据(打开OPenQQ审批没法C表是否加载)。

 

\'勾选引用至-外经证管理
If e.DataCol.Name  = "审批状态"
    If e.DataRow("审批状态") = "审批通过" Then
        Dim nma() As String = { "ID","合同编码","所属机构","项目名称","合同工期","开工日期","竣工日期","首次申请","延期申请","自营业务证明"} \'A表数据来源列
        Dim nmb() As String = { "ID","合同编码","所属机构","项目名称","合同工期","开工日期","竣工日期","首次申请","延期申请","自营业务证明"} \'B表数据接收列
        e.DataRow.save
        Dim dr As DataRow = DataTables("外经证管理").AddNew
        For i As Integer = 0 To nma.Length - 1
            dr(nmb(i)) = e.DataRow(nma(i))
        Next
    Else
        DataTables("外经证管理").deletefor("ID = \'" & e.DataRow("ID") & "\'")
    End If
End If


--  作者:有点甜
--  发布时间:2018/9/21 14:24:00
--  

1、第一种有什么问题?代码逻辑没问题的。如果你想判断多列,修改这句代码

 

If  e.DataCol.Name = "项目名称" Then

 

2、第二种也没问题啊,你遇到什么具体情况,具体说明啊