以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 高效流水账代码 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=159446) |
-- 作者:爱相随 -- 发布时间:2020/12/26 22:44:00 -- 高效流水账代码 老师,下面是科目汇总表期初\\借方合计\\贷方合计\\期末余额计算代码.直接与帮助中一样的条件,则可行,增加条件后的代码在细微之处就是看不出差别,还请老师指点. 另外,同一数据表中上下级关系怎么自动汇总.比如1002怎 么汇总100201和100202的数?? Select Case e.DataCol.Name Case "科目编码","借方合计","贷方合计" Dim dr As DataRow Dim mr As DataRow = e.DataRow Dim drs As List(of DataRow) Dim Value As String = e.DataRow("方向") dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [科目编码] = \'" & mr("科目编码") & "\'", "[_SortKey] Desc") If dr Is Nothing Then Select Case Value Case "借" If dr("方向2") = "借" OrElse dr("方向2") = "共同" Then If dr("期初金额1") + dr("借方合计") - dr("贷方合计") > 0 Then mr("期末金额") = mr("期初金额1") + mr("借方合计") - mr("贷方合计") dr("方向1") = "借" Else mr("期末金额") = mr("期初金额1") - mr("借方合计") + mr("贷方合计") dr("方向1") = "贷" End If Else If dr("期初金额1") + dr("贷方合计") - dr("借方合计") > 0 Then mr("期末金额") = mr("期初金额1") - mr("借方合计") + mr("贷方合计") dr("方向1") = "贷" Else mr("期末金额") = mr("期初金额1") - mr("贷方合计") + mr("借方合计") dr("方向1") = "借" End If dr = mr End If End Select End If drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [科目编码] = \'" & dr("科目编码") & "\'", "[_SortKey]") For i As Integer = 1 To drs.Count - 1 drs(i)("期初金额1") = drs(i-1)("期末金额") drs(i)("方向2") = drs(i-1)("方向1") Next If e.DataCol.Name = "科目编码" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [科目编码] = \'" & e.OldValue & "\'", "[_SortKey] Desc") If dr Is Nothing Then dr = e.DataTable.Find("[科目编码] = \'" & e.OldValue & "\'", "[_SortKey]") If dr IsNot Nothing Then Select Case Value Case "借" If dr("方向2") = "借" OrElse dr("方向2") = "共同" Then If mr("期初金额1") + mr("借方合计") - mr("贷方合计") > 0 Then mr("期末金额") = mr("期初金额1") + mr("借方合计") - mr("贷方合计") dr("方向1") = "借" Else mr("期末金额") = mr("期初金额1") + mr("贷方合计") - mr("借方合计") dr("方向1") = "贷" End If Else If mr("期初金额1") - mr("借方合计") + mr("贷方合计") > 0 Then mr("期末金额") = mr("期初金额1") - mr("借方合计") + mr("贷方合计") dr("方向1") = "贷" Else mr("期末金额") = mr("期初金额1") - mr("贷方合计") + mr("借方合计") dr("方向1") = "借" End If dr = mr End If End Select 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)("期初金额1") = drs(i-1)("期末金额") Next End If End If |
-- 作者:有点蓝 -- 发布时间:2020/12/27 20:45:00 -- 我也没看懂到底什么问题。 汇总使用compute统计和like条件查询即可
|