Select Case e.DataCol.name Case "生产开始时间","生产结束时间" Dim dr3 As DataRow = e.DataRow If dr3.IsNull("生产开始时间") Or dr3.IsNull("生产结束时间") Then dr3("开动时间") = Nothing Else Dim d1 As Date = dr3("生产结束时间") Dim d2 As Date = dr3("生产开始时间") Dim tp1, tp2 As TimeSpan If d1 < d2 Then d1 = d1.AddDays(1) End If Dim time As Double tp1 = d1 - d2 time = tp1.TotalSeconds For Each dr As DataRow In DataTables("休息表").Select("") Dim d3 As Date = dr("开始时间") Dim d4 As Date = dr("结束时间") Dim d1s, d1e As Date If d4 > d2 Then d1s = new Date(d2.Year, d2.Month, d2.day, d3.Hour, d3.Minute, 0) d1e = new Date(d2.Year, d2.Month, d2.day, d4.Hour, d4.Minute, 0) Else d1s = new Date(d1.Year, d1.Month, d1.day, d3.Hour, d3.Minute, 0) d1e = new Date(d1.Year, d1.Month, d1.day, d4.Hour, d4.Minute, 0) End If If d1 > d1e Then If d2 < d1e AndAlso d2 >= d1s Then tp2 = d1e - d2 time = time - tp2.TotalSeconds Else If d2 < d1s Then tp2 = d1e - d1s time = time - tp2.TotalSeconds End If Else If d1 > d1s Then If d2 < d1s Then tp2 = d1 - d1s time = time - tp2.TotalSeconds Else time = 0 End If End If Next dr3("开动时间") = time/60/60 End If End Select
|