<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
<asp:Panel runat="server" ID="Panel1"><div class="bigModule">
        <div class="bigModuleBottom">
            <div class="title">
				Available employees: <asp:Label runat="server" ID="AvailableUsers" />
			<br/>		
				Available conference rooms: <asp:Label runat="server" ID="AvailableRooms" />
			</div>
            This example demonstrates resource filtering based on availability in <strong>RadScheduler</strong>.
<br/>
	Double-click on a time slot to add an appointment. Through the advanced edit form assign a resource, such as
	Charlie, to the appointment. Notice how the resource is not available in other appointments until it is freed
	by either removing the appointment or assigning a different resource.
            </div></div>
   <telerik:RadScheduler runat="server" ID="RadScheduler1"
				Width="750px"
				SelectedDate="2007-03-30"                  
				DataSourceID="SqlDataSource1" DataKeyField="ID" DataSubjectField="Subject"
				DataStartField="Start" DataEndField="End" TimeZoneOffset="03:00:00"
				OnAppointmentDataBound="RadScheduler1_AppointmentDataBound"
				OnAppointmentInsert="RadScheduler1_AppointmentInsert"
				OnAppointmentUpdate="RadScheduler1_AppointmentUpdate"
				OnAppointmentDelete="RadScheduler1_AppointmentDelete"
				OnDataBound="RadScheduler1_DataBound"
				OnAppointmentCreated="RadScheduler1_AppointmentCreated" AllowDelete="True" AllowEdit="True" AllowInsert="True" HoursPanelTimeFormat="h:mm tt">
				<ResourceTypes>
					<telerik:ResourceType KeyField="ID" Name="Room" TextField="RoomName" ForeignKeyField="RoomID"
						DataSourceID="SqlDataSource2" />
					<telerik:ResourceType KeyField="ID" Name="User" TextField="UserName" ForeignKeyField="UserID"
						DataSourceID="SqlDataSource3" />                            
				</ResourceTypes>
				<AppointmentTemplate>
					<%# Eval("Subject") %>
					<br />
					<asp:Label runat="server" ID="AssignedTo" />
					<br />
					<asp:Label runat="server" ID="Location" />
				</AppointmentTemplate>
			</telerik:RadScheduler>
			</asp:Panel>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SchedulerDataConnectionString2 %>"
        DeleteCommand="DELETE FROM [Appointments_ResourceAvailability] WHERE [ID] = @ID"
        InsertCommand="INSERT INTO [Appointments_ResourceAvailability] ([Subject], [Start], [End], [UserID], [RoomID]) VALUES (@Subject, @Start, @End, @UserID, @RoomID)"
        SelectCommand="SELECT [ID], [Subject], [Start], [End], [UserID], [RoomID] FROM [Appointments_ResourceAvailability]"
        UpdateCommand="UPDATE [Appointments_ResourceAvailability] SET [Subject] = @Subject, [Start] = @Start, [End] = @End, [UserID] = @UserID, [RoomID] = @RoomID WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Subject" Type="String" />
            <asp:Parameter Name="Start" Type="DateTime" />
            <asp:Parameter Name="End" Type="DateTime" />
            <asp:Parameter Name="UserID" Type="Int32" />
            <asp:Parameter Name="RoomID" Type="Int32" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Subject" Type="String" />
            <asp:Parameter Name="Start" Type="DateTime" />
            <asp:Parameter Name="End" Type="DateTime" />
            <asp:Parameter Name="UserID" Type="Int32" />
            <asp:Parameter Name="RoomID" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:SchedulerDataConnectionString2 %>"
        SelectCommand="SELECT [ID], [RoomName] FROM [Rooms]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:SchedulerDataConnectionString2 %>"
        SelectCommand="SELECT [ID], [UserName] FROM [Users]"></asp:SqlDataSource>
</asp:Content>

