If e.DataCol.name = "第1序_配膳日" OrElse e.DataCol.name.EndsWith("_工程名")
If e.DataRow.IsNull("部组名") = True AndAlso e.DataRow.IsNull("部品ID") = True
Dim d As Date = e.DataRow("第1序_配膳日")
If d <> Nothing Then
Dim idx As Integer = 0
For i As Integer = 12 To 1 Step -1
If e.DataRow.Isnull("第" & i & "序_工程名") = False Then
idx += 1
Dim lg As String = "第" & i & "序_"
Dim jsrq, ksrq As Date
If idx = 1 Then
jsrq = d.AddDays(-2)
If jsrq.DayOfWeek = 5 OrElse jsrq.DayOfWeek = 6 OrElse jsrq.DayOfWeek = 0 Then
jsrq = jsrq.AddDays(-1)
End If
Else
jsrq = d.AddDays(-1)
If jsrq.DayOfWeek = 6 OrElse jsrq.DayOfWeek = 0 Then
jsrq = jsrq.AddDays(-1)
End If
End If
If e.DataTable.DataCols.Contains(lg & "结束日") Then
e.DataRow(lg & "结束日") = jsrq
End If
ksrq = jsrq.AddDays(-e.DataRow(lg & "标准耗时天"))
Dim scount As Integer = 0
For j As Integer = 1 To e.DataRow(lg & "标准耗时天")
Dim tempd As Date = jsrq.AddDays(-j)
If tempd.DayOfWeek = 0 Then
scount += 1
End If
Next
ksrq = ksrq.AddDays(-scount)
If e.DataTable.DataCols.Contains(lg & "结束日") Then
e.DataRow(lg & "开始日") = ksrq
End If
If ksrq.DayOfWeek = 0 OrElse ksrq.DayOfWeek = 1 OrElse ksrq.DayOfWeek = 2 Then
ksrq = ksrq.AddDays(-1)
End If
If e.DataTable.DataCols.Contains(lg & "配膳日") Then
e.DataRow(lg & "配膳日") = ksrq.AddDays(-2)
End If
d = ksrq.AddDays(-2)
End If
Next
End If
End If
End If