Select Case e.DataCol.Name
Case "启动时间","完成时间"
Dim dr10 As DataRow = e.DataRow
If dr10.IsNull("启动时间") OrElse dr10.IsNull("完成时间") Then
dr10("周期天数")= Nothing
dr10("实际天数")= Nothing
dr10("实际小时数")= Nothing
dr10("其中星期天天数")= Nothing
Else
Dim t11 As String = "08:00"
Dim t12 As String = "12:00"
Dim t21 As String = "13:30"
Dim t22 As String = "15:30"
Dim t31 As String = "16:30"
Dim t32 As String = "21:30"
Dim h As Double = 0
Dim d3 As Date = dr10("启动时间")
Dim d4 As Date = dr10("完成时间")
Dim d1 As Date = d3.Date
Dim d2 As Date = d4.Date
Dim cnt As Integer
Do While d1 < d2
h += 11
d1 = d1.AddDays(1)
If d1.DayOfWeek = 0 Then cnt +=1
Loop
Output.Show(h)
d1 = d3.Date
d2 = d4.Date
If d3 > d1 Then
Dim t1 As String = Format(d3,"HH:mm")
If t1 >= t11 Then
If t1 >= t11 AndAlso t1 <= t12 Then
Dim tp As TimeSpan = d3 - d1.AddHours(8)
h -= tp.TotalHours
ElseIf t1 >= t21 AndAlso t1 <= t22 Then
Dim tp As TimeSpan = d3 - d1.AddHours(13).AddMinutes(30)
h -= (tp.TotalHours + 4)
ElseIf t1 >= t31 AndAlso t1 <= t32 Then
Dim tp As TimeSpan = d3 - d1.AddHours(16).AddMinutes(30)
h -= (tp.TotalHours + 6)
ElseIf t1 > t12 AndAlso t1 < t21 Then
h -= 4
ElseIf t1 > t22 AndAlso t1 < t31 Then
h -= 6
Else
h-= 11
End If
End If
End If
Output.Show(h)
If d4 > d2 Then
Dim t1 As String = Format(d4,"HH:mm")
Output.Show(t1)
If t1 >= t11 Then
If t1 >= t11 AndAlso t1 <= t12 Then
Dim tp As TimeSpan = d4 - d2.AddHours(8)
h += tp.TotalHours
ElseIf t1 >= t21 AndAlso t1 <= t22 Then
Dim tp As TimeSpan = d4 - d2.AddHours(13).AddMinutes(30)
h += (tp.TotalHours + 4)
ElseIf t1 >= t31 AndAlso t1 <= t32 Then
Dim tp As TimeSpan = d4 - d2.AddHours(16).AddMinutes(30)
h += (tp.TotalHours + 6)
ElseIf t1 > t12 AndAlso t1 < t21 Then
h += 4
ElseIf t1 > t22 AndAlso t1 < t31 Then
h += 6
Else
h += 11
End If
End If
End If
Output.Show(h)
dr10("实际小时数") = Round2(h,1)
dr10("实际天数") = Round2(h/11,1)
dr10("周期天数") = Round2((d4-d3).TotalDays,1)
dr10("其中星期天天数")= cnt
End If
End Select