以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  根据日期增加行  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=143130)

--  作者:良才
--  发布时间:2019/11/14 12:22:00
--  根据日期增加行

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编辑过]

--  作者:有点蓝
--  发布时间:2019/11/14 13:55:00
--  
Dim lst3 As New List(of Date)
Do While d <= d1
    If (d.DayOfWeek = 0 OrElse d.DayOfWeek = 6 OrElse lst1.Contains(d)) And lst2.Contains(d) = False
    Else
lst3.add(d)
    End If
    d = d.AddDays(1)
Loop
For each d2 as date in lst3
    Dim dr = DataTables("托管日况").AddNew
    dr("学生编号") = e.Form.Controls("学生编号").text
    dr("托管班级") = e.Form.Controls("托管班级").text
    dr("托管日期")  = d2
    dr("录入日期") = Format(Date.Now,"yyyy-MM-dd")
    dr("录入人") = _UserJgbh
Next
[此贴子已经被作者于2019/11/14 13:55:09编辑过]