以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]流水账 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=176515) |
-- 作者:lgj716330 -- 发布时间:2022/4/15 20:40:00 -- [求助]流水账 Select Case e.DataCol.Name Case "理财账户名称","理财产品名称","买入本金","赎回本金" 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("理财账户名称") & "\' And [理财产品名称] = \'" & mr("理财产品名称") & "\'", "[_SortKey] Desc") If dr Is Nothing Then mr("当前持有金额") = mr("买入本金") - mr("赎回本金") dr = mr End If drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [理财账户名称] = \'" & mr("理财账户名称") & "\' And [理财产品名称] = \'" & mr("理财产品名称") & "\'", "[_SortKey]") For i As Integer = 1 To drs.Count - 1 drs(i)("当前持有金额") = drs(i-1)("当前持有金额") + drs(i)("买入本金") - drs(i)("赎回本金") Next If (e.DataCol.Name = "理财账户名称" OrElse e.DataCol.Name = "理财产品名称") AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [理财账户名称] = \'" & e.OldValue & "\' And [理财产品名称] = \'" & e.OldValue & "\'", "[_SortKey] Desc") If dr Is Nothing Then dr = e.DataTable.Find("[理财账户名称] = \'" & e.OldValue & "\' And [理财产品名称] = \'" & 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 [理财账户名称] = \'" & dr("理财账户名称") & "\' And [理财产品名称] = \'" & dr("理财产品名称") & "\'", "[_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 上面标黄处是不是写得有问题
|
-- 作者:有点蓝 -- 发布时间:2022/4/16 8:54:00 -- 理财账户名称和理财产品名称分开单独处理 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 & "\' And [理财产品名称] = \'" & dr("理财产品名称") & "\'", "[_SortKey] Desc") If dr Is Nothing Then …… If e.DataCol.Name = "理财产品名称" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [理财账户名称] = \'" & dr("理财账户名称") & "\' And [理财产品名称] = \'" & e.OldValue & "\'", "[_SortKey] Desc") If dr Is Nothing Then …… |
-- 作者:lgj716330 -- 发布时间:2022/4/16 9:50:00 -- 下面标黄处提示“无法在 System.DateTime 和 System.String 上执行“=”操作。” Dim bjs As List(Of String()) = DataTables("公司理财项目明细账").GetValues("理财账户名称|理财产品名称|日期") For Each bj As String() In bjs Dim drs As List(Of DataRow) = DataTables("公司理财项目明细账").Select("[理财账户名称] = \'" & bj(0) & "\' and [理财产品名称] = \'" & bj(1) & "\' and [日期] = \'" & bj(2) & "\'", "理财账户名称,理财产品名称,日期") For n As Integer = 0 To drs.Count - 1 Dim dn As Date = drs(n)("日期") Dim tp1 As TimeSpan = Date.Today - dn If n > 0 Then Dim dn1 As Date = drs(n-1)("日期") Dim tp As TimeSpan = dn - dn1 If drs(n)("日期") > drs(n-1)("日期") And drs(n)("当前持有金额")<>0 Then drs(n-1)("当前金额持有天数") = tp drs(n)("当前金额持有天数") = tp1 ElseIf drs(n)("日期") > drs(n-1)("日期") And drs(n)("当前持有金额")=0 Then drs(n-1)("当前金额持有天数") = tp drs(n)("当前金额持有天数") = Nothing End If ElseIf n=0 Then drs(n)("当前金额持有天数") = tp1 End If Next Next |
-- 作者:有点蓝 -- 发布时间:2022/4/16 10:01:00 -- "\' and [日期] = #" & bj(2) & "#", |
-- 作者:lgj716330 -- 发布时间:2022/4/16 10:34:00 -- 这样会提示 表达式包含无效的日期常量“##”
[此贴子已经被作者于2022/4/16 10:34:09编辑过]
|
-- 作者:lgj716330 -- 发布时间:2022/4/16 10:39:00 -- 哦,大概知道怎么回事了,发现日期列有空值 |
-- 作者:lgj716330 -- 发布时间:2022/4/16 11:44:00 -- Select Case e.DataCol.Name Case "买入日期","赎回日期" If e.DataRow.IsNull("买入日期")=False Then e.DataRow("日期") = e.DataRow("买入日期") ElseIf e.DataRow.IsNull("赎回日期")=False Then e.DataRow("日期") = e.DataRow("赎回日期") End If End Select Select Case e.DataCol.Name Case "理财账户名称","理财产品名称","日期" If e.DataRow.Isnull("日期") =False Then Dim bjs As List(Of String()) = DataTables("公司理财项目明细账").GetValues("理财账户名称|理财产品名称|日期") For Each bj As String() In bjs Dim drs As List(Of DataRow) = DataTables("公司理财项目明细账").Select("[理财账户名称] = \'" & bj(0) & "\' and [理财产品名称] = \'" & bj(1) & "\' and [日期] = \'" & bj(2) & "\'", "理财账户名称,理财产品名称,日期") For n As Integer = 0 To drs.Count - 1 Dim dn As Date = drs(n)("日期") Dim da As Date = Date.Today Dim tp1 As TimeSpan = da - dn If n > 0 Then Dim dn1 As Date = drs(n-1)("日期") Dim tp As TimeSpan = dn - dn1 If drs(n)("日期") > drs(n-1)("日期") And drs(n)("当前持有金额")<>0 Then drs(n-1)("当前金额持有天数") = tp drs(n)("当前金额持有天数") = tp1 ElseIf drs(n)("日期") > drs(n-1)("日期") And drs(n)("当前持有金额")=0 Then drs(n-1)("当前金额持有天数") = tp drs(n)("当前金额持有天数") = Nothing End If ElseIf n=0 Then drs(n)("当前金额持有天数") = tp1 End If Next Next End If End Select 提示:参数“Expression”无法转换为类型“TimeSpan”。
|
-- 作者:有点蓝 -- 发布时间:2022/4/16 11:47:00 -- drs(n-1)("当前金额持有天数") = tp.TotalDays |
-- 作者:lgj716330 -- 发布时间:2022/4/16 14:40:00 -- Select Case e.DataCol.Name Case "理财账户产品名称","日期" If e.DataRow.Isnull("日期") =False Then Dim bjs As List(Of String()) = DataTables("公司理财项目明细账").GetValues("理财账户产品名称|日期") For Each bj As String() In bjs Dim drs As List(Of DataRow) = DataTables("公司理财项目明细账").Select("[理财账户产品名称] = \'" & bj(0) & "\' and [日期] = \'" & bj(1) & "\'", "理财账户产品名称,日期") For n As Integer = 0 To drs.Count - 1 If n > 0 Then Dim dn As Date = drs(n)("日期") Dim dn1 As Date = drs(n-1)("日期") Dim da As Date = Date.Today Dim tp As TimeSpan = dn - dn1 Dim tp1 As TimeSpan = da - dn If drs(n)("当前持有金额")<>0 Then drs(n-1)("当前金额持有天数") = tp.TotalDays drs(n)("当前金额持有天数") = tp1.TotalDays ElseIf drs(n)("当前持有金额")=0 Then drs(n)("当前金额持有天数") = tp.TotalDays drs(n)("当前金额持有天数") = Nothing End If ElseIf n=0 Then Dim dn As Date = drs(n)("日期") Dim da As Date = Date.Today Dim tp1 As TimeSpan = da - dn drs(n)("当前金额持有天数") = tp1.TotalDays End If Next Next End If End Select 上述出来的是"当前金额持有天数"的结果,想实现“正确”列中这样的结果,要怎么调整
[此贴子已经被作者于2022/4/16 15:29:38编辑过]
|
-- 作者:有点蓝 -- 发布时间:2022/4/16 15:36:00 -- 计算逻辑是什么? |