Foxtable(狐表)用户栏目专家坐堂 → 跨表数据更新


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

主题:跨表数据更新

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/8 9:37:00 [显示全部帖子]

Select Case e.DataCol.name
    Case "发生年月","物料编号","责任部门","责任人","数量"
        If e.DataRow.Isnull("发生年月")=False AndAlso e.DataRow.Isnull("物料编号") = False AndAlso e.DataRow.Isnull("数量")=False AndAlso e.DataRow.Isnull("责任部门") = False AndAlso e.DataRow.Isnull("责任人") = False Then
            Dim drs As List (of DataRow) = DataTables("清单表").Select("产品编号= '" & e.DataRow("物料编号") & "' and 使用状态= '使用'")
            If drs.count = 0 Then
                msgbox("清单表没有,请先增加")
            Else
                For Each  dr As DataRow In drs
                    Dim dr1 As DataRow = DataTables("物料表").find("物料编号 = '" & dr("物料编号") & "' and 发生年月 = '" & e.DataRow("发生年月") & "'and 责任人 = '" & e.DataRow("责任人") & "'and 责任部门 = '" & e.DataRow("责任部门") & "'")
                    If dr1 Is Nothing Then
                        dr1 = DataTables("物料表").addnew
                        dr1("发生年月")=e.DataRow("发生年月")
                        dr1("责任部门")=e.DataRow("责任部门")
                        dr1("责任人")=e.DataRow("责任人")
                        dr1("物料编号")=dr("物料编号")
                        dr1("物料名称")=dr("物料名称")
                        dr1("规格型号")=dr("规格型号")
                        dr1("基本单位")=dr("基本单位")
                        dr1("数量")=dr("数量")*e.DataRow("数量")
                    Else
                        Dim sum As Double = 0
                        For Each jh As DataRow In e.DataTable.Select("物料编号 = '" & e.DataRow("物料编号") & "' and 发生年月 = '" & e.DataRow("发生年月") & "'and 责任人 = '" & e.DataRow("责任人") & "'and 责任部门 = '" & e.DataRow("责任部门") & "' ")
                            sum += dr("数量")*jh("数量")
                        Next
                        dr1("数量") = sum
                    End If
                Next
            End If
        End If
End Select

 回到顶部