Foxtable(狐表)用户栏目专家坐堂 → 同步加载数据并更新


  共有1805人关注过本帖树形打印复制链接

主题:同步加载数据并更新

帅哥哟,离线,有人找我吗?
lk15502
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:706 积分:4908 威望:0 精华:0 注册:2016/5/17 12:03:00
同步加载数据并更新  发帖心情 Post By: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

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/1/4 14:19:00 [只看该作者]

 你要学会调试啊。

 

 加入msgbox,看是否进入判断里面了?如果没有进入,说明没有查询到对应的内容。


 回到顶部
帅哥哟,离线,有人找我吗?
lk15502
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:706 积分:4908 威望:0 精华:0 注册:2016/5/17 12:03:00
  发帖心情 Post By: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

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/1/4 15:23:00 [只看该作者]

3楼的方式,比你原先的重复sqlSelect要好。

 回到顶部