以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  运算前判断  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=121602)

--  作者:yangwenghd
--  发布时间:2018/7/10 10:18:00
--  运算前判断
可以在下面的运算结果是否小于0吗?
如果小于0就提示超过库存量
如果不会小于0就执行,
麻烦就是在于,是在执行代码后的结果来判断,感谢 感谢 
If e.DataRow.IsNull("订单号据_联产编号")=False Then
    Dim dr As DataRow = DataTables("库存").Find("属性_产品编号=\'" & e.DataRow("订单号据_联产编号") & "\'")
    If dr IsNot Nothing Then
        dr("实况_数量")= DataTables("采购记录").Compute("sum(采购_数量)","产品_编号=\'" & e.DataRow("订单号据_联产编号")  & "\' and 采购_状态=\'已完成\'")-DataTables("订单附产品表").Compute("sum(订单_数量)","订单号据_联产编号=\'" & e.DataRow("订单号据_联产编号")  & "\' and 订单_库存状态=\'已出库\'")
    End If
End If  \'计算待收款  在回款表有配套代码

--  作者:有点甜
--  发布时间:2018/7/10 10:50:00
--  


If e.DataRow.IsNull("订单号据_联产编号")=False Then
    Dim sum = DataTables("采购记录").Compute("sum(采购_数量)","产品_编号=\'" & e.DataRow("订单号据_联产编号")  & "\' and 采购_状态=\'已完成\'")-DataTables("订单附产品表").Compute("sum(订单_数量)","订单号据_联产编号=\'" & e.DataRow("订单号据_联产编号")  & "\' and 订单_库存状态=\'已出库\'")
    If sum < 0 Then
        msgbox("超过库存")
    Else
        Dim dr As DataRow = DataTables("库存").Find("属性_产品编号=\'" & e.DataRow("订单号据_联产编号") & "\'")
        If dr IsNot Nothing Then
            dr("实况_数量")= sum
        End If
    End If
End If  \'计算待收款  在回款表有配套代码