以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  复制多行  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=87822)

--  作者:lk15502
--  发布时间:2016/7/20 15:19:00
--  复制多行
A表中输入一行或多行数据,通过一个按钮复制到B表,B表只比A表多了一个列,其他都一样,求怎么写代码;
--  作者:大红袍
--  发布时间:2016/7/20 15:26:00
--  

参考

 

http://www.foxtable.com/webhelp/scr/1533.htm

 


--  作者:lk15502
--  发布时间:2016/7/20 16:24:00
--  
If messagebox.show("数据将被复制到库存表,请确认准确与否","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Warning) = DialogResult.Yes Then
    Dim Cols1() As String = {"入库日期","入库编号","入库日期统计","客户","订单号","克重","门幅","缸号","颜色","重量","匹数","仓位","销售人员","品名","入库类型","标注"}
    Dim Cols2() As String = {"入库日期","入库编号","入库日期统计","客户","订单号","克重","门幅","缸号","颜色","重量","匹数","仓位","销售人员","品名","入库类型","标注"}
    For Each dr1 As DataRow In DataTables("入库表").datarows
        If DataTables("库存表").Find("入库编号 = \'" & r("入库编号") & "\'") Is Nothing Then
            
            Dim dr2 As DataRow = DataTables("库存表").addnew()
            For i As Integer = 0 To Cols1.length -1
                dr2(Cols2(i)) = dr1(Cols1(i))
            Next
            dr2.save
        Next
    End If
End If

请问上面的代码有什么问题吗
 If DataTables("库存表").Find("入库编号 = \'" & r("入库编号") & "\'") Is Nothing Then 是不要重复的行再被复制到库存表,
好像感觉不完善
            

--  作者:大红袍
--  发布时间:2016/7/20 16:27:00
--  
If messagebox.show("数据将被复制到库存表,请确认准确与否","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Warning) = DialogResult.Yes Then
    Dim Cols1() As String = {"入库日期","入库编号","入库日期统计","客户","订单号","克重","门幅","缸号","颜色","重量","匹数","仓位","销售人员","品名","入库类型","标注"}
    Dim Cols2() As String = {"入库日期","入库编号","入库日期统计","客户","订单号","克重","门幅","缸号","颜色","重量","匹数","仓位","销售人员","品名","入库类型","标注"}
    For Each dr1 As DataRow In DataTables("入库表").datarows
        If DataTables("库存表").Find("入库编号 = \'" & dr1("入库编号") & "\'") Is Nothing Then
            Dim dr2 As DataRow = DataTables("库存表").addnew()
            For i As Integer = 0 To Cols1.length -1
                dr2(Cols2(i)) = dr1(Cols1(i))
            Next
            dr2.save
        End If
    Next
End If