我有以下代码:如何检查是否已经过了30分钟?
if (v != null && DateTime.Now > v.Besetzt_Von)
{
Debug.WriteLine("Hallo, das ist die Ausgabe! : " + v.Thema + v.Besetzt_Von + v.Besetzt_Bis);
string clientId = GetClientId(req);
DateTime TimeCheck = v.Besetzt_Von;
if (TimeCheck.AddMinutes(30) > v.Besetzt_Von)
{
String hql = "UPDATE Buchung as b " +
"set STORNO = :Storno " +
"where ID IN (SELECT rr.Buchung FROM Raumreservierung rr " +
"where BESETZT_VON = :Von and Raum IN (SELECT r.ID FROM Raum r " +
"join r.Panel pl where pl.ID = :PanelId))";
IQuery query = CurrentSession.CreateQuery(hql);
query.SetParameter("Storno", DateTime.Now);
query.SetParameter("Von", v.Besetzt_Von);
query.SetParameter("PanelId", clientId);
int result = query.ExecuteUpdate();
Debug.WriteLine("Rows affected: " + result);
}
}
我想,如果例如Besetzt_Von = 14:00点钟,仅查询被如果有30分钟之后(14:30)执行。我用if语句做了这个,但它不起作用。查询总是执行。什么iam做错了?
你不觉得这个'TimeCheck.AddMinutes(30)> v.Besetzt_Von'永远是真的吗? – V4Vendetta
现在我想是这样^^ .. – Paks