以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 合并相同代码 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=146960) |
-- 作者:g1j2h3 -- 发布时间:2020/3/6 18:04:00 -- 合并相同代码 请教下边这段代码如何合并简化 Select Case e.DataCol.Name Case "调拨单号" Dim fdr As DataRow = DataTables("入库明细").Find("入库单号 = \'" & e.DataRow("调拨单号") & "\'") If fdr Is Nothing Then fdr = DataTables("入库明细").AddNew fdr("商品编号") = e.DataRow("商品编号") fdr("商品名称") = e.DataRow("商品名称") fdr("规格型号") = e.DataRow("规格型号") fdr("单位") = e.DataRow("单位") fdr("单价") = e.DataRow("单价") fdr("数量") = e.DataRow("数量") fdr("备注") = e.DataRow("备注") fdr("入库单号") = e.DataRow("调拨单号") End If Case "商品编号","商品名称","规格型号","单位","单价","数量","备注" Dim fdr As DataRow = DataTables("入库明细").Find("入库单号 = \'" & e.DataRow("调拨单号") & "\'") If fdr IsNot Nothing Then fdr("商品编号") = e.DataRow("商品编号") fdr("商品名称") = e.DataRow("商品名称") fdr("规格型号") = e.DataRow("规格型号") fdr("单位") = e.DataRow("单位") fdr("单价") = e.DataRow("单价") fdr("数量") = e.DataRow("数量") fdr("备注") = e.DataRow("备注") End If End Select Select Case e.DataCol.Name Case "调拨单号" Dim fdr As DataRow = DataTables("出库明细").Find("出库单号 = \'" & e.DataRow("调拨单号") & "\'") If fdr Is Nothing Then fdr = DataTables("出库明细").AddNew fdr("商品编号") = e.DataRow("商品编号") fdr("商品名称") = e.DataRow("商品名称") fdr("规格型号") = e.DataRow("规格型号") fdr("单位") = e.DataRow("单位") fdr("单价") = e.DataRow("单价") fdr("数量") = e.DataRow("数量") fdr("备注") = e.DataRow("备注") fdr("出库单号") = e.DataRow("调拨单号") End If Case "商品编号","商品名称","规格型号","单位","单价","数量","备注" Dim fdr As DataRow = DataTables("出库明细").Find("出库单号 = \'" & e.DataRow("调拨单号") & "\'") If fdr IsNot Nothing Then fdr("商品编号") = e.DataRow("商品编号") fdr("商品名称") = e.DataRow("商品名称") fdr("规格型号") = e.DataRow("规格型号") fdr("单位") = e.DataRow("单位") fdr("单价") = e.DataRow("单价") fdr("数量") = e.DataRow("数量") fdr("备注") = e.DataRow("备注") End If End Select |
-- 作者:有点蓝 -- 发布时间:2020/3/6 20:44:00 -- Select Case e.DataCol.Name Case "调拨单号" If e.DataRow.Isnull("调拨单号") = False Dim ns1() As String = {"入库","出库"} For Each s As String In ns1 Dim fdr As DataRow = DataTables(s & "明细").Find(s & "单号 = \'" & e.DataRow("调拨单号") & "\'") If fdr Is Nothing Then fdr = DataTables(s & "明细").AddNew fdr(s & "单号") = e.DataRow("调拨单号") fdr("商品编号") = e.DataRow("商品编号") fdr("商品名称") = e.DataRow("商品名称") fdr("规格型号") = e.DataRow("规格型号") fdr("单位") = e.DataRow("单位") fdr("单价") = e.DataRow("单价") fdr("数量") = e.DataRow("数量") fdr("备注") = e.DataRow("备注") End If Next Next Case "商品编号","商品名称","规格型号","单位","单价","数量","备注" If e.DataRow.Isnull("调拨单号") = False Dim ns1() As String = {"入库","出库"} For Each s As String In ns1 Dim fdr As DataRow = DataTables(s & "明细").Find(s & "单号 = \'" & e.DataRow("调拨单号") & "\'") If fdr IsNot Nothing Then fdr(e.DataCol.Name) = e.DataRow(e.DataCol.Name) End If Next End If End Select |