以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 同步加载数据并更新 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=94874) |
-- 作者:lk15502 -- 发布时间:2017/1/4 13:41:00 -- 同步加载数据并更新 老师,下面的代码是按钮里的,帮我看看有什么问题,没有反应? Dim Cols1() As String = {"订单明细编号对外","客户","品名大类","品名小类","坯布规格","缸号类型","投坯重量","投坯匹数","颜色","单双染","色号","卡注"} Dim Cols2() As String = {"订单明细编号对外","客户","品名大类","品名小类","坯布规格","缸号类型","重量","匹数","颜色","单双染","色号","卡注"} If Tables(e.Form.Name & "_table3").Rows.Count > 0 Then For Each r1 As Row In Tables(e.Form.Name & "_table3").Rows Dim dr1s As List(of DataRow) = DataTables("染色生产表").SQLSelect("缸号 = \'" & r1("缸号") & "\'") If dr1s.Count > 0 Then For Each dr1 As DataRow In dr1s For i As Integer = 0 To Cols1.Length -1 dr1(Cols2(i)) = r1(Cols1(i)) Next dr1.Save Next End If Next End If |
-- 作者:有点色 -- 发布时间:2017/1/4 14:19:00 -- 你要学会调试啊。
加入msgbox,看是否进入判断里面了?如果没有进入,说明没有查询到对应的内容。 |
-- 作者:lk15502 -- 发布时间:2017/1/4 14:29:00 -- 老师,后来代码改成这样了,也达到预期作用,但是初学者,没有信心,看代码有没有改进的地方,谢谢? If Tables(e.Form.Name & "_table3").Rows.Count > 0 Then Dim tj As String For Each r As Row In Tables(e.Form.Name & "_table3").Rows tj = "\'" & r("缸号") & "\'," & tj Next tj = tj.TrimEnd(",") DataTables("染色生产表").LoadFilter = "缸号 in (" & tj & ")" DataTables("染色生产表").Load \'-------------------------------------------------------------------------------------------------------------- Dim Cols1() As String = {"订单明细编号对外","客户","品名大类","品名小类","坯布规格","缸号类型","投坯重量","投坯匹数","颜色","单双染","色号","卡注"} Dim Cols2() As String = {"订单明细编号对外","客户","品名大类","品名小类","坯布规格","缸号类型","重量","匹数","颜色","单双染","色号","卡注"} For Each r1 As Row In Tables(e.Form.Name & "_table3").Rows Dim dr1s As List(of DataRow) = DataTables("染色生产表").Select("缸号 = \'" & r1("缸号") & "\'") If dr1s.Count > 0 Then For Each dr1 As DataRow In dr1s For i As Integer = 0 To Cols1.Length -1 dr1(Cols2(i)) = r1(Cols1(i)) Next dr1.Save Next End If Next DataTables("染色生产表").LoadFilter = "缸号 in (" & tj & ")" DataTables("染色生产表").Load End If |
-- 作者:有点色 -- 发布时间:2017/1/4 15:23:00 -- 3楼的方式,比你原先的重复sqlSelect要好。 |