search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Let users know when they already have an event scheduled for a particular time

Asked by Stepahnie
12 years ago.

Any one have any code or guidance on the best way to show a message to clients when they try to book an appointment the overlaps another appointment? Any ideas welcome!

Answer posted by Dan Letecky [DayPilot]
12 years ago.

There are two possible approaches:

1. Check the new event against the database before saving it. For a simple scenario (i.e. no recurring events) you can use the same logic you use for selecting events to be displayed. LINQ example (http://kb.daypilot.org/56894/how-to-use-daypilot-scheduler-with-linq-to-sql/):

var events = from ev in db.Events where !(ev.eventend <= start || ev.eventstart >= end) select ev;

2. You can also use asynchronous checking - that means you will allow adding the conflicting event but warn the users about it. The biggest advantage of this method is that you can show a complete list of the conflicts (and one new event can create many conflicts if you use recurring events).

This method is demonstrated in the Shift Scheduling Tutorial:

http://code.daypilot.org/34377/shift-scheduling-tutorial-asp-net-sql-server-c-vb-net

You can test it online here:

http://www.daypilot.org/tutorial/shifts/

The upcoming 7.1 release will bring a new ConflictDetector API. It will be possible to use multiple data sets for the detection (including automatic recurring events expansion).

Example:

        GridView1.DataSource = new ConflictDetector()
            .Add(standardEventsDataTable, "start", "end", null)
            .AddRecurring(recurringEventsDataTable, "start", "end", null, "recurrence", "id", "master")
            .ForRange(DateTime.Today, DateTime.Today.AddYears(1))
            .List;

See also:

http://www.daypilot.org/daypilot-pro-for-asp-net-webforms-7-1.html

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.