Dim e = Args(0)
Select Case e.DataTable.Name
Case "ddyg"
If e.DataCol.Name = "zbm" Then '如果内容发生变动的是品名列
If e.NewValue Is Nothing Then '如果新值是空白,也就是品名列的内容为空
e.DataRow("mdbh") = Nothing '那么清空此行单价列的内容
Else
Dim dr As DataRow
'否则在产品表查找同名的产品行,将找到的行赋值给变量dr
dr = DataTables("ddbm").Find("[name] = '" & e.NewValue & "'")
If dr IsNot Nothing Then '如果找到了同名的产品行,也就是dr不是Nothing
e.DataRow("mdbh") = dr("jj")
End If
End If
End If
If e.DataCol.Name = "mdbh" Then '如果内容发生变动的是品名列
If e.NewValue Is Nothing Then '如果新值是空白,也就是品名列的内容为空
e.DataRow("id") = Nothing '那么清空此行单价列的内容
Else
Dim dr As DataRow
'否则在产品表查找同名的产品行,将找到的行赋值给变量dr
dr = DataTables("dpdzm").Find("[KHDM] = '" & e.NewValue & "'")
If dr IsNot Nothing Then '如果找到了同名的产品行,也就是dr不是Nothing
e.DataRow("ID") = dr("id")
End If
End If
End If
If e.DataCol.Name = "ygzt" Then '如果内容发生变动的是品名列
If e.DataRow("ygzt") <> "离职" Then '如果新值是空白,也就是品名列的内容为空
e.DataRow("lzrq") = Nothing '那么清空此行单价列的内容
ElseIf e.DataRow("ygzt") = "离职" Then
e.DataRow("lzrq") = Date.Today
End If
End If
Case "表B"
'针对表B的代码
Case "表C"
'针对表C的代码
End Select