以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 流水帐 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=170314) |
||||
-- 作者:cjl333333333 -- 发布时间:2021/7/21 16:35:00 -- 流水帐
老师这个项目库存数量老是不对,然后我是外部数据表的,每次加载最后一天的数据。
|
||||
-- 作者:有点蓝 -- 发布时间:2021/7/21 16:38:00 -- 重置列后检查数据没有问题。模仿原项目,做个功能一样有问题的测试项目发过来测试 |
||||
-- 作者:cjl333333333 -- 发布时间:2021/7/21 17:21:00 -- 老师你再帮我看看,我就是下面这个代码,其它没问题就是全部数据加载出来的他都计算对的,就是没加载就会计成库存数量0 Select Case e.DataCol.Name Case "编号","入库数量","出库数量","入库件数","出库件数" Dim dr As DataRow Dim mr As DataRow = e.DataRow Dim drs As List(of DataRow) Dim jk As Integer Dim ck As Integer Dim jk1 As Integer Dim ck1 As Integer dr = e.DataTable.SQLFind("[_SortKey] < " & mr("_SortKey") & " And [编号] = \'" & mr("编号") & "\'", "[_SortKey] Desc") If dr Is Nothing Then \'如果是第一行,计算结存 jk = DataTables("库存表").SQLCompute("Sum(入库数量)","[_SortKey] < " & mr("_SortKey") & " And 编号 = \'" & mr("编号") & "\'") jk1 = DataTables("库存表").SQLCompute("Sum(入库件数)","[_SortKey] < " & mr("_SortKey") & " And 编号 = \'" & mr("编号") & "\'") ck = DataTables("库存表").SQLCompute("Sum(出库数量)","[_SortKey] < " & mr("_SortKey") & " And 编号 = \'" & mr("编号") & "\'") ck1 = DataTables("库存表").SQLCompute("Sum(出库件数)","[_SortKey] < " & mr("_SortKey") & " And 编号 = \'" & mr("编号") & "\'") mr("库存数量") = e.DataRow("入库数量") - e.DataRow("出库数量") + jk - ck mr("库存件数") = e.DataRow("入库件数") - e.DataRow("出库件数") + jk1 - ck1 dr = mr End If drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [编号] = \'" & dr("编号") & "\'", "[_SortKey]") For i As Integer = 1 To drs.Count - 1 drs(i)("库存数量") = drs(i-1)("库存数量") + drs(i)("入库数量") - drs(i)("出库数量") drs(i)("库存件数") = drs(i-1)("库存件数") + drs(i)("入库件数") - drs(i)("出库件数") Next If e.DataCol.Name = "编号" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then \'如果修改的是产品列 dr = e.DataTable.SQLFind("[_SortKey] < " & mr("_SortKey") & " And [编号] = \'" & e.OldValue & "\'", "[_SortKey] Desc") \'找出旧产品的上一行 If dr Is Nothing Then \'如果不存在上一行,那么本行就是旧产品的第一行,由于已经被修改为新产品,需要找出旧产品现在的第一行 dr = e.DataTable.SQLFind("[编号] = \'" & e.OldValue & "\'", "[_SortKey]") \'找出旧产品现在的第一行 If dr IsNot Nothing Then \'如果找到,计算库存 jk = DataTables("库存表").SQLCompute("Sum(入库数量)","[_SortKey] < " & mr("_SortKey") & " And 编号 = \'" & e.OldValue & "\'") jk1 = DataTables("库存表").SQLCompute("Sum(入库件数)","[_SortKey] < " & mr("_SortKey") & " And 编号 = \'" & e.OldValue & "\'") ck = DataTables("库存表").SQLCompute("Sum(出库数量)","[_SortKey] < " & mr("_SortKey") & " And 编号 = \'" & e.OldValue & "\'") ck1 = DataTables("库存表").SQLCompute("Sum(出库件数)","[_SortKey] < " & mr("_SortKey") & " And 编号 = \'" & e.OldValue & "\'") dr("库存数量") = dr("入库数量") - dr("出库数量") + jk - ck dr("库存件数") = dr("入库件数") - dr("出库件数") + jk1 - ck1 End If End If If dr IsNot Nothing Then drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [编号] = \'" & dr("编号") & "\'", "[_SortKey]") For i As Integer = 1 To drs.Count - 1 drs(i)("库存数量") = drs(i-1)("库存数量") + drs(i)("入库数量") - drs(i)("出库数量") drs(i)("库存件数") = drs(i-1)("库存件数") + drs(i)("入库件数") - drs(i)("出库件数") Next End If End If End Select |
||||
-- 作者:有点蓝 -- 发布时间:2021/7/21 17:27:00 -- SQLFind改为Find |