Foxtable(狐表)用户栏目专家坐堂 → 有点甜老师,您再帮我看看,着急


  共有4282人关注过本帖树形打印复制链接

主题:有点甜老师,您再帮我看看,着急

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/3/7 20:04:00 [显示全部帖子]

 呃,没看懂你的意思。不是每种工时的累加么?

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/3/7 20:53:00 [显示全部帖子]

 哦,你改一下代码

 

If e.DataCol.Name.StartsWith("工序") Then
    Dim filter As String = "产品名称 = '" & e.DataRow("产品名称") & "'"
    Dim fdr As DataRow = DataTables("产品信息").Find(filter)
    If fdr IsNot Nothing Then
        Dim fdr2 As DataRow  = DataTables("工时统计").Find(filter & " and 单号 = '" & e.DataRow("单号") & "'")
        If fdr2 Is Nothing Then
            fdr2 = DataTables("工时统计").AddNew
            fdr2("产品名称") = e.DataRow("产品名称")
            fdr2("日期") = e.DataRow("日期")
            fdr2("单号") = e.DataRow("单号")
            fdr2("数量") = e.DataRow("数量")
        Else
            For Each dc As DataCol In DataTables("工时统计").DataCols
                If dc.Name <> "日期" AndAlso dc.name <> "产品名称" AndAlso dc.name <> "单号" AndAlso dc.Name <> "数量" Then
                    fdr2(dc.name) = Nothing
                End If
            Next
        End If
       
        For Each dc As DataCol In DataTables("工时统计").DataCols
            If dc.Name.StartsWith("工序") Then
                fdr2(dc.Name) = Nothing
            End If
        Next

        For Each dc As DataCol In e.DataTable.DataCols
            If dc.Name.StartsWith("工序") AndAlso e.DataRow(dc.name) > "" Then
                Dim names() As String = e.DataRow(dc.name).split(",")
                For Each name As String In names
                    Dim sum As Double = e.DataTable.Compute("sum(数量)", filter & " and 单号 = '" & e.DataRow("单号") & "' and " & dc.Name & " like '*" & name & "*'")
                    sum = sum * fdr(dc.Name)
                    If DataTables("工时统计").DataCols.Contains(name) Then
                        fdr2(name) += sum
                    End If
                Next
            End If
        Next
    Else
        msgbox("没有找到【产品信息】对应的数据!")
    End If
End If


 回到顶部