Select Case e.DataCol.Name
Case "计划开始日期","计划完成日期"
Dim filter As String = "设备名称='" & e.DataRow("设备名称") & "'"
DataTables("试验室设备运行情况").DeleteFor(filter)
Dim dr2 As DataRow
For Each dr As DataRow In e.DataTable.Select(filter)
If dr.IsNull("计划开始日期")= False AndAlso dr.IsNull("计划完成日期") = False
Dim d As Date = dr("计划开始日期")
Dim m As Integer = d.month
dr2 = DataTables("试验室设备运行情况").Find(filter & " and 月份='" & m & "' and 年份=" & d.Year)
If dr2 Is Nothing Then
dr2 = DataTables("试验室设备运行情况").AddNew()
dr2("设备名称") = e.DataRow("设备名称")
dr2("年份") = d.year
dr2("月份") = m
End If
Dim d1 As Date = dr("计划完成日期")
Do While d <= d1
If d.Month <> m Then
m = d.Month
dr2 = DataTables("试验室设备运行情况").Find(filter & " and 月份='" & m & "' and 年份=" & d.Year)
If dr2 Is Nothing Then
dr2 = DataTables("试验室设备运行情况").AddNew()
dr2("设备名称") = e.DataRow("设备名称")
dr2("年份") = d.year
dr2("月份") = m
End If
End If
dr2("设备运行情况_" & d.Day) = "P"
d = d.AddDays(1)
Loop
Else
Dim d As Date
If dr.IsNull("计划开始日期")
d = dr("计划完成日期")
Else
d = dr("计划开始日期")
End If
If d <> Nothing
Dim m As Integer = d.month
dr2 = DataTables("试验室设备运行情况").Find(filter & " and 月份='" & m & "' and 年份=" & d.Year)
If dr2 Is Nothing Then
dr2 = DataTables("试验室设备运行情况").AddNew()
dr2("设备名称") = e.DataRow("设备名称")
dr2("年份") = d.year
dr2("月份") = m
End If
dr2("设备运行情况_" & d.Day) = "P"
End If
End If
Next
End Select