dataColChanged事件
If e.DataCol.Name = "要求完成时间" AndAlso e.DataRow.Isnull("要求完成时间") = False Then
If e.DataRow.IsNull("办单号") OrElse e.DataRow.IsNull("办房部位") Then
msgbox("请先输入数据")
Else
If e.DataRow("工艺序号") <> 1 Then
Dim fdrFirst As DataRow = e.DataTable.Find("办单号 = '" & e.DataRow("办单号") & "' and 办房部位 = '" & e.DataRow("办房部位") & "'", "工艺序号")
If fdrFirst IsNot Nothing Then
If fdrFirst.isnull("要求完成时间") Then
e.DataRow("要求完成时间") = Nothing
msgbox("请先输入第一道工序时间")
Else
Dim fdr As DataRow = e.DataTable.Find("办单号 = '" & e.DataRow("办单号") & "' and 办房部位 = '" & e.DataRow("办房部位") & "' and 要求完成时间 is not null and 工艺序号 < " & e.DataRow("工艺序号"), "工艺序号 desc")
If fdr IsNot Nothing Then
Dim num1 As Integer = fdr("工艺序号")
Dim num2 As Integer = e.DataRow("工艺序号")
If num2-num1 > 1 Then
Dim stime As Date = fdr("要求完成时间")
Dim etime As Date = e.DataRow("要求完成时间")
Dim seconds As Double = 0
If Format(etime, "yyyyMMdd") = Format(stime, "yyyyMMdd") Then
seconds = (etime-stime).TotalSeconds
Else
seconds = (new Date(stime.Year, stime.Month, stime.Day, 22, 0, 0) - stime).TotalSeconds
seconds += 14 * 3600 * (etime.Day - stime.Day - 1)
seconds += (etime-new Date(etime.Year, etime.Month, etime.Day, 8, 0, 0)).TotalSeconds
End If
Dim second As Double = seconds / (num2-num1)
Dim temp As Date = stime
systemready = False
For i As Integer = num1+1 To num2-1
fdr = e.DataTable.Find("办单号 = '" & e.DataRow("办单号") & "' and 办房部位 = '" & e.DataRow("办房部位") & "' and 工艺序号 = " & i)
Dim t As Date = temp.AddSeconds(second)
If Format(temp, "yyyyMMdd") <> Format(t, "yyyyMMdd") OrElse t.Hour >= 22 Then
temp = t.AddHours(10 * math.Ceiling((t-temp).Totaldays))
Else
temp = t
End If
fdr("要求完成时间") = temp
Next
systemready = True
End If
End If
End If
End If
End If
End If
End If