function isRoomOccupied(scheduler, start, end, slot, appointment)
{
//get the "Room" resource associated with the time slot
var currentRoom = slot.get_resource();
//get all appointments for this "room" in the specified period
var appointmentsForThisRoom = getAppointmentsInRangeByResource(scheduler, start, end, currentRoom, appointment);
//if the list of appointments is not empty there are other appointments in this slot
return appointmentsForThisRoom.get_count() > 0;
}
I am not sure what I am doing wrong. Thanks.
function isRoomOccupied(scheduler, start, end, slot, appointment)
{
//get the "Room" resource associated with the time slot
var currentRoom = slot.get_resource();
//get all appointments for this "room" in the specified period
var appointmentsForThisRoom = getAppointmentsInRangeByResource(scheduler, start, end, currentRoom, appointment);
//if the list of appointments is not empty there are other appointments in this slot
return appointmentsForThisRoom.get_count() > 0;
}
function warnIfOccupied(start, end, sender, args)
{
var slot = args.get_targetSlot();
var appointment = args.get_appointment();
if (isRoomOccupied(sender, start, end, slot, appointment))
{
alert(
"This room is not available in this time period.");
args.set_cancel(
true);
}
appointment.get_element().style.border =
"";
}
function onAppointmentResizeEnd(sender, args)
{
var start = args.get_appointment().get_start();
var end = args.get_targetSlot().get_endTime();
warnIfOccupied(start, end, sender, args);
}
function onAppointmentMoveEnd(sender, args)
{
var start = args.get_targetSlot().get_startTime();
var end = new Date(start.getTime() + args.get_appointment().get_duration());
warnIfOccupied(start, end, sender, args);
}
function onAppointmentInserting(sender, args)
{
var slot = args.get_targetSlot();
var start = slot.get_startTime();
var end = slot.get_endTime();
if (isRoomOccupied(sender, start, end, slot))
{
alert(
"This room is not available in this time period.");
args.set_cancel(
true);
}
}
<
telerik:RadScheduler runat="server" ID="RadScheduler1" OnClientAppointmentEditing="AppointmentEditing"
OnClientAppointmentInserting="AppointmentInserting" EnableCustomAttributeEditing="true"
SelectedDate="2009-07-26" DataSourceID="EventsDataSource" DataKeyField="MeetingID"
DataSubjectField="Description" DataStartField="Start" DataEndField="End" SelectedView="WeekView"
FirstDayOfWeek="Sunday" LastDayOfWeek="Saturday" Skin="Vista" ShowResourceHeaders="false"
CustomAttributeNames="Description,HostedBy,Room" Height="100%" Localization-ConfirmDeleteText="Are you sure you want to delete this meeting?"
TimelineView-UserSelectable="false" OnClientAppointmentMoveEnd="onAppointmentMoveEnd"
OnClientAppointmentResizeEnd="onAppointmentResizeEnd">
<ResourceTypes>
<telerik:ResourceType KeyField="Room" Name="Room" TextField="Room" ForeignKeyField="Room"
DataSourceID="RoomsDataSource" />
</ResourceTypes>
<AppointmentTemplate>
<div style="color: Maroon;">
<%
#Eval("Description")%></div>
<%
-- <br />--%>
<div style="color: Teal;">
</font>Host: <%#Eval("HostedBy")%></div>
<%
-- <br />--%>
<div style="color: Fuchsia;">
Room:
<%#Eval("Room")%></div>
</AppointmentTemplate>
</telerik:RadScheduler>
<asp:Button ID="btnGo" runat="server" Text="Go" Visible="false" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>
<asp:SqlDataSource ID="EventsDataSource" runat="server" ProviderName="System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:MCHPEVENTS %>" SelectCommand="SELECT [MeetingID], [Description], [Start], [End], [Room], [HostedBy], [Food], [Beverages], [Projector], [Easel], [Flipchart], [Microphone], [HotelAVSupplies], [Comments] FROM [Meetings]"
InsertCommand="INSERT INTO [Meetings] ([Description], [Start], [End], [Room]) VALUES (@Description, @Start, @End, @Room)"
UpdateCommand="UPDATE [Meetings] SET [Description] = @Description, [Start] = @Start, [End] = @End, [Room] = @Room WHERE (MeetingID = @MeetingID)"
DeleteCommand="DELETE FROM [Meetings] WHERE [MeetingID] = @MeetingID">
<DeleteParameters>
<asp:Parameter Name="MeetingID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="MeetingID" Type="Int32" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="Start" Type="DateTime" />
<asp:Parameter Name="End" Type="DateTime" />
<asp:Parameter Name="Room" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="Start" Type="DateTime" />
<asp:Parameter Name="End" Type="DateTime" />
<asp:Parameter Name="Room" Type="String" DefaultValue="TBD" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="RoomsDataSource" runat="server" ProviderName="System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:MCHPEVENTS %>" SelectCommand="SELECT DISTINCT([Room]) FROM [Meetings]">
</asp:SqlDataSource>