Dim d,d1 As Date
d = e.Form.Controls("开始日期").Value
d1 = e.Form.Controls("结束日期").Value
Dim lst1,lst2 As New List(of Date)
For Each dr As DataRow In DataTables("法定假期").Select("日期 >= #" & d & "# and 日期 <= #" & d1 & "# and 名称 Not Like '%补班'")
lst1.Add(dr("日期"))
Next
For Each dr As DataRow In DataTables("法定假期").Select("日期 >= #" & d & "# and 日期 <= #" & d1 & "# and 名称 Like '%补班'")
lst2.Add(dr("日期"))
Next
Dim TotalDays As Integer
Do While d <= d1
If (d.DayOfWeek = 0 OrElse d.DayOfWeek = 6 OrElse lst1.Contains(d)) And lst2.Contains(d) = False
Else
TotalDays += 1
End If
d = d.AddDays(1)
Loop
For i As Integer = 0 To TotalDays
Dim dr = DataTables("托管日况").AddNew
dr("学生编号") = e.Form.Controls("学生编号").text
dr("托管班级") = e.Form.Controls("托管班级").text
dr("托管日期") = d.AddDays(i)
dr("录入日期") = Format(Date.Now,"yyyy-MM-dd")
dr("录入人") = _UserJgbh
Next
按日期增加行,除去周六、周日、假期,加上调休。请老师指教,谢谢!
[此贴子已经被作者于2019/11/14 12:49:40编辑过]