老师好,项目事件中有和下面相同的一段代码,这段新增的代码不知怎样修改。
Dim filter = iif(t5.filter > "", t5.filter, "1=1")
cmd5.CommandText = "SEL ECT DIS TINCT year(日期) as 年, 来源,客户ID,客户名称 from {进销存} where " & filter
dt = cm d5.ExecuteReader()
For Each dr As DataRow In dt.datarows
filter = "年份 = '" & dr("年") & "' and 来源 = '" & dr("来源") & "' and 客户名称 = '" & dr("客户名称")
[此贴子已经被作者于2025/1/11 3:15:32编辑过]
老师,两组代码在标出的地方怎样设置避免冲突。
Dim cmd5 As New SQLCommand '年度统计
Dim dt As DataTable
cmd5.C
Dim t5 As Table = Tables("进销存")
Dim filter = iif(t5.filter > "", t5.filter, "1=1")
cmd5.Co mmandText = "SELE CT DIS TINCT 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
'''''''''''''''''''''''''''''''''''''''''''''''''
Dim cmd As New SQLCommand '年度统计
Dim dt1 As DataTable
cmd.C
Dim t6 As Table = Tables("汇总")
Dim filter = iif(t6.filter > "", t6.filter, "1=1")
cmd.Com mandText = "SEL EC T DISTINCT year(抄表日期) as 年, 来源,名称_ID,名称 from {汇总} where " & filter
dt1 = cmd.ExecuteReader()
For Each dr As DataRow In dt1.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
老师,变量改了还是没有用。
此主题相关图片如下:2025-01-06 10 37 50.png