Dim q As new QueryBuilder
q.TableName = "备案明细表"
q.Con nec ti
q.Sel ectString = "s ele ct * from {备案信息表} where (产品名称 Like '%面膜%') And (配方名称 In (s el ect DISTINCT {配方明细}.[PFDW] from {配方明细} where {配方明细}.YLDW in (s ele ct DISTINCT {原料目录}.[YLDW] from {原料目录} where 原料名称 in ('1.3丙二醇','1.3-丙二醇')))) And BAXXDW is not null ORDER BY BAXXDW DESC"
q.Build
If DataTables("备案明细表").DataRows.Count > 0 Then
Dim cmd As New SQLCommand
Dim qymc As DataTable
Dim dgmx As DataTable
cm d.Con necti
Dim ids As String = DataTables("备案明细表").GetComboListString("BAXXDW")
If ids > "" Then
ids = ids.Replace("|",",")
ids = ids.TrimStart(",")
cmd.CommandText = "S ELE CT [BAXXDW],[QYDW] From {代工明细} where BAXXDW in (" & ids & ")"
dgmx = cmd.ExecuteReader()
If dgmx.DataRows.Count > 0 Then
ids = dgmx.GetComboListString("QYDW")
ids = ids.Replace("|",",")
ids = ids.TrimStart(",")
cmd.CommandText = "SE LE CT [QYDW],[企业名称],[业务员] From {企业目录} where QYDW in (" & ids & ")"
qymc = cmd.ExecuteReader()
If qymc.datarows.Count > 0 Then
If DataTables("备案明细表").datacols.Contains("代工企业") = False Then
DataTables("备案明细表").datacols.Add("代工企业", Gettype(String), 250)
End If
For Each r As Row In Tables("备案明细表").Rows
Dim drs As List(Of DataRow)
drs = dgmx.Select("[BAXXDW] = " & r("BAXXDW") & "")
Output.show(drs.Count)
If drs.Count > 0 Then
Dim mc As String = ""
For Each dr As DataRow In drs
Dim tr As DataRow = qymc.find("QYDW = " & dr("QYDW") & "")
If tr IsNot Nothing Then
Output.show(r("产品名称"))
Output.show(tr("企业名称"))
If mc = "" Then
mc = tr("企业名称")
Else
mc = mc & "," & tr("企业名称")
End If
r("代工企业")= mc
End If
Next
End If
Next
End If
End If
End If
End If
Output.show(1)