我有4个字段:
• calStartDate = Control for the start Date Calendar (drop downs for Day, Month and Year)
• ddlTime = Start time drop down
• calEndDate = Control for the End Date Calendar (drop downs for Day, Month and Year)
• ddlTime2 = End time drop down
现在我已设法将以下值保存在DB中;
• STARTDATETIME = “2/24/2012 6:30:00 AM”
• ENDDATETIME = “2/24/2013 6:30:00 AM”
如下面的代码;
Dim EndDateTime As DateTime
Dim StartDateTime As DateTime
If chkbxAccAppBasedOnTimeInterval.Checked = True Then
Dim StartDate As System.DateTime? = calStartDate.CurrentDate
If StartDate.HasValue Then
StartDateTime = StartDate.Value.AddMinutes(CType(ddlTime.SelectedValue, Double))
EditRelTbl.STARTDATETIME = StartDateTime
End If
Dim EndDate As System.DateTime? = calEndDate.CurrentDate
If EndDate.HasValue Then
EndDateTime = EndDate.Value.AddMinutes(CType(ddlTime2.SelectedValue, Double))
EditRelTbl.ENDDATETIME = EndDateTime
End If
If EndDateTime > StartDateTime Then
DisplayAlert("End date time, must be less than Start Date and time", "Warning")
EndDateTime = StartDateTime
End If
Else
EditRelTbl.STARTDATETIME = Nothing
EditRelTbl.ENDDATETIME = Nothing
End If
问题是我必须检查STARTDATETIME是否必须大于ENDDATETIME,如果End dateTime大于Start DateTime,那么填写End datetime作为Start DateTime ,因为我试图在代码
If EndDateTime > StartDateTime Then
DisplayAlert("End time must be greater than Start time", "Warning")
EndDateTime = StartDateTime
End If
但这不是检查我想要的支票。任何人都可以指导我如何进行检查,或者我错了。
注意:'EditRelTbl'是表,我将保存结束/开始日期时间的值。