以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  公式如何修改  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=15950)

--  作者:chan1997
--  发布时间:2012/1/19 20:59:00
--  公式如何修改

If e.DataCol.Name = "选择" Then
    If e.DataRow("选择") = True Then
        Dim nma() As String = {"单位","商品类别","商品代码","商品名称","仓库名称","仓位","日期","进库_折扣","进库_数量","进库_单价","进库_金额","规格","等级"} \'A表数据来源列
        Dim nmb() As String = {"单位","商品类别","商品代码","商品名称","仓库名称","仓位","日期","进库_折扣","进库_数量","进库_单价","进库_金额","规格","等级"} \'B表数据来源列        Dim dr As DataRow = DataTables("库存表").AddNew
       Dim dr As DataRow = DataTables("库存表").AddNew
        For i As Integer = 0 To nma.Length - 1
            dr(nmb(i)) = e.DataRow(nma(i))
        Next
        For Each dc As DataCol In DataTables("库存表").DataCols
            If dc.name ="id" Then
                dr("id") =e.DataRow("_identify")
            Else
                dr("商品类别") = e.DataRow("商品类别")

                dr("商品名称") = e.DataRow("商品名称")
                dr("商品代码") = e.DataRow("商品代码")
                dr("规格") =e.DataRow("规格")
                dr("等级") =e.DataRow("等级")
                dr("单位") = e.DataRow("单位")
                 dr("商品名称") =e.DataRow("商品名称")
                dr("仓位") =e.DataRow("仓位")
                dr("日期") = e.DataRow("日期")
                dr("进库_折扣") =e.DataRow("进库_折扣")
                dr("进库_数量") =e.DataRow("进库_数量")
                dr("进库_单价") = e.DataRow("进库_单价")
                dr("进库_金额") = e.DataRow("进库_金额")
            End If
        Next
    Else
        Dim tr As DataRow =DataTables("库存表").find("id ="& e.DataRow("id"))
        If tr IsNot Nothing Then
            tr.delete()
        End If
    End If
End If

以上是表DataColChanged公式,"选择“列打算不要了

If e.DataCol.Name = "选择" Then
    If e.DataRow("选择") = True Then

这两句去掉,我想直接在窗口的“保存”按钮把库存明细表的公式保存到库存表,同时如果明细表内容有变动,库存表同样发生相应变动,公式如何修改?


--  作者:狐狸爸爸
--  发布时间:2012/1/20 8:50:00
--  

没有人这样设计修通的,数据冗余,维护困难,编码难度大幅增加。

同样的数据,应该只出现在一个地方。

 

还有你原来的公式,完全重复了,有一段是多余的,应该:

 

If e.DataCol.Name = "选择" Then
    If e.DataRow("选择") = True Then
        Dim nma() As String = {"单位","商品类别","商品代码","商品名称","仓库名称","仓位","日期","进库_折扣","进库_数量","进库_单价","进库_金额","规格","等级"} \'A表数据来源列
        Dim nmb() As String = {"单位","商品类别","商品代码","商品名称","仓库名称","仓位","日期","进库_折扣","进库_数量","进库_单价","进库_金额","规格","等级"} \'B表数据来源列        Dim dr As DataRow = DataTables("库存表").AddNew
        Dim dr As DataRow = DataTables("库存表").AddNew
        For i As Integer = 0 To nma.Length - 1
            dr(nmb(i)) = e.DataRow(nma(i))
        Next
        dr("id") =e.DataRow("_identify")
    Else
        Dim tr As DataRow =DataTables("库存表").find("id ="& e.DataRow("id"))
        If tr IsNot Nothing Then
            tr.delete()
        End If
    End If
End If


--  作者:chan1997
--  发布时间:2012/1/20 12:12:00
--  

以上是表DataColChanged公式,"选择“列只作为触发事件达到复制效果,打算不要了以下两句

If e.DataCol.Name = "选择" Then
    If e.DataRow("选择") = True Then

这两句去掉,我想直接在窗口的“保存”按钮把库存明细表的公式保存到库存表,同时如果明细表内容有变动,库存表同样发生相应变动,公式如何修改?

我是刚接触孤表的新手,好多地方不懂,请指教