以文本方式查看主题
- Foxtable(狐表) (http://foxtable.net/bbs/index.asp)
-- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2)
---- 自动复制行 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=136793)
|
-- 作者:yaojun
-- 发布时间: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编辑过]
|
-- 作者:有点甜
-- 发布时间: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
-- 发布时间: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编辑过]
|
-- 作者:有点甜
-- 发布时间: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
-- 发布时间: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
|
-- 作者:有点甜
-- 发布时间:2019/6/21 18:29:00
--
以下是引用yaojun在2019/6/21 17:13:00的发言:
谢谢,请问可以两端代码合成一段吗,是否可以提升速度:
代码不需要修改,并不会提醒速度。
|