Dim RQ As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker3")
Dim SSJ As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker1")
Dim XSJ As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker2")
Dim pg As WinForm.TabControl = e.Form.Controls("页签")
Dim n As String = pg.SelectedPage.Name
Dim t As String = "生产计划_" & n
For i As Integer = 0 To Tables(t).Rows.Count-1
If XSJ.Value IsNot Nothing Then
If I=0 Then
Tables(t).Rows(i)("计划生产时间") = RQ.Value & " " & Format(SSJ.Value,"hh:mm:ss")
Tables(t).Rows(i)("计划完成时间") = Tables(t).Rows(i)("计划生产时间").AddSeconds(Tables(t).Rows(i)("额定生产时间"))
Else
Dim TP1 As Date = Tables(t).Rows(i-1)("计划完成时间").AddSeconds(Tables(t).Rows(i)("额定生产时间"))
If Format(TP1,"hh:mm:ss") < Format(XSJ.Value,"hh:mm:ss") Then
Tables(t).Rows(i)("计划生产时间") = Tables(t).Rows(i-1)("计划完成时间")
Tables(t).Rows(i)("计划完成时间") = Tables(t).Rows(i)("计划生产时间").AddSeconds(Tables(t).Rows(i)("额定生产时间"))
Else
Dim dd As Date = Tables(t).Rows(I-1)("计划生产时间").adddays(1)
Tables(t).Rows(i)("计划生产时间") = FORMAT(dd,"yyyy-MM-dd") & " " & Format(SSJ.Value,"hh:mm:ss")
Tables(t).Rows(i)("计划完成时间") = Tables(t).Rows(i)("计划生产时间").AddSeconds(Tables(t).Rows(i)("额定生产时间"))
End If
End If
Else
If I=0 Then
Tables(t).Rows(i)("计划生产时间") = RQ.Value & " " & Format(SSJ.Value,"hh:mm:ss")
Tables(t).Rows(i)("计划完成时间") = Tables(t).Rows(i)("计划生产时间").AddSeconds(Tables(t).Rows(i)("额定生产时间"))
Else
Tables(t).Rows(i)("计划生产时间") = Tables(t).Rows(i-1)("计划完成时间")
Tables(t).Rows(i)("计划完成时间") = Tables(t).Rows(i)("计划生产时间").AddSeconds(Tables(t).Rows(i)("额定生产时间"))
End If
End If
Next
Tables(T).Save()
老师,我段代码是计算生产时间,也就是一个排产的时间计算,其中有个问题是,如果我有个单跨过几天生产那这段代码就有问题,这要怎么处理呢?