此主题相关图片如下:12.png
老师,您好!
如图所示,在“部组名”和“部品ID"列,
【1.如”部组名“列不为空,”部品ID"为空,则是部组,
部组的意思是父产品】
【2.如”部组名“列不为空,”部品ID"也不为空,则是部组成员,
部组成员的意思是子产品,】
3.父产品是由子产品组成的,
现有的数据中已经将父产品(部组)的”第1序_配膳日“的时间已经算出来了,
子产品(部品ID)的各工序和工序各耗时也已经导入了,
现在要做的是,根据父产品的”第1序_配膳日“倒推子产品的各工序时间,
逻辑请参考
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
有一个问题是,父产品与子产品不是在同一行上,一个是子产品在上,父产品在下(部组名和部品ID均不为空),
需要根据子产品去找到父产品的“第1序_配膳日”
除了红色背景以外的,其他的地方也可能不对,
由于水平有限,请老师帮帮忙,谢谢!