销售接单表想直接引用发货表的部分列,麻烦老师看下我写的代码错在那里Dim Cols1() As String = {"车型", "车辆来源", "凭证号", "发货日期"}
Dim Cols2() As String = {"车型", "车辆来源", "凭证号", "发货日期"}
Dim dr As DataRow
dr = DataTables("发货表").Find("[接单单号] = '" & e.NewValue & "'")
Dim Filter As String = "[接单单号] = '" & e.DataRow("接单单号") & "'"
Dim drs As List(Of DataRow) = DataTables("销售接单").Select(Filter)
For Each dr As DataRow In drs
For i As Integer = 0 To Cols1.Length - 1
dr(Cols2(i)) = drs(Cols1(i))
Next
Next
datacolchanged事件?参考:
http://www.foxtable.com/webhelp/topics/1451.htm
If e.DataCol.Name = "接单单号" Then '如果内容发生变动的是品名列
Dim Cols1() As String = {"车型", "车辆来源", "凭证号", "发货日期"}
If e.NewValue Is Nothing Then '如果新值是空白,也就是品名列的内容为空
For i As Integer = 0 To Cols1.Length - 1
e.DataRow(Cols1(i)) = Nothing
Next
Else
Dim dr As DataRow
'否则在产品表查找同名的产品行,将找到的行赋值给变量dr
dr = DataTables("产品").Find("[接单单号] = '" & e.NewValue & "'")
If dr IsNot Nothing Then '如果找到了同名的产品行,也就是dr不是Nothing For i As Integer = 0 To Cols1.Length - 1
e.DataRow(Cols1(i)) = dr(Cols1(i))
Next
End If
End If
End If
我先有销售接单表,也就是说我想在发货表填了四项内容后,能即时填到销售接单表中
发货表datacolchanged事件
Select Case e.DataCol.Name
Case "车型", "车辆来源", "凭证号", "发货日期"
Dim Filter As String = "[接单单号] = '" & e.DataRow("接单单号") & "'"
For i As Integer = 0 To Cols1.Length - 1
DataTables("销售接单表").ReplaceFor(Cols1(i), e.DataRow(Cols1(i)), Filter)
next
End Select
Select Case e.DataCol.Name
Case "车型", "车辆来源", "凭证号", "发货日期"
Dim Filter As String = "[接单单号] = '" & e.DataRow("接单单号") & "'"
DataTables("销售接单表").ReplaceFor(e.DataCol.Name, e.newvalue, Filter)
End Select
[此贴子已经被作者于2024/4/9 14:36:31编辑过]