SystemReady = False
Tables("Main_Table2").StopRedraw
DataTables("订单").StopRedraw
e.form.StopRedraw
For Each dr As DataRow In CurrentTable.DataTable.DataRows
dr("产品")=dr("产品")
dr("数量")=-dr("数量")
Next
For Each dr2 As DataRow In CurrentTable.DataTable.DataRows
Dim dr1 As DataRow = DataTables("订单").AddNew
dr1("产品")=dr2("产品")
dr1("数量")=dr2("数量")
dr1("用户")=_UserName
dr1("时间")=Date.Now()
Next
DataTables("订单").Save
Dim cm As WinForm.TextBox = e.Form.Controls("zdcm")
cm.Value = 0
Dim g As New GroupTableBuilder("统计表1", DataTables("订单"))
g.Groups.AddDef("产品")
g.Totals.AddDef("数量")
g.FromServer = True
Tables("Main_Table2").DataSource = g.BuildDataSource()
For Each dr As Row In Tables("Main_Table2").Rows
Dim i As Integer
Dim tb As WinForm.Label = e.Form.Controls("Label3")
i= Tables("Main_Table2").Compute("sum(数量)")
tb.Text=i
Next
Tables("Main_Table2").Sort = "数量 DESC"
DataTables("Main_Table2").RemoveFor("产品 is null")
DataTables("Main_Table2").RemoveFor("数量 = 0")
Tables("Main_Table2").ResumeRedraw
DataTables("订单").ResumeRedraw
e.form.ResumeRedraw
SystemReady = True