简体   繁体   中英

Allow the user to add only one event per cell over FullCalendar resource view

I am using FullCalendar Is there any way that ban the user to enter another event to the same day if s/he already added an event to that day before ?

[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.
}

Some mistakes,its not working correctly.i don't know how to show an alert message in c# code behind.

You need to perform Select operation on returned datatable to check whether your eventid already exist or not.

Something like that:

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.
 }

You cannot show alert message from web service. However you could perform action based on the response received from web service.

You could track web method response using jquery, here is helpful link .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM