以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请教  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=23113)

--  作者:kevin
--  发布时间:2012/9/2 21:18:00
--  请教

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:自动复制行.rar

请前辈帮忙

 

项目中

进化明细表中,当审核列打勾时,会将当前的数据复制到产品资料中(其中如果遇到有相同条形码的,则自动叠加数量)

我现在需要增加:当 审核 列取消审核(也就是说把勾勾去掉时),,则减去对应的的产品的数量.


--  作者:czy
--  发布时间:2012/9/2 21:24:00
--  

If e.DataCol.Name = "条形码" Then \'发生变化的是产品编号吗?
    \'在产品表找出该产品
    Dim drj As DataRow
    drj = DataTables("产品资料").Find("条形码 = " & "\'" & e.DataRow("条形码") & "\'" )
    If drj IsNot Nothing \'如果找到, 则设置各列内容
        e.DataRow("分类") = drj("分类")
        e.DataRow("品名") = drj("品名")
        e.DataRow("型号") = drj("型号")
        e.DataRow("规格") = drj("规格")
        e.DataRow("单位") = drj("规格")
        e.DataRow("进货价") = drj("进货价")
    End If
End If

 

If e.DataCol.Name = "审核"
    Dim dri As DataRow = DataTables("产品资料").Find("条形码 = \'" & e.DataRow("条形码") & "\'")
    If e.DataRow("审核") = True  Then
        If dri Is Nothing Then
            Dim nma() As String = {"条形码","分类","品名","型号","规格","单位","数量","进货价"} \'A表数据来源列
            Dim nmb() As String = {"条形码","分类","品名","型号","规格","单位","数量","进货价"} \'B表数据接收列
            Dim dr As DataRow = DataTables("产品资料").AddNew
            For i As Integer = 0 To nma.Length - 1
                dr(nmb(i)) = e.DataRow(nma(i))
            Next
        Else
            dri("数量") = dri("数量") + e.DataRow("数量")
        End If
    Else
        If dri IsNot Nothing Then
            dri("数量") = dri("数量") - e.DataRow("数量")
        End If
    End If
End If