Foxtable(狐表)用户栏目专家坐堂 → 不重复加载


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

主题:不重复加载

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/3 14:04:00 [显示全部帖子]

dim filter as string = "1=1"
For Each dc As DataCol In DataTables("表A").datacols
    filter &= " And " & dc.name & " = '" & dr(dc.name) & "'"
Next
msgbox(filter)
[此贴子已经被作者于2015/11/3 14:04:34编辑过]

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/3 14:06:00 [显示全部帖子]

dim filter as string = "1=1"
For Each dc As DataCol In DataTables("表A").datacols
    filter &= " And convert(" & dc.name & ",'System.String') = '" & dr(dc.name) & "'"
Next
msgbox(filter)

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/3 14:27:00 [显示全部帖子]

Dim Cols1() As String = {"项目","下单日期","MK号","DO号","城市","客户","送货地址","物料代码","数量","体积","重量","收货时间","是否采购订单","车型","司机","车牌","车数","出车日期" }
Dim Cols2() As String = {"项目","下单日期","MK号","DO号","城市","客户","送货地址","物料代码","数量","体积","重量","收货时间","是否采购订单","车型","司机","车牌","车数","出车日期" }
Dim count As Integer = 0
For Each r As Row In Tables("配载订单").GetCheckedRows
    Dim filter As String = "1=1"
    For Each dc As String In Cols1
        filter &= " And convert(" & dc & ",'System.String') = '" & r(dc) & "'"
    Next
   
    Dim dr As DataRow = DataTables("客服跟单").find(filter)
    If dr Is Nothing Then
        dr = DataTables("客服跟单").AddNew
        count += 1
    End If
    For i As Integer = 0 To Cols1.Length -1
        dr(Cols2(i)) = r(Cols1(i))
    Next
   
Next
msgbox(count)

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/3 15:28:00 [显示全部帖子]

这样写


Dim Cols1() As String = {"第一列", "第二列"}
Dim Cols2() As String = {"第一列","第二列"}
Dim count As Integer = 0
For Each r As Row In Tables("表A").GetCheckedRows
    Dim filter As String = ""
    Dim str As String = ""
    For Each dc As String In Cols1
        filter &= "isnull(convert(" & dc & ",'System.String'),'')+'|'+"
        str &= r(dc) & "|"
    Next
    filter = "(" & filter.trim("+") & ") = '" & str & "'"
    Dim dr As DataRow = DataTables("表B").find(filter)
    If dr Is Nothing Then
        dr = DataTables("表B").AddNew
        count += 1
    End If
    For i As Integer = 0 To Cols1.Length -1
        dr(Cols2(i)) = r(Cols1(i))
    Next
   
Next
msgbox(count)


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/3 15:37:00 [显示全部帖子]

不会,我测试不会啊。

 

上传例子测试。


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/3 15:49:00 [显示全部帖子]

Dim Cols1() As String = {"第一列", "第二列","第三列"}
Dim Cols2() As String = {"第一列","第二列", "第三列"}
Dim count As Integer = 0
For Each r As Row In Tables("表A").GetCheckedRows
    Dim filter As String = "1=1"
    For Each dc As String In Cols1
        If r.IsNull(dc) Then
            filter &= " and " & dc & " is null"
        Else
            Dim c As Col = Tables("表B").Cols(dc)
            If c.IsNumeric Then
                filter &= " and " & dc & " = " & r(dc)
            ElseIf c.IsBoolean Then
                If r(dc) = True Then
                    filter &= " and " & dc & " = true"
                Else
                    filter &= " and " & dc & " = false"
                End If
            ElseIf c.IsDate Then
                filter &= " and " & dc & " = #" & r(dc) & "#"
            Else
                filter &= " and " & dc & " = '" & r(dc) & "'"
            End If
        End If
    Next

    Dim dr As DataRow = DataTables("表B").find(filter)
    If dr Is Nothing Then
        dr = DataTables("表B").AddNew
        count += 1
    End If
    For i As Integer = 0 To Cols1.Length -1
        dr(Cols2(i)) = r(Cols1(i))
    Next
   
