'进销存表统计入库明细?出库明细?期初
If MainTable.Name = "进销存" Then
'DataTables("进销存").DataCols("商品ID").RaiseDataColChanged
'DataTables("进销存").DataCols("商品名称").RaiseDataColChanged
MainTable.StopRedraw
MainTable.DataTable.DeleteFor("")
For Each dr As DataRow In DataTables("入库明细").Select("入库日期 is not null")
Dim nr As Row = MainTable.AddNew
nr("日期") = dr("入库日期")
nr("客户名称") = dr("供应商_名称")
nr("商品ID") = dr("商品ID")
nr("商品名称") = dr("商品名称")
nr("来源") = dr("来源")
nr("规格") = dr("规格")
nr("入库_数量") = dr("入库_数量")
nr("入库_单价") = dr("入库_单价")
nr("入库_金额") = dr("金额合计")
Next
For Each dr As DataRow In DataTables("出库明细").Select("出库日期 is not null")
Dim nr As Row = MainTable.AddNew
nr("日期") = dr("出库日期")
nr("客户名称") = dr("客户")
nr("商品ID") = dr("商品ID")
nr("商品名称") = dr("商品名称")
nr("来源") = dr( "出库用途")
nr("规格") = dr("规格")
nr("出库_数量") = dr("出库_数量")
nr("出库_单价") = dr("出库_售价")
nr("出库_金额") = dr("出库_价税合计")
Next
For Each dr As DataRow In DataTables("期初").Select("日期 is not null")
Dim nr As Row = MainTable.AddNew
nr("日期") = dr("日期")
nr("商品ID") = dr("商品ID")
nr("商品名称") = dr("商品名称")
nr("来源") = dr("来源")
nr("规格") = dr("规格")
nr("期初_数量") = dr("期初_数量")
nr("期初_单价") = dr("期初_单价")
nr("期初_金额") = dr("期初_金额")
Next
For Each dr As DataRow In DataTables("退货").Select("退货日期 is not null")
Dim nr As Row = MainTable.AddNew
nr("日期") = dr("退货日期")
nr("客户名称") = dr("退货客户")
nr("商品ID") = dr("商品ID")
nr("商品名称") = dr("商品名称")
nr("来源") = dr("来源")
nr("规格") = dr("规格")
nr("退货_数量") = dr("退货_数量")
nr("退货_单价") = dr("退货_单价")
nr("退货_金额") = dr("退货_金额")
Next
Tables("进销存").sort="商品ID,日期"
MainTable.ResumeRedraw
End If
'进销存窗口筛选代码
If MainTable.Name = "进销存" Then
Forms("筛选").Show()
Else
Forms("筛选").Visible = False
End If
'该事件maintablechanged的代码是针对我打开的表。
[此贴子已经被作者于2014-9-11 19:48:12编辑过]