Dim y1 As WinForm.NumericComboBox = e.Form.Controls("年份1")
Dim y2 As WinForm.NumericComboBox = e.Form.Controls("年份2")
Dim m1 As WinForm.NumericComboBox = e.Form.Controls("开始月")
Dim m2 As WinForm.NumericComboBox = e.Form.Controls("结束月")
Dim dtks1 As Date = New Date(y1.Value,m1.Value,1)
Dim dtjs1 As Date = New Date(y1.Value,m2.Value,Date.DaysInMonth(y1.Value,m2.Value))
Dim dtks2 As Date = New Date(y2.Value,m1.Value,1)
Dim dtjs2 As Date = New Date(y2.Value,m2.Value,Date.DaysInMonth(y2.Value,m2.Value))
For Each drwl1 As DataRow In DataTables("bom物料合并").DataRows
Dim q1 As new QueryBuilder
q1.TableName = "采购fa piaotop2"
q1.C
q1.SelectString = "Sel ect TOP 3 FItemID,FPriceDiscount FR OM {ICPurchaseEntry} LEFT JOIN {ICPurchase} ON {ICPurchaseEntry}.FInterID = {ICPurchase}.FInterID WHERE FDate <= '" & dtjs2 & "' And FPriceDiscount > 0 And FItemID = " & drwl1("物料内码") & " ORDER BY {ICPurchaseEntry}.FInterID DESC"
q1.Build
If Tables("采购fa piaotop2").Rows.Count > 0 Then
drwl1("均价2") = Tables("采购fa piaotop2").Compute("Avg(FPriceDiscount)")
End If
Next
For Each drwl As DataRow In DataTables("bom物料合并").DataRows
Dim q As new QueryBuilder
q.TableName = "采购fa piaotop1"
q.C
q.SelectString = "Sel ect TOP 3 FItemID,FPriceDiscount FR OM {ICPurchaseEntry} LEFT JOIN {ICPurchase} ON {ICPurchaseEntry}.FInterID = {ICPurchase}.FInterID WHERE FDate <= '" & dtjs1 & "' And FPriceDiscount > 0 And FItemID = " & drwl("物料内码") & " ORDER BY {ICPurchaseEntry}.FInterID DESC"
q.Build
If Tables("采购fa piaotop1").Rows.Count > 0 Then
drwl("均价1") = Tables("采购fa piaotop1").Compute("Avg(FPriceDiscount)")
End If
Next
[此贴子已经被作者于2018/10/10 15:33:42编辑过]