红色部分代码获取的是时间不重复值,列名是日期时间列,这么修正呢?
DataTables("凭证号").DeleteFor("")
Dim t1 As Table =Tables("凭证号")
t1.StopRedraw
Dim Products As List(Of String)
Products = DataTables("凭证明细").GetValues("时间")
Dim Products1 As List(Of String)
For Each Product As String In Products
Output.Show(Product)
Products1 = DataTables("凭证明细").GetValues("凭证号","时间='"& Product &"'")
For Each Product1 As String In Products1
Output.Show(Product1)
t1.AddNew
t1.Current("凭证号")=Product1
t1.Current("凭证单位")="瓮安县粮食局粮食储备库"
t1.Current("时间")=Product
t1.Current("uuid")=Guid.NewGuid.TOstring()
t1.Current("会计主管")="李沅玫1"
t1.Current("记账")="李沅玫"
t1.Current("复核")="李沅玫"
Dim dt As Date=Product
t1.Current("年份")=dt.Year
t1.Current("月份")=dt.Month
Next
Next
t1.save
t1.ResumeRedraw
For Each Product As String() In DataTables("凭证明细").GetValues("时间|凭证号")
Dim a2 As DataRow=DataTables("凭证号").Find("时间='" & Product(0) & "'and 凭证号='" & Product(1) & "'")
If a2 IsNot Nothing Then
Dim idx As Integer = 1
For Each dr As DataRow In DataTables("凭证明细").Select("时间='" & Product(0) & "' and 凭证号='" & Product(1) & "'")
dr("uuid")=a2("uuid")
dr("凭证编号")=idx
idx += 1
Dim dt1 As Date=dr("时间")
dr("年份")=dt1.Year
dr("月份")=dt1.Month
dr.save
a2("合计_借方金额")=DataTables("凭证明细").Compute("sum(借方金额)","时间='" & Product(0)& "' and 凭证号='" & Product(1) & "'")
a2("合计_贷方金额")=DataTables("凭证明细").Compute("sum(贷方金额)","时间='" & Product(0) & "' and 凭证号='" & Product(1) & "'")
a2.Save
Next
End If
Next