如果有以下代码:
Public Shared Function GetNextWeekDay() As Date
Dim value As Date = Date.Now
Do
value = value.AddDays(1)
Loop While (value.DayOfWeek = DayOfWeek.Saturday) Or (value.DayOfWeek = DayOfWeek.Sunday)
Return value
End Function
Public Shared Function DPLoadData() As String
Dim s As StringBuilder = New StringBuilder("<head><meta http-equiv=""content-type"" content=""text/html;charset=utf-8"" /><META HTTP-EQUIV=""REFRESH"" CONTENT=""900"">")
s.Append("<style type=""text/css"" media=""all""> body{font-family: Arial;}h4{font-size: 10pt;font-weight: bold;white-space: nowrap;margin-top: 0; margin-bottom: 10px;}")
s.Append("th{font-size: 9pt;font-weight: normal;text-align: center;white-space: nowrap;}td{font-size: 9pt;}.content td{border: solid 1px #dadada;}")
s.Append(".content th {border: solid 1px #dadada;background-image: url(""tbl_header_row_bg.gif""); background-repeat: repeat-x; white-space: nowrap;}</style></head>")
s.Append("<h3>" & "Daily Plan" & "</h3>")
Dim strCurrDay As String = ""
s.Append("<h5>" & strCurrDay & "</h5>")
Dim CurrDateFirstDay As Date = GetNextWeekDay()
strCurrDay = FormatDateTime(CurrDateFirstDay, DateFormat.LongDate)
s.Append("<h5>" & strCurrDay & "</h5>")
s.Append(LoadDataGroupByDate(CurrDateFirstDay))
Return s.ToString()
End Function
函数 DPLoadData 生成一个带有表格的 HTML 文件,并用预订填充它。目前,HTML 文件显示明天的预订(例如,如果今天是星期一,则显示星期二的预订,如果今天是星期五,则显示星期一的预订)。
我需要的是 HMTL 文件在下午 5 点生成例如:如果今天是星期一,那么 HTML 文件应该在星期一下午 5 点生成,并且应该显示星期二到星期二下午 5 点和星期二下午 5 点的预订文件应该在星期三生成,并且应该显示星期三的预订直到星期三下午 5 点,依此类推。
我怎样才能做到这一点?请帮忙。
我的解决方案:
Public Shared Function GetNextWeekDay() As Date
Dim value As Date = Date.Now
Dim intHour As Integer
Dim intMinute As Integer
Dim intSecond As Integer
intHour = 17
intMinute = 0
intSecond = 0
Dim newdatetime As DateTime = New Date(value.Year, value.Month, value.Day, intHour, intMinute, intSecond)
If DateTime.Now < newdatetime Then
If value.DayOfWeek = DayOfWeek.Saturday Then
value = value.AddDays(2)
Return value
End If
If value.DayOfWeek = DayOfWeek.Sunday Then
value = value.AddDays(1)
Return value
End If
Return value
ElseIf DateTime.Now > newdatetime Then
Do
value = value.AddDays(1)
Loop While (value.DayOfWeek = DayOfWeek.Saturday) Or (value.DayOfWeek = DayOfWeek.Sunday)
Return value
End If
End Function