Next
msgbox(count)


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/3 16:45:00 [显示全部帖子]

没问题啊

 

Dim Cols1() As String = {"项目","下单日期","MK号","DO号","城市","客户","送货地址","物料代码","数量","体积","重量","收货时间","是否采购订单","车型","司机","车牌","车数","出车日期" }
Dim Cols2() As String = {"项目","下单日期","MK号","DO号","城市","客户","送货地址","物料代码","数量","体积","重量","收货时间","是否采购订单","车型","司机","车牌","车数","出车日期" }

Dim count As Integer = 0
For Each r As Row In Tables("回单异常").GetCheckedRows
    Dim filter As String = "1=1"
    For Each dc As String In Cols1
        If r.IsNull(dc) Then
            filter &= " and " & dc & " is null"
        Else
            Dim c As Col = Tables("应付款项").Cols(dc)
            If c.IsNumeric Then
                filter &= " and " & dc & " = " & r(dc)
            ElseIf c.IsBoolean Then
                If r(dc) = True Then
                    filter &= " and " & dc & " = true"
                Else
                    filter &= " and " & dc & " = false"
                End If
            ElseIf c.IsDate Then
                filter &= " and " & dc & " = #" & r(dc) & "#"
            Else
                filter &= " and " & dc & " = '" & r(dc) & "'"
            End If
        End If
    Next
   
    Dim dr As DataRow = DataTables("应付款项").find(filter)
    If dr Is Nothing Then
        dr = DataTables("应付款项").AddNew
        count += 1
    End If
    For i As Integer = 0 To Cols1.Length -1
        dr(Cols2(i)) = r(Cols1(i))
    Next
   
Next
msgbox(count)


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/3 17:10:00 [显示全部帖子]

看14楼,我测试不会有问题。

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/3 17:37:00 [显示全部帖子]

Dim Cols1() As String = {"项目","下单日期","MK号","DO号","城市","客户","送货地址","物料代码","数量","体积","重量","收货时间","是否采购订单","司机","车牌","车型","车数","出车日期" ,"异常描述","处理结果","责任方","回单异常原因","责任单位","解决措施","补单司机","罚款金额"}
Dim Cols2() As String = {"项目","下单日期","MK号","DO号","城市","客户","送货地址","物料代码","数量","体积","重量","收货时间","是否采购订单","司机","车牌","车型","车数","出车日期","异常描述","处理结果","责任方","回单异常原因","责任单位","解决措施","补单司机","罚款金额" }

Dim count As Integer = 0
systemready = False
For Each r As Row In Tables("回单异常").GetCheckedRows
    Dim filter As String = "1=1"
    For Each dc As String In Cols1
        If r.IsNull(dc) Then
            filter &= " and " & dc & " is null"
        Else
            Dim c As Col = Tables("应付款项").Cols(dc)
            If c.IsNumeric Then
                filter &= " and " & dc & " = " & r(dc)
            ElseIf c.IsBoolean Then
                If r(dc) = True Then
                    filter &= " and " & dc & " = true"
                Else
                    filter &= " and " & dc & " = false"
                End If
            ElseIf c.IsDate Then
                filter &= " and " & dc & " = #" & r(dc) & "#"
            Else
                filter &= " and " & dc & " = '" & r(dc) & "'"
            End If
        End If
    Next
    Dim dr As DataRow = DataTables("应付款项").find(filter)
    If dr Is Nothing Then
        dr = DataTables("应付款项").AddNew
        count += 1
    End If
    For i As Integer = 0 To Cols1.Length -1
        If r.IsNull(Cols1(i)) Then
            dr(Cols2(i)) = Nothing
        Else
            dr(Cols2(i)) = r(Cols1(i))
        End If
    Next
   
Next
systemready = True
msgbox(count)


 回到顶部