Dim cmd5 As New SQLCommand
Dim dt As DataTable
cmd5.ConnectionName = "数据库"
Dim t5 As Table = Tables("进销存")
Dim filter = iif(t5.filter > "", t5.filter, "1=1")
cmd5.CommandText = "SELECT DISTINCT year(日期) as 年, 来源,客户ID,客户名称 from {进销存} where " & filter
dt = cmd5.ExecuteReader()
For Each dr As DataRow In dt.datarows
filter = "年份 = '" & dr("年") & "' and 来源 = '" & dr("来源") & "' and 客户名称 = '" & dr("客户名称") & "'"
Dim ndr As DataRow = DataTables("年度统计").find(filter)
If ndr Is Nothing Then
ndr = DataTables("年度统计").addnew
End If
ndr("年份") = dr("年")
ndr("来源") = dr("来源")
ndr("客户名称") = dr("客户名称")
Next