以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  关于统计,请高手指点!!!  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=74886)

--  作者:jinzhengbe
--  发布时间:2015/9/22 0:47:00
--  关于统计,请高手指点!!!

Select Case e.DataCol.Name
    Case "shuliang", "price"
        Dim rks As Double = DataTables("rukudan").Compute("sum(shuliang)", "cord = \'" & e.DataRow("cord") & "\'")
        Dim cks As Double = e.DataTable.Compute("sum(shuliang)", "cord = \'" & e.DataRow("cord") & "\'")
        If cks > rks Then

      

请问这个地方统计的是数据库后台的数据,还是当前数据?如果是当前数据,怎么改为统计后台数据

 

还想添加一个参数 显示当前是累计多少个商品,也是要统计后台数据库,而不是当前程序的数据

 

因为程序加载的时候,默认不加载数据

\'     msgbox("无法出库,库存不足")
        Else
            Dim count As Integer = 0
            Dim drs As List(Of DataRow) = DataTables("rukudan").Select("cord = \'" & e.DataRow("cord") & "\'", "_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 - e.DataRow("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 >= e.DataRow("shuliang") Then
                            cbs += (e.DataRow("shuliang") - (count - sy)) * dr("price")
                            msgbox(cbs & count)
                            e.DataRow("lirun") = e.DataRow("shuliang") * e.DataRow("price") - cbs
                            Exit For
                        Else
                            cbs += cb
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
End Select


--  作者:sloyy
--  发布时间:2015/9/22 9:02:00
--  
1 rks 统计的是加载了的rukudan的筛选行的suliang
2 cks统计的是当前表的筛选行的suliang

--  作者:大红袍
--  发布时间:2015/9/22 9:13:00
--  
Dim rks As Double = DataTables("rukudan").sqlCompute("sum(shuliang)", "cord = \'" & e.DataRow("cord") & "\'")
Dim cks As Double = e.DataTable.sqlCompute("sum(shuliang)", "cord = \'" & e.DataRow("cord") & "\'")
Dim count As Double = DataTables("rukudan").sqlCompute("count(*)", "cord = \'" & e.DataRow("cord") & "\'")
If cks > rks Then

--  作者:jinzhengbe
--  发布时间:2015/9/23 10:17:00
--  
我还想添加一个 bb字段 用来显示当前被计算的 是累计第几个商品 
应该怎么处理
非常感谢 
狐表团队 棒极了

--  作者:大红袍
--  发布时间:2015/9/23 10:19:00
--  
e.DataRow("bb") = count