我有一个使用datetime数据类型的数据表中的变量。此数据类型是"scheduledTime"列。我正在尝试将 datatime 变量与系统时钟进行比较,这将在我的桌子上返回不同的背景颜色。我的代码没有得到任何结果,我需要一些指导......我也不确定如何"scheduledTime"在我的情况下定义 datetime 变量
这是条件:
如果晚了,则背景颜色scheduledTime为0-15mins红色..
如果晚了scheduledTime,15min-30mins那么背景颜色黄色..
如果晚了,则背景颜色scheduledTime为30mins-2hours绿色..
//Row Rendering event
public void Row_Rendering()
{
DateTime currentTime = DateTime.New();
DateTime scheduledTime = "SCHD DTM" //<--- this is the name of the column from the table
int i = DateTime.Compare(scheduleTime,currentTime);
if (i <= 0.25)
{
Style.SelectionBackColor = Color.Red;
ForeColor = Color.White;
}
else if (i > 0.25 && i <=0.5)
{
Style.SelectionBackColor = Color.Yellow;
ForeColor = Color.Black;
}
else if (i > 0.5 && i <=2)
{
Style.SelectionBackColor = Color.Green;
ForeColor = Color.White;
}
}