以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- for each 取数组元素的值。 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=98492) |
-- 作者:huhu -- 发布时间:2017/3/30 16:50:00 -- for each 取数组元素的值。 Dim yphsl As WinForm.Button = e.Form.Controls("Button5") Dim bfhfh As WinForm.Button = e.Form.Controls("Button6") Dim tg As WinForm.RadioButton = Forms("配货整理").Controls("通过") Dim wg As WinForm.RadioButton = Forms("配货整理").Controls("未过") Dim dr As Row = Tables("销售出库单列表").current Dim str As String = dr("发货要求") Dim filter,filter1 As String filter1 = "物料编码 = \'" & dr("存货编码") & "\' and 发货单号 = \'" & dr("发货单号") & "\'" Dim gdh,gdhh As String Dim msm() As String Dim gdsl() As String = str.Split("|") For Index As Integer = 0 To gdsl.Length - 1 Dim gds() As String = gdsl(Index).Split("_") msm(Index)= "物料编码 = \'" & dr("存货编码") & "\' and 库位编码 = \'" & dr("仓库编码") & "\' And 生产订单号码 = \'" & gds(0) & "\' and 工单行号 = \'" & gds(1) & "\'" Next Select Case e.DataCol.name Case "SN" If Not e.DataRow.IsNull("SN") Then Dim drr As DataRow = DataTables("库存明细表").SQLFind("SN = \'" & e.DataRow("SN") & "\' and 物料编码 = \'" & dr("存货编码") & "\'") If drr IsNot Nothing Then If drr("状态") = "配货完成" Then e.DataRow("状态") = "配货重复扫描" e.DataRow("物料编码") = dr("存货编码") e.DataRow("发货单号") = dr("发货单号") e.DataRow("数量") = 0 e.DataRow.save Else Dim nms() As String = {"生产订单号码","工单行号","物料编码","物料名称","类别说明","产品批次","订单号","订单行号","客户","备注","软件版本","MAC","HW","入库单号","库位类别","库位编码","入库完成时间","入库方式","在库生命周期"} For Each nm As String In nms e.DataRow(nm) = drr(nm) Next e.DataRow("状态") = "配货完成" e.DataRow("发货单号") = dr("发货单号") e.DataRow("数量") = 1 e.DataRow.save drr("状态") = "配货完成" drr("配货完成时间") = Date.now drr("U8发货单号") = dr("发货单号") drr("业务员") = dr("业务员") drr("货运单号") = dr("货运单号") drr("发货地址") = dr("发货地址") drr.Save Dim mr As DataRow = DataTables("库位数量统计").SQLFind("生产订单号码 = \'" & drr("生产订单号码") & "\' and 工单行号 = \'" & drr("工单行号") & "\' and 物料编码 = \'" & drr("物料编码") & "\' and 库位编码 = \'" & drr("库位编码") & "\' and 库位类别 = \'" & drr("库位类别") & "\'") If mr IsNot Nothing Then Dim cmd1 As new SQLCommand cmd1.C cmd1.CommandText = "Exec kwsltjdec \'" & mr("生产订单号码") & "\',\'" & mr("工单行号") & "\',\'" & mr("物料编码") & "\',\'" & mr("库位编码") & "\',\'" & mr("库位类别") & "\'" Dim t As DataTable = cmd1.ExecuteReader mr.save End If Dim tr As String = "物料编码 = \'" & e.DataRow("物料编码") & "\' and 库位类别 = \'" & e.DataRow("库位类别") & "\' and 生产订单号码 = \'" & e.DataRow("生产订单号码") & "\' and 工单行号 = \'" & e.DataRow("工单行号") & "\'" Dim mrr As DataRow = DataTables("可用数量表").SQLFind(tr) If mrr IsNot Nothing Then For Each id As Integer = 0 To msm.Length - 1 If (msm(id) <> tr) Then Dim cmd1 As new SQLCommand cmd1.C cmd1.CommandText = "Exec kwsltjdec \'" & mr("生产订单号码") & "\',\'" & mr("工单行号") & "\',\'" & mr("物料编码") & "\',\'" & mr("库位编码") & "\',\'" & mr("库位类别") & "\'" Dim t As DataTable = cmd1.ExecuteReader mr.save End If Next End If 请帮忙解决一下。我的目的是希望tr不等于数组msm的任何元素值,才能执行褐色的代码。现在代码就会不等于其中的一个值就会执行褐色代码。
|
-- 作者:狐狸爸爸 -- 发布时间:2017/3/30 17:31:00 -- For Each id As Integer = 0 To msm.Length - 1 If (msm(id) <> tr) Then Dim cmd1 As new SQLCommand cmd1.C cmd1.CommandText = "Exec kwsltjdec \'" & mr("生产订单号码") & "\',\'" & mr("工单行号") & "\',\'" & mr("物料编码") & "\',\'" & mr("库位编码") & "\',\'" & mr("库位类别") & "\'" Dim t As DataTable = cmd1.ExecuteReader mr.save End If Next 改为: For Each id As Integer = 0 To msm.Length - 1 Dim match As Boolean = false If (msm(id) = tr) Then match = true End If if match = false then Dim cmd1 As new SQLCommand cmd1.C cmd1.CommandText = "Exec kwsltjdec \'" & mr("生产订单号码") & "\',\'" & mr("工单行号") & "\',\'" & mr("物料编码") & "\',\'" & mr("库位编码") & "\',\'" & mr("库位类别") & "\'" Dim t As DataTable = cmd1.ExecuteReader mr.save End if Next |
-- 作者:huhu -- 发布时间:2017/3/30 19:49:00 -- 感觉这么改是不是也有问题啊。 比如数组msm有3个值为1,2,3. tr如果为1,2,3中的任何一个,都不能执行褐色代码。 只有tr为不等于1,2,3才能执行褐色代码,而且也只能执行一次。 换句话说就是拿tr的值与数组里面的每个值都挨个比较一下。循环完发现没有一个与tr相等的,那就执行一次褐色代码。 假如果发现哪怕是有一个相等的,那就不能执行褐色代码。 |
-- 作者:有点色 -- 发布时间:2017/3/30 19:58:00 -- Dim match As Boolean = False For Each id As Integer = 0 To msm.Length - 1 |
-- 作者:huhu -- 发布时间:2017/3/31 19:03:00 -- Dim gdsl() As String = str.Split("|") Dim msm() As String For Index As Integer = 0 To gdsl.Length - 1 Dim msm() As String Dim gds() As String = gdsl(Index).Split("_") msm(Index)= "物料编码 = \'" & dr("存货编码") & "\' and 库位编码 = \'" & dr("仓库编码") & "\' And 生产订单号码 = \'" & gds(0) & "\' and 工单行号 = \'" & gds(1) & "\'" Next Select Case e.DataCol.name Case "SN" If Not e.DataRow.IsNull("SN") Then Dim drr As DataRow = DataTables("库存明细表").SQLFind("SN = \'" & e.DataRow("SN") & "\' and 物料编码 = \'" & dr("存货编码") & "\'") If drr IsNot Nothing Then If drr("状态") = "配货完成" Then e.DataRow("状态") = "配货重复扫描" e.DataRow("物料编码") = dr("存货编码") e.DataRow("发货单号") = dr("发货单号") e.DataRow("数量") = 0 e.DataRow.save Else Dim nms() As String = {"生产订单号码","工单行号","物料编码","物料名称","类别说明","产品批次","订单号","订单行号","客户","备注","软件版本","MAC","HW","入库单号","库位类别","库位编码","入库完成时间","入库方式","在库生命周期"} For Each nm As String In nms e.DataRow(nm) = drr(nm) Next e.DataRow("状态") = "配货完成" e.DataRow("发货单号") = dr("发货单号") e.DataRow("数量") = 1 e.DataRow.save drr("状态") = "配货完成" drr("配货完成时间") = Date.now drr("U8发货单号") = dr("发货单号") drr("业务员") = dr("业务员") drr("货运单号") = dr("货运单号") drr("发货地址") = dr("发货地址") drr.Save Dim mr As DataRow = DataTables("库位数量统计").SQLFind("生产订单号码 = \'" & drr("生产订单号码") & "\' and 工单行号 = \'" & drr("工单行号") & "\' and 物料编码 = \'" & drr("物料编码") & "\' and 库位编码 = \'" & drr("库位编码") & "\' and 库位类别 = \'" & drr("库位类别") & "\'") If mr IsNot Nothing Then Dim cmd1 As new SQLCommand cmd1.C cmd1.CommandText = "Exec kwsltjdec \'" & mr("生产订单号码") & "\',\'" & mr("工单行号") & "\',\'" & mr("物料编码") & "\',\'" & mr("库位编码") & "\',\'" & mr("库位类别") & "\'" Dim t As DataTable = cmd1.ExecuteReader mr.save End If Dim tr As String = "物料编码 = \'" & e.DataRow("物料编码") & "\' and 库位类别 = \'" & e.DataRow("库位类别") & "\' and 生产订单号码 = \'" & e.DataRow("生产订单号码") & "\' and 工单行号 = \'" & e.DataRow("工单行号") & "\'" Dim mrr As DataRow = DataTables("可用数量表").SQLFind(tr) If mrr IsNot Nothing Then Dim match As Boolean = False For id As Integer = 0 To msm.Length If (msm(id) = tr) Then match = True Exit For End If Next If match = False Dim cmd1 As new SQLCommand cmd1.C cmd1.CommandText = "Exec kwsltjdec \'" & mr("生产订单号码") & "\',\'" & mr("工单行号") & "\',\'" & mr("物料编码") & "\',\'" & mr("库位编码") & "\',\'" & mr("库位类别") & "\'" Dim t As DataTable = cmd1.ExecuteReader mr.save End If End If End If Else e.DataRow("状态") = "配货完成" e.DataRow("物料编码") = dr("存货编码") e.DataRow("发货单号") = dr("发货单号") e.DataRow("数量") = 1 e.DataRow.save Dim rr As DataRow = DataTables("库存明细表").AddNew rr("SN") = e.DataRow("SN") rr("物料编码") = e.DataRow("物料编码") rr("U8发货单号") = dr("发货单号") rr("状态") = "配货完成" rr("出库方式") = "type5" rr("数量") = 1 rr.save Dim sum2 As Integer sum2 = DataTables("配货扫描").SQLCompute("Sum(数量)",filter1 & "And 状态 = \'配货完成\' and SN is not null") yphsl.text = "发货单号:" & dr("发货单号") & "已完成配货数量" & "=" & sum2 If dr("挪货数量") = sum2 Then dr("配货状态") = True dr("配货完成时间") = Date.now dr.save tg.Enabled = True wg.Enabled = True Else tg.Enabled = False wg.Enabled = False End If End If End If End Select 蓝色的代码是不是也有问题。我想把每次合成的内容作为msm数组的元素。
|
-- 作者:有点蓝 -- 发布时间:2017/3/31 20:36:00 -- Dim msm(gdsl.Length - 1) As String For Index As Integer = 0 To gdsl.Length - 1 Dim gds() As String = gdsl(Index).Split("_") msm(Index)= "物料编码 = \'" & dr("存货编码") & "\' and 库位编码 = \'" & dr("仓库编码") & "\' And 生产订单号码 = \'" & gds(0) & "\' and 工单行号 = \'" & gds(1) & "\'" Next
|