以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  期初和库存非关联表之间的数据同步  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=157771)

--  作者:青丘狐
--  发布时间:2020/10/28 13:31:00
--  期初和库存非关联表之间的数据同步

非关联表之间的数据同步
1、将期初库存表的

 

DataColChanged事件代码设置为:
Select Case e.DataCol.name
    Case "物资编号"
        Dim dr As DataRow = DataTables("库存明细表").Find("物资编号 = \'" & e.OldValue & "\'")
        If dr Is Nothing Then
            dr = DataTables("库存明细表").AddNew()
            dr("物资编号") = e.DataRow("物资编号")
            dr("货物名称") = e.DataRow("货物名称")
            dr("规格型号") = e.DataRow("规格型号")
            dr("库存重量") = e.DataRow("期初重量")
        Else
            dr("物资编号") = e.DataRow("物资编号")
        End If
    Case "货物名称","规格型号","库存重量"
        Dim dr As DataRow = DataTables("库存明细表").Find("物资编号 = \'" & e.DataRow("物资编号") & "\'")
        If dr IsNot Nothing Then
            dr(e.DataCol.Name) = e.DataRow(e.DataCol.Name)
        End If
End Select

 

2、将期初库存表的

 

DataRowDeleting事件代码设置为:


Dim dr As DataRow = DataTables("库存明细表").Find("物资编号 = \'" & e.DataRow("物资编号") & "\'")
If dr IsNot Nothing Then
    dr.Delete()
End If
显示库存重量为0  还要加计算方法吗?


--  作者:有点蓝
--  发布时间:2020/10/28 13:38:00
--  
没看懂您要解决的是什么问题?
--  作者:青丘狐
--  发布时间:2020/10/28 14:08:00
--  
录入期初重量有数据后   库存重量显示是0   想把期初表期初重量的数据 加到库存表的库存重量里
--  作者:有点蓝
--  发布时间:2020/10/28 14:27:00
--  
Case "货物名称","规格型号","期初重量"
--  作者:青丘狐
--  发布时间:2020/10/28 14:41:00
--  

.NET Framework 版本:4.0.30319.1
Foxtable 版本:2020.5.29.8
错误所在事件:表,期初库存,DataColChanged
详细错误信息:
Exception has been thrown by the target of an invocation.
Column \'期初重量\' does not belong to table 库存明细表.

 

改了运行出错

Select Case e.DataCol.name
    Case "物资编号"
        Dim dr As DataRow = DataTables("库存明细表").Find("物资编号 = \'" & e.OldValue & "\'")
        If dr Is Nothing Then
            dr = DataTables("库存明细表").AddNew()
            dr("物资编号") = e.DataRow("物资编号")
            dr("货物名称") = e.DataRow("货物名称")
            dr("规格型号") = e.DataRow("规格型号")
            dr("库存重量") = e.DataRow("期初重量")
        Else
            dr("物资编号") = e.DataRow("物资编号")
        End If
    Case "货物名称","规格型号","期初重量"
        Dim dr As DataRow = DataTables("库存明细表").Find("物资编号 = \'" & e.DataRow("物资编号") & "\'")
        If dr IsNot Nothing Then
            dr(e.DataCol.Name) = e.DataRow(e.DataCol.Name)
        End If
End Select


--  作者:有点蓝
--  发布时间:2020/10/28 14:53:00
--  
    Case "货物名称","规格型号"
        Dim dr As DataRow = DataTables("库存明细表").Find("物资编号 = \'" & e.DataRow("物资编号") & "\'")
        If dr IsNot Nothing Then
            dr(e.DataCol.Name) = e.DataRow(e.DataCol.Name)
        End If
    Case "期初重量"
        Dim dr As DataRow = DataTables("库存明细表").Find("物资编号 = \'" & e.DataRow("物资编号") & "\'")
        If dr IsNot Nothing Then
            dr("库存重量") = e.DataRow("期初重量")
        End If
End Select

--  作者:青丘狐
--  发布时间:2020/10/28 15:11:00
--  
谢i谢可以了,两个字段名字不同要要重新定义下