Foxtable(狐表)用户栏目专家坐堂 → 删除行记录更新表数据


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

主题:删除行记录更新表数据

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


加好友 发短信
等级:四尾狐 帖子:858 积分:6381 威望:0 精华:0 注册:2017/2/13 9:04:00
删除行记录更新表数据  发帖心情 Post By:2018/10/9 11:12:00 [只看该作者]

保存按钮更新了dr的可申领数:

If Forms("领料申请").opened
For Each dr2 As DataRow In DataTables("领料申请明细").Select("[领料申请单号] = '" & Tables("领料申请_table1").current("领料申请单号")  & "'")
    For Each dr As DataRow In DataTables("物检入库明细表").Select("[物料ID] = '" & dr2("物料ID")  & "'")
        dr("可申领数") = dr("需求数") - DataTables("领料申请明细").Compute("Sum(申请数)", "[物料ID] = '" & dr2("物料ID")  & "' and [审核] = 'true'")
        dr.save()
    Next
Next
End If

删除按钮代码:(在删除行记录的时候,因为申请数会删掉,当前行对应的物检入库明细表的可申领数也需要更新,代码怎么写?)
If Tables("领料申请_table2").Current IsNot Nothing Then
        If Tables("领料申请_table2").TopPosition>-1 Then
            For  i As Integer=Tables("领料申请_table2").BottomPosition To Tables("领料申请_table2").TopPosition Step -1
                Tables("领料申请_table2").Rows(i).Delete()
            Next
        End If
End If


领料申请_table2绑定的是领料申请明细表



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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/10/9 11:40:00 [只看该作者]

重新计算一次不就好了?

 

If Tables("领料申请_table2").Current IsNot Nothing Then
    If Tables("领料申请_table2").TopPosition>-1 Then
        For  i As Integer=Tables("领料申请_table2").BottomPosition To Tables("领料申请_table2").TopPosition Step -1
            Dim dr2 = Tables("领料申请_table2").Rows(i)
           
            For Each dr As DataRow In DataTables("物检入库明细表").Select("[物料ID] = '" & dr2("物料ID")  & "'")
                dr("可申领数") = dr("需求数") - DataTables("领料申请明细").Compute("Sum(申请数)", "[物料ID] = '" & dr2("物料ID")  & "' and [审核] = 'true'") + dr2("申请数")
                dr.save()
            Next
            dr2.delete
        Next
    End If
End If


 回到顶部