以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 保存错位 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=116828) |
-- 作者:小美菜 -- 发布时间:2018/3/31 22:52:00 -- For Each key As String In dic.keys Dim dr As DataRow = DataTables("材料需求明细").AddNew() dr("存货编码") = key dr("需求数量") = dic(key) Next这个位置重新增加了记录,你应该是找到前面的记录,然后添加数据,这样就不会乱了 |
-- 作者:有点甜 -- 发布时间:2018/4/1 17:46:00 -- Dim dic As new Dictionary(of String,Integer) DataTables("材料需求明细").DataRows.Clear() For Each dr1 As DataRow In DataTables("生产在制品").DataRows For Each dr2 As DataRow In DataTables("BOM基础数据").Select("[成品编码] = \'" & dr1("成品编码") & "\'") Dim nm As String = dr2("生产批次") Dim vl As Integer = dr1("计划数量") * dr2("单车用量") If dic.ContainsKey(nm) = False dic.Add(nm,vl) Else dic(nm) = dic(nm)+ vl End If Next Next For Each key As String In dic.keys Dim dr As DataRow = DataTables("材料需求明细").AddNew() Dim cr As Row = Tables("生产在制品").Current dr("存货编码") = cr("存货编码") dr("需求数量") = dic(key) dr("生产批次") = key dr("毛坯产地") = cr("毛坯产地") dr("下达日期") = cr("下达日期") Next |
-- 作者:有点甜 -- 发布时间:2018/4/1 20:15:00 -- Dim dic As new Dictionary(of String,Integer) DataTables("材料需求明细").DataRows.Clear() For Each dr1 As DataRow In DataTables("生产在制品").DataRows For Each dr2 As DataRow In DataTables("BOM基础数据").Select("[成品编码] = \'" & dr1("成品编码") & "\'") Dim nm As String = dr2("生产批次") & "|" & dr2("成品编码") Dim vl As Integer = dr1("计划数量") * dr2("单车用量") If dic.ContainsKey(nm) = False dic.Add(nm,vl) Else dic(nm) = dic(nm)+ vl End If Next Next For Each key As String In dic.keys Dim dr As DataRow = DataTables("材料需求明细").AddNew() Dim cr As Row = Tables("生产在制品").Current dr("存货编码") = key.split("|")(1) dr("需求数量") = dic(key) dr("生产批次") = key.split("|")(0) dr("毛坯产地") = cr("毛坯产地") dr("下达日期") = cr("下达日期") Next |
-- 作者:有点甜 -- 发布时间:2018/4/1 20:42:00 --
Dim nm As String = dr1("生产批次") & "|" & dr2("材料编码") |
-- 作者:有点甜 -- 发布时间:2018/4/1 22:10:00 -- 认认真真看9楼啊
Dim nm As String = dr1("生产批次") & "|" & dr2("材料编码") |