Foxtable(狐表)用户栏目专家坐堂 → 我觉得还是代码有问题,还请各位大师指教


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

主题:我觉得还是代码有问题,还请各位大师指教

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


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

 微调就是答案啊

 

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") & "' and time < #" & r("time") & "#"")

Dim cks As Double = DataTables("wx").sqlCompute("sum(shuliang)", "name = '" & r("name") & "' and time < #" & r("time") & "#")

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)

        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


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


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

计算,没,问,题。

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


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

自己认真测试啊。

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


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

之前还有的save代码你没加上啊

 

DataTables("rukudan").save
DataTables("wx").save

 

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") & "' and time < #" & r("time") & "#"")

Dim cks As Double = DataTables("wx").sqlCompute("sum(shuliang)", "name = '" & r("name") & "' and time < #" & r("time") & "#")

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)
        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

 

 

[此贴子已经被作者于2016/3/21 21:18:45编辑过]

 回到顶部