DataTables("sos").StopRedraw
DataTables("sos").DataRows.Clear()
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim sCols() As String = {"排产日期","部门","班组","订单编号","产品编码","产品名称","排产数量","颜色","商标","分类编码","单价","计划号"}
Dim dCols() As String = {"排产日期","部门","班组","订单编号","产品编码","产品名称","排产数量","颜色","商标","分类编码","单价","计划号"}
cmd.C
cmd.CommandText = "select distinct a.planid as '计划号',CONVERT(VARCHAR(30),a.requiredate,23) as '排产日期',a.requiresumcontractno as'订单编号',a.itemcode as'产品编码',b.name as'产品名称',a.plannum as'排产数量',a.color As '颜色',a.remark as '商标',b.classcode as '分类编码',c.deptcode as'部门',d.workcentercode as '班组',g.rate_exchange * f.price_taxfree as '单价' from ((((aec00000 a join aaa00000 b on a.itemcode=b.code And a.centercode='0100' and (a.requiredate between '2011-02-01' and '2011-02-28')) left join abb00000 c on a.itemcode=c.itemcode)left join abc00000 d on a.itemcode=d.itemcode And d.code='0001') join eba00000 g on a.id_contract=g.id_contract and g.sellunit<>'0702')left join (Select distinct id_product,price_taxfree,id_contract,amount from ebf00000 where centercode='0100') f on a.id_contract=f.id_contract and a.itemcode= f.id_product "
dt = cmd.ExecuteReader()
For Each dr As DataRow In dt.DataRows
Dim nr As DataRow = DataTables("sos").AddNew()
For i As Integer =0 To sCols.Length -1
nr(dCols(i)) = dr(sCols(i))
Next
Next
For Each dr1 As DataRow In DataTables("sos").DataRows
Dim dr2 As DataRow= DataTables("class").Find("classcode = " & "'" & dr1("分类编码") & "'" )
If dr2 IsNot Nothing '如果找到, 则设置各列内容
dr1("约当量")= dr2("number")*dr1("排产数量")
dr1("销售")= dr1("单价")*dr1("排产数量")
dr1("产值")= dr1("单价")*dr1("排产数量")*0.88
dr1("大类")= dr2("classaa")
End If
Next
DataTables("sos").ResumeRedraw
'以下为合并后统计结果显示代码
With Tables("sos")
.MergeMode = MergeModeEnum.Standard
.MergeCols.Clear()
.MergeCols.Add("排产日期")
.MergeCols.Add("部门")
.MergeCols.Add("班组")
.MergeCols.Add("订单编号")
.MergeSort = "排产日期,部门,班组,订单编号"
.AllowMerge = True
End With
Dim t As Table = Tables("sos")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "排产日期"
g.DateGroup = DateGroupEnum.day
g.Caption = "{0}"
t.SubtotalGroups.Add(g)
t.Subtotal(True)
Dim r As Row
Dim r1 As Row
For i As Integer = 1 To t.Rows.Count(True) - 1
r = t.Rows(i,True)
r1 = t.Rows(i-1,True)
If r.IsGroup '如果是分组行
Dim f As String = "排产日期 = #" & r1("排产日期") & "#"
Dim x1 As String = "排产日期 = #" & r1("排产日期") & "# and 大类 = '分类一'"
Dim x2 As String = "排产日期 = #" & r1("排产日期") & "# and 大类 = '分类二'"
Dim x3 As String = "排产日期 = #" & r1("排产日期") & "# and 大类 = '分类三'"
Dim x4 As String = "排产日期 = #" & r1("排产日期") & "# and 大类 = ''分类四"
Dim x5 As String = "排产日期 = #" & r1("排产日期") & "# and 大类 = ''分类五"
Dim x6 As String = "排产日期 = #" & r1("排产日期") & "# and 大类 = ''分类六"
Dim v As String = "销售金额:" & t.Compute("Sum(销售)",f)
v = v & " /产值:" & t.Compute("Sum(产值)",f)
v = v & "/分类一:" & t.Compute("Sum(约当量)",x1)
v = v & "/分类二:" & t.Compute("Sum(约当量)",x2)
v = v & "/分类三:" & t.Compute("Sum(约当量)",x3)
v = v & "/分类四:" & t.Compute("Sum(约当量)",x4)
v = v & "/分类无:" & t.Compute("Sum(约当量)",x5)
v = v & "/分类六:" & t.Compute("Sum(约当量)",x6)
r("排产日期") = format(r1("排产日期"),"yyyy年MM月dd日") & "排产信息提示:" & v
Tables("sos").AutoSizeRow(i)
End If
Next