1、代码
Dim dr As DataRow = e.DataRow
Dim dt As DataTable = DataTables("销售开单")
If e.DataCol.Name = "编号" Then
Dim ary1() = {"AA","BB","CC","DD","EE","FF","GG","HH","II","JJ","KK","LL"}
Dim ary2(ary1.length) As Date
Dim d As Date = Date.today
d = new Date(d.year, d.month, 1)
ary2(0) = d
For i As Integer = 0 To ary1.length-1
ary2(i+1) = d.AddMonths(-i-1)
Next
Dim ary3(ary1.length-1) As Double
Dim drs = dt.Select("[编号] = '" & dr("编号") & "'", "日期 desc")
For Each cdr As DataRow In drs
For i As Integer = 0 To ary1.length-1
If cdr("日期") >= ary2(i+1) AndAlso cdr("日期") < ary2(i) Then
ary3(i) += cdr("数量")
Exit For
End If
Next
Next
For i As Integer = 0 To ary1.length-1
dr(ary1(i)) = ary3(i)
Next
End If
2、代码
If MainTable.Name = "计算" Then
systemready = False
Dim f As New Filler
DataTables("计算").DataRows.Clear() '清除原有数据
f.SourceTable = DataTables("销售开单")
f.SourceCols = "编号"
f.DataTable = DataTables("计算")
f.DataCols = "编号"
f.Fill()
systemready = True
DataTables("计算").datacols("编号").RaiseDataColChanged
End If