以文本方式查看主题
- Foxtable(狐表) (http://foxtable.net/bbs/index.asp)
-- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2)
---- 错误所在事件:项目,AfterOpenProject (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=94947)
|
-- 作者:seal51
-- 发布时间:2017/1/5 21:44:00
-- 错误所在事件:项目,AfterOpenProject
错误所在事件:项目,AfterOpenProject 详细错误信息: 未将对象引用设置到对象的实例。
好像是下段代码出了问题, 请老师帮忙检查更改一下
Dim drs As New List(of DataRow) With DataTables("库存明细表") For Each nm As String In .GetValues("产品ID") \'找出每个产品的第一行数据, 添加到集合drs中 drs.Add(.Find("产品ID = \'" & nm & "\'", "[_SortKey]")) Next For Each r As DataRow In drs .DataCols("入库数量").RaiseDataColChanged(r) \'重置每个产品的第一行 Next End With
|
-- 作者:有点色
-- 发布时间:2017/1/5 21:45:00
--
你datacolchanged事件应该有问题。
|
-- 作者:seal51
-- 发布时间:2017/1/5 21:58:00
--
谢谢老师! 是库存明细表的datacolchanged事件吗?
Select Case e.DataCol.Name Case "产品ID","入库数量","出库数量" Dim dr As DataRow Dim mr As DataRow = e.DataRow Dim drs As List(of DataRow) dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [产品ID] = \'" & mr("产品ID") & "\'", "[_SortKey] Desc") If dr Is Nothing Then mr("库存数量") = mr("入库数量") - mr("出库数量") dr = mr End If drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [产品ID] = \'" & dr("产品ID") & "\'", "[_SortKey]") For i As Integer = 1 To drs.Count - 1 drs(i)("库存数量") = drs(i-1)("库存数量") + drs(i)("入库数量") - drs(i)("出库数量") Next If e.DataCol.Name = "产品ID" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [产品ID] = \'" & e.OldValue & "\'", "[_SortKey] Desc") If dr Is Nothing Then dr = e.DataTable.Find("[产品ID] = \'" & e.OldValue & "\'", "[_SortKey]") If dr IsNot Nothing Then dr("库存数量") = dr("入库数量") - dr("出库数量") End If End If If dr IsNot Nothing Then drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [产品ID] = \'" & dr("产品ID") & "\'", "[_SortKey]") For i As Integer = 1 To drs.Count - 1 drs(i)("库存数量") = drs(i-1)("库存数量") + drs(i)("入库数量") - drs(i)("出库数量") Next End If End If End Select
|
-- 作者:有点色
-- 发布时间:2017/1/5 22:02:00
--
试试改一下
Dim drs As New List(of DataRow) With DataTables("库存明细表") For Each nm As String In .GetValues("产品ID", "产品ID is not null") \'找出每个产品的第一行数据, 添加到集合drs中 drs.Add(.Find("产品ID = \'" & nm & "\'", "[_SortKey]")) Next For Each r As DataRow In drs .DataCols("入库数量").RaiseDataColChanged(r) \'重置每个产品的第一行 Next End With
|
-- 作者:seal51
-- 发布时间:2017/1/5 22:06:00
--
OK了, 谢谢老师!
|