Foxtable(狐表)用户栏目专家坐堂 → 自动复制行


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

主题:自动复制行

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


加好友 发短信
等级:二尾狐 帖子:576 积分:4737 威望:0 精华:0 注册:2014/7/3 15:28:00
自动复制行  发帖心情 Post By:2019/6/21 16:34:00 [只看该作者]

从“生产订单.订单明细”表复制当前“提交”=true和“属性”= “生产”的行到“PMC车间计划”表里面,用如下代码实现,现请求大师帮忙修改代码,使其“PMC车间计划”里面“序列号”和“名称”相同的行不在复制,谢谢

If e.DataCol.Name = "提交" AndAlso e.DataRow("提交") = True AndAlso e.DataRow("属性") = "生产" Then
    Dim nma() As String = {"序列号","名称","规格","需求数量","属性","计划数量","订单号","产品名称"} 'A表数据来源列
    Dim nmb() As String = {"序列号","名称","规格","需求数量","属性","计划数量","订单号","产品名称"} 'B表数据接收列
    Dim dr As DataRow = DataTables("PMC车间计划").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
    Next
End If

请帮忙修改代码,谢谢

[此贴子已经被作者于2019/6/21 16:34:50编辑过]

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/6/21 17:08:00 [只看该作者]

 

If e.DataCol.Name = "提交" AndAlso e.DataRow("提交") = True AndAlso e.DataRow("属性") = "生产" Then
    Dim nma() As String = {"序列号","名称","规格","需求数量","属性","计划数量","订单号","产品名称"} 'A表数据来源列
    Dim nmb() As String = {"序列号","名称","规格","需求数量","属性","计划数量","订单号","产品名称"} 'B表数据接收列
    Dim dr As DataRow = DataTables("PMC车间计划").find("序列号='" & e.DataRow("序列号") & "' and 名称='" & e.DataRow("名称") & "'")
    If dr Is Nothing Then dr = DataTables("PMC车间计划").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
    Next
End If

 


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


加好友 发短信
等级:二尾狐 帖子:576 积分:4737 威望:0 精华:0 注册:2014/7/3 15:28:00
  发帖心情 Post By:2019/6/21 17:13:00 [只看该作者]

谢谢,请问可以两端代码合成一段吗,是否可以提升速度:

If e.DataCol.Name = "提交" AndAlso e.DataRow("提交") = True AndAlso e.DataRow("属性") = "生产" Then
    Dim nma() As String = {"序列号","名称","规格","需求数量","属性","计划数量","订单号","产品名称"} 'A表数据来源列
    Dim nmb() As String = {"序列号","名称","规格","需求数量","属性","计划数量","订单号","产品名称"} 'B表数据接收列
    Dim dr As DataRow = DataTables("PMC车间计划").find("序列号='" & e.DataRow("序列号") & "' and 名称='" & e.DataRow("名称") & "'")
    If dr Is Nothing Then dr = DataTables("PMC车间计划").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
    Next
End If

 

 

If e.DataCol.Name = "提交" AndAlso e.DataRow("提交") = True AndAlso e.DataRow("属性") = "采购" Then
    Dim nma() As String = {"序列号","名称","规格","需求数量","属性","计划数量","订单号","产品名称"} 'A表数据来源列
    Dim nmb() As String = {"序列号","名称","规格","需求数量","属性","计划数量","订单号","产品名称"} 'B表数据接收列
    Dim dr As DataRow = DataTables("PMC车间计划").find("序列号='" & e.DataRow("序列号") & "' and 名称='" & e.DataRow("名称") & "'")
    If dr Is Nothing Then dr = DataTables("采购计划").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
    Next
End If

[此贴子已经被作者于2019/6/21 17:14:37编辑过]

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/6/21 17:18:00 [只看该作者]

 

If e.DataCol.Name = "提交" AndAlso e.DataRow("提交") = True AndAlso (e.DataRow("属性") = "生产" orelse e.DataRow("属性") = "采购") Then
    Dim nma() As String = {"序列号","名称","规格","需求数量","属性","计划数量","订单号","产品名称"} 'A表数据来源列
    Dim nmb() As String = {"序列号","名称","规格","需求数量","属性","计划数量","订单号","产品名称"} 'B表数据接收列
    Dim dr As DataRow = DataTables("PMC车间计划").find("序列号='" & e.DataRow("序列号") & "' and 名称='" & e.DataRow("名称") & "'")
    If dr Is Nothing Then dr = DataTables("采购计划").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
    Next
End If

 

 


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


加好友 发短信
等级:二尾狐 帖子:576 积分:4737 威望:0 精华:0 注册:2014/7/3 15:28:00
  发帖心情 Post By:2019/6/21 17:24:00 [只看该作者]

抱歉,刚才是复制的,忘记修改了,两个表要复制的列名不一样:

If e.DataCol.Name = "提交" AndAlso e.DataRow("提交") = True AndAlso e.DataRow("属性") = "生产" Then
    Dim nma() As String = {"序列号","名称","规格","需求数量","属性","计划数量","订单号","产品名称"} 'A表数据来源列
    Dim nmb() As String = {"序列号","名称","规格","需求数量","属性","计划数量","订单号","产品名称"} 'B表数据接收列
    Dim dr As DataRow = DataTables("PMC车间计划").find("序列号='" & e.DataRow("序列号") & "' and 名称='" & e.DataRow("名称") & "'")
    If dr Is Nothing Then dr = DataTables("PMC车间计划").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
    Next
End If

 

 

If e.DataCol.Name = "提交" AndAlso e.DataRow("提交") = True AndAlso e.DataRow("属性") = "采购" Then
    Dim nma() As String = {"序列号","名称","入库日期","需求数量","属性","备注"} 'A表数据来源列
    Dim nmb() As String = {"序列号","名称","入库日期","需求数量","属性","备注"} 'B表数据接收列
    Dim dr As DataRow = DataTables("PMC车间计划").find("序列号='" & e.DataRow("序列号") & "' and 名称='" & e.DataRow("名称") & "'")
    If dr Is Nothing Then dr = DataTables("采购计划").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
    Next
End If


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/6/21 18:29:00 [只看该作者]

以下是引用yaojun在2019/6/21 17:13:00的发言:

谢谢,请问可以两端代码合成一段吗,是否可以提升速度:

 

代码不需要修改,并不会提醒速度。


 回到顶部