我正在使用FullCalendar如果他/她之前已经添加了一个事件,有没有办法禁止用户在同一天输入另一个事件?
[System.Web.Services.WebMethod(true)]
public static void AllowEvents(DateTime start, DateTime end, int Resource_id)
{
//using the startdate enddate and resourceid to pick the events already in that cell
DataTable dt = new DataTable();
dt = EventDAO2.AllowEvents(start, end, user_id);
//get the eventid in dt.
if (dt.Rows.Count > 0)
{
//show a message"An event already exists in this cell"
}
//otherwise allow a popup window for entering event details,and add that values to the server.
}
有些错误,它无法正常工作。我不知道如何在c#代码后面显示警告信息。
答案 0 :(得分:0)
您需要对返回的数据表执行Select
操作,以检查您的eventid
是否已存在。
类似的东西:
DataTable dt = new DataTable();
dt = EventDAO2.AllowEvents(start, end, user_id);
//get the eventid in dt.
if (dt.Rows.Count > 0)
{
DataRow[] drs = dt.Select("eventid=2 And user_id=" + user_id); //example
if(drs.Length > 0)
{
//show a message"An event already exists in this cell"
}
else
{
//otherwise allow a popup window for entering event details,and add that values to the server.
}
}
else
{
//otherwise allow a popup window for entering event details,and add that values to the server.
}
您无法显示来自网络服务的提醒消息。但是,您可以根据从Web服务收到的响应执行操作。
您可以使用jquery here is helpful link跟踪Web方法响应。