Select Case e.DataCol.Name
Case "编号"
Dim drs As List(of DataRow) = DataTables("成本支出明细").Select("编号 = '" & e.OldValue & "'")
If drs.Count = 0 Then
Dim dr As DataRow
For i As Integer = 1 To 4
dr = DataTables("成本支出明细").AddNew()
dr("编号") = e.DataRow("编号")
dr("项目名称") = e.DataRow("项目名称")
dr("日期") = e.DataRow("日期")
dr("报表类型") = e.DataRow("报表类型")
dr("第几周") = e.DataRow("第几周")
Next
Else
For Each r As DataRow In drs
r("编号") = e.DataRow("编号")
Next
End If
Case "项目名称","日期","报表类型","第几周"
Dim drs As List(of DataRow) = DataTables("成本支出明细").Select("编号 = '" & e.DataRow("编号") & "'")
For Each r As DataRow In drs
r(e.DataCol.Name) = e.DataRow(e.DataCol.Name)
Next
End Select
明细表DataRowAdded
Dim dr As DataRow = DataTables("成本支出").Find("编号 = '" & e.DataRow("编号") & "'")
If dr IsNot Nothing Then
e.DataRow("项目名称") = dr("项目名称")
e.DataRow("日期") = dr("日期")
e.DataRow("报表类型") = dr("报表类型")
e.DataRow("第几周") = dr("第几周")
End If