老师:
您给编的自动生成的起号可以用了。但还有一个小问题,就是要作到当售出张数为空时,所在行的售出起号也为空,请老师在原代码上改写一下!
以下是您已编 的代码和我出现问题的截图:
<!--StartFragment -->
Select Case e.DataCol.Name
Case "姓名","上年结转_张数","领入_张数","售出_张数","结存张数","售出_废piao","售出_金额","所领入_张数","所领入结存张数"
Dim dr As DataRow
Dim mr As DataRow = e.DataRow
Dim drs As List(of DataRow)
dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [姓名] = '" & mr("姓名") & "'", "[_SortKey] Desc")
If dr Is Nothing Then '如果没有上一行,说明本行就是同产品的第一行
mr("结存张数") = mr("上年结转_张数") + mr("领入_张数") - mr("售出_张数")- mr("售出_废piao")
mr("结存金额") = mr("售出_金额")
mr("所领入结存张数") = mr("所领入_张数")
dr = mr
Else
If dr.IsNull("售出_止号") = False Then
e.DataRow("售出_起号") = val(dr("售出_止号")) + 1
ElseIf dr.IsNull("上年结转_起号") = False Then
e.DataRow("售出_起号") = val(dr("上年结转_起号"))
End If
End If
drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [姓名] = '" & dr("姓名") & "'")
For i As Integer = 1 To drs.Count - 1 '重算余下行的余额
drs(i)("结存张数") = drs(i-1)("结存张数") + drs(i)("上年结转_张数") + drs(i)("领入_张数") - drs(i)("售出_张数")- drs(i)("售出_废piao")
drs(i)("结存金额") = drs(i-1)("结存金额") + drs(i)("售出_金额")
drs(i)("所领入结存张数") = drs(i-1)("所领入结存张数") + drs(i)("所领入_张数")
Next
此主题相关图片如下:xr3k5n0{6kvh{3(wgo~2j0k.png
[此贴子已经被作者于2017/11/28 20:29:44编辑过]