如果用户在上午 7:00-12:00NN 在该房间添加事件,则代码如下。所以当时应该不可用,但我的代码只读取开始时间和结束时间,有什么建议吗?
public bool checkSched(string start, string endtime, string room, string day)
{
myCon.Open();
SqlDataReader dr;
bool found = false;
SqlCommand cmd = new SqlCommand("SELECT * FROM Subject WHERE (Starting_Time=@start OR Ending_Time = @endtime) AND (Room = @room) AND (Day=@day)", myCon);
cmd.Parameters.Add("@start", SqlDbType.NVarChar).Value = start;
cmd.Parameters.Add("@room", SqlDbType.NVarChar).Value = room;
cmd.Parameters.Add("@day", SqlDbType.NVarChar).Value = day;
cmd.Parameters.Add("@endtime", SqlDbType.NVarChar).Value = endtime;
dr = cmd.ExecuteReader();
found = dr.HasRows;
myCon.Close();
return found;
}