cmd.CommandText = "selec t * from 资金日报账户表 where 日期 = '2019-01-01'"
Dim t As DataTable = cmd.ExecuteReader
For Each r As DataRow In t.DataRows
dim filter as string = "日期 > '" & r("日期") & "'" & _
" And 分销商 = '" & r("分销商") & "' And 类型 = '" & r("类型") & "' and 项目 = '" & r("项目") & "'"
Dim i As Integer = 0
For Each dr As DataRow In t.Selec t(filter,"日期")
output.show(i & ": 日期1: " & dr("日期") & " 日期2: " & r("日期"))
If i = 0 Then
dr("上日余额") = r("本日余额")
dr("本日余额") = r("本日余额")+dr("本日增加")-dr("本日减少")
Else
dr("上日余额") = dt.Selec t("","日期")(i-1)("本日余额")
dr("本日余额") = dt.Selec t("","日期")(i-1)("本日余额")+dr("本日增加")-dr("本日减少")
End If
i +=1
Next
dt.save
Next