这段代码搞了几天了,搞不定,特来请教
Dim Multi As String = e.Table.Current("Fk")
Dim Values() As String
Dim sql As String =""
Values = Multi.split("/")
If e.Table.Current("Xh") <> ""
' MessageBox.Show(Values(2))
sql = "Select RcjBm as 人材机编码,Mc as 名称,Dw as 单位,Rcjhl As 含量,Rcjhj as 合计 FROM (SELECT Rcjid,Rcjhl,Rcjhj From {QdxrcjhlMx} where Fk = '" & Values(2) & "') as a INNER JOIN {RcjhzMx} as b ON b.RcjId = a.RcjId "
Else
' MessageBox.Show(Values(3))
sql = "Select RcjBm as 人材机编码,Mc as 名称,Dw as 单位,Rcjhl As 含量,Rcjhj as 合计 FROM (SELECT Rcjid,Rcjhl,Rcjhj From {QdxdercjhlMx} where Fk = '" & Values(3) & "') as a INNER JOIN {RcjhzMx} as b ON b.RcjId = a.RcjId "
End If
If sql <> ""
Dim b As New GroupTableBuilder("统计表1",sql)
此主题相关图片如下:捕获.png
b.Groups.AddDef("人材机编码")
b.Groups.AddDef("名称")
b.Groups.AddDef("单位")
b.Groups.AddDef("含量")
b.Totals.AddDef("合计")
b.VerticalTotal = True
' b.Build()
Dim dr As Table = Tables("清单_Table17")
dr.DataSource = b.BuildDataSource()
For Each cc As Col In dr.Cols
If cc.Name = "名称"
cc.Width =80
Else
cc.Width =60
End If
Next
End If
End If
1、先从当前表{Qdmx}中读取列Fk字符串
2、判断当前Row列(Xh)是不是为空,不为空,取From {QdxrcjhlMx},Select FK = 字符串(2),
3、为空From {QdxdercjhlMx} ,Select FK = 字符串(3)
4、 INNER JOIN {RcjhzMx} 读取Mc、RjcBM
结果如下图,问题是取出的结果不满足Select FK = 字符串(2)或Select FK = 字符串(3),多了别的内容,请教是什么原因,代码附上