wst.delete
Next
Dim rq As Date = Date.Today
'一号销售表
For Each dr As DataRow In DataTables("一号销售表").DataRows
If dr("日期") = rq Then
Dim st As DataRow = DataTables("当日销售统计").Find("编号 = '" & dr("编号") & "'")
If st Is Nothing Then
Dim r As Row = Tables("当日销售统计").AddNew()
r("编号") = dr("编号")
r("销售") = dr("销售")
For Each sxf As DataRow In DataTables("进出表").DataRows
If sxf("日期") = rq And sxf("编号") = r("编号") Then
r("进项") = r("进项") + sxf("进项")
r("出项") = r("出项") + sxf("出项")
r("返红") = r("返红") + sxf("返红")
End If
Next
r("盈亏") = dr("当笔进出项")
r("抽成") = dr("抽成")
Else
st("盈亏") = st("盈亏") + dr("当笔进出项")
st("抽成") = st("抽成") + dr("抽成")
End If
End If
Next
'二号销售表
For Each dr2 As DataRow In DataTables("二号销售表").DataRows
If dr2("日期") = rq Then
Dim st2 As DataRow = DataTables("当日销售统计").Find("编号 = '" & dr2("编号") & "'")
If st2 Is Nothing Then
Dim r2 As Row = Tables("当日销售统计").AddNew()
r2("编号") = dr2("编号")
r2("销售") = dr2("销售")
For Each sxf2 As DataRow In DataTables("进出表").DataRows
If sxf2("日期") = rq And sxf2("编号") = r2("编号") Then
r2("进项") = r2("进项") + sxf2("进项")
r2("出项") = r2("出项") + sxf2("出项")
r2("返红") = r2("返红") + sxf2("返红")
End If
Next
r2("盈亏") = dr2("当笔进出项")
r2("抽成") = dr2("抽成")
Else
st2("盈亏") = st2("盈亏") + dr2("当笔进出项")
st2("抽成") = st2("抽成") + dr2("抽成")
End If
End If
Next
经试验,用开发者进入窗口,每次点击数据统计控件,table1中经统计的数是正确的,不会累加;
但是我以其它用户名进入,第一次点击是正确的,但第二次点击控件,table1里面的数据是和第一次点击出现的数累加的.
为什么呢?难不成还能搞区别对待的?
老师们,帮忙看看代码哪里出错了?