以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  处理多张表的全局表事件方法  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=170298)

--  作者:yfy13338431925
--  发布时间:2021/7/21 4:28:00
--  处理多张表的全局表事件方法

项目中有十几张表,每张表均有相同的两个列,如A列和B列

需求:如何用全局表事件,把两列做字符串连接,像这样A-B,填充到C列中

 


--  作者:有点蓝
--  发布时间:2021/7/21 8:45:00
--  
datacolchanged事件

If e.DataTable.DataCols.Contains("A列") andalso e.DataTable.DataCols.Contains("B列") andalso e.DataTable.DataCols.Contains("C列") then
    Select Case e.DataCol.Name
        Case  "A列","B列"
            e.DataRow("C列") = e.DataRow("A列") & "" & e.DataRow("B列")
    End Select
End If

--  作者:yfy13338431925
--  发布时间:2021/7/21 9:53:00
--  

十几张表,表名第一个字是“第”字,在全局事件PrepareEdit中怎么改写下面的代码

If e.DataTableName Like "第*" Then
If e.DataTable.datacols.contains("档案编号") Then  
    If e.Table.current.IsNull("档案编号") Or e.Table.current.IsNull("类号") Then
        e.Table.current("数字化编号")=""
    Else
        e.Table.current("数字化编号") = e.Table.current("档案编号")&"-" &"RS"& e.Table.current("类号")  

    End If
End If
End If


--  作者:有点蓝
--  发布时间:2021/7/21 9:57:00
--  
代码放到datacolchanged事件

If e.DataTableName Like "第*" Then
If e.DataTable.datacols.contains("档案编号") Then  
    If e.datarow.IsNull("档案编号") Orelse e.datarow.IsNull("类号") Then
        e.datarow("数字化编号")=nothing
    Else
        e.datarow("数字化编号") = e.datarow("档案编号")&"-" &"RS"& e.datarow("类号")  

    End If
End If
End If


另外除了currentchanged事件,其它表事件尽量不要使用current这种用法,除了坑没有其它的


--  作者:yfy13338431925
--  发布时间:2021/7/21 10:11:00
--  
datatablename 不是datacoleventargs的成员
--  作者:有点蓝
--  发布时间:2021/7/21 10:31:00
--  
e.DataTable.Name
--  作者:yfy13338431925
--  发布时间:2021/7/21 11:43:00
--  
怎样在命令窗口对上述的表批量加入一个同名的字符型列
[此贴子已经被作者于2021/7/21 11:47:14编辑过]

--  作者:有点蓝
--  发布时间:2021/7/21 11:58:00
--  
参考:http://www.foxtable.com/webhelp/topics/2122.htm