以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  如果出库大于入库,原价安0计算。应该怎么改?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=81816)

--  作者:jinzhengbe
--  发布时间:2016/3/7 5:29:00
--  如果出库大于入库,原价安0计算。应该怎么改?

Dim r As Row = Tables("wx").Current

Dim rks As Double = DataTables("rukudan").sqlCompute("sum(shuliang)", "name = \'" & r("name") & "\'")

Dim rks1 As Double = DataTables("weixin").sqlCompute("sum(shuliang)", "name = \'" & r("name") & "\'")

Dim cks As Double = DataTables("wx").sqlCompute("sum(shuliang)", "name = \'" & r("name") & "\'")

If cks + rks1 > rks Then
    
    \'msgbox("无法出库,库存不足")
    
Else
    
    Dim count As Integer = 0
    
    Dim drs As List(Of DataRow) = DataTables("rukudan").Select("name = \'" & r("name") & "\'", "_Identify")
    
    For i As Integer = 0 To drs.count - 1
        
        Dim dr As DataRow = drs(i)
        
        count += dr("shuliang")
        
        Dim sy As Integer = count - (cks + rks1 - r("shuliang"))
        
        If sy >= 0 Then
            
            Dim cb, cbs As Double
            
            count = 0
            
            For j As Integer = i To drs.count - 1
                
                dr = drs(j)
                
                If j = i Then
                    
                    count += sy
                    
                    cb = sy * dr("price")
                    
                Else
                    
                    count += dr("shuliang")
                    
                    cb = dr("shuliang") * dr("price")
                    
                    sy = dr("shuliang")
                    
                End If
                
                If count >= r("shuliang") Then
                    
                    cbs += (r("shuliang") - (count - sy)) * dr("price")
                    
                    r("cb")=cb
                    
                    r("cbs")=cbs
                    
                    r("bb") = count
                    
                    \' msgbox(cbs & count)
                    
                    r("lirun") = r("shuliang") * r("price") - cbs
                    
                    Exit For
                    
                Else
                    
                    cbs += cb
                    
                End If
                
            Next
            
            Exit For
            
        End If
        
    Next
    
    \'    End If
    
End If


--  作者:大红袍
--  发布时间:2016/3/7 9:07:00
--  

没看懂你什么意思,出库大于入库的时候,就是库存不足的提示啊。

 

你要做什么,就在这个判断后面写代码

 

If cks + rks1 > rks Then
    
    msgbox("无法出库,库存不足")