datacolchanging事件,细节自己调整
Select Case e.DataCol.name
Case "任务2_结束日期"
Dim d1 As Date = e.DataRow("结束日期")
Dim d2 As Date = e.NewValue
If e.NewValue <> Nothing
If d2 < d1 Then
msgbox("日期不能小于结束日期")
e.cancel = True
Else
Dim fdr As DataRow = DataTables("法定假期").find("开始日期 <= #" & e.NewValue & "#", "开始日期 desc")
If fdr IsNot Nothing Then
If fdr("开始日期") <= e.NewValue AndAlso cdate(fdr("开始日期")).AddDays(fdr("天数")) >= e.newvalue AndAlso fdr("名称") <> "上班" Then
msgbox(fdr("名称"))
e.cancel = True
Return
End If
End If
Dim wday = e.NewValue.dayofweek
If wday = 6 OrElse wday = 0 Then
If fdr Is Nothing Then
msgbox("周末")
e.cancel = True
Else
If fdr("开始日期") <= e.NewValue AndAlso cdate(fdr("开始日期")).AddDays(fdr("天数")) >= e.newvalue AndAlso fdr("名称") <> "上班" Then
msgbox("周末")
e.cancel = True
End If
End If
End If
End If
End If
End Select