0

我有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”是表格,我在其中保存结束/开始日期时间的值。

4

0 回答 0