<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="scheduler" TagName="AdvancedEditForm" Src="AdvancedEditForm.ascx" %>
<%@ Register TagPrefix="scheduler" TagName="AdvancedInsertForm" Src="AdvancedInsertForm.ascx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
		<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="false">
			<AjaxSettings>
				<telerik:AjaxSetting AjaxControlID="RadScheduler1">
					<UpdatedControls>
						<telerik:AjaxUpdatedControl ControlID="RadScheduler1" />
					</UpdatedControls>
				</telerik:AjaxSetting>
			</AjaxSettings>
		</telerik:RadAjaxManager>
		<telerik:RadScheduler runat="server" ID="RadScheduler1" Width="750px" Skin="Default"
			EnableEmbeddedSkins="True" SelectedDate="2007-03-30" DayStartTime="08:00:00"
			DayEndTime="18:00:00" TimeZoneOffset="03:00:00" CustomAttributeNames="Description"
			DataSourceID="AppointmentsDataSource" DataKeyField="ID" DataSubjectField="Subject"
            DataStartField="Start" DataEndField="End" DataRecurrenceField="RecurrenceRule"
            DataRecurrenceParentKeyField="RecurrenceParentID"
			OnAppointmentDataBound="RadScheduler1_AppointmentDataBound">
            <ResourceTypes>
                <telerik:ResourceType KeyField="ID" Name="Room" TextField="RoomName" ForeignKeyField="RoomID"
                    DataSourceID="RoomsDataSource" />
                <telerik:ResourceType KeyField="ID" Name="User" TextField="UserName" ForeignKeyField="UserID"
                    DataSourceID="UsersDataSource" />                            
            </ResourceTypes>
			<AppointmentTemplate>
				<div style="text-align: center;"><%# Eval("Subject") %></div>
				<hr style="width: 90%;" />
				<%# Eval("Description") %>
			</AppointmentTemplate>
			<AdvancedEditTemplate>
				<scheduler:AdvancedEditForm	runat="server" ID="AdvancedEditForm1"
										Subject='<%# Bind("Subject") %>'
										Start='<%# Bind("Start") %>'
										End='<%# Bind("End") %>'
										RecurrenceRuleText='<%# Bind("RecurrenceRule") %>'
										Description='<%# Bind("Description") %>'
										UserID='<%# Bind("User") %>'
										RoomID='<%# Bind("Room") %>' />
										
			</AdvancedEditTemplate>
			<AdvancedInsertTemplate>
				<scheduler:AdvancedInsertForm	runat="server" ID="AdvancedInsertForm1"
										Subject='<%# Bind("Subject") %>'
										Start='<%# Bind("Start") %>'
										End='<%# Bind("End") %>'
										RecurrenceRuleText='<%# Bind("RecurrenceRule") %>'
										Description='<%# Bind("Description") %>'
										UserID='<%# Bind("User") %>'
										RoomID='<%# Bind("Room") %>' />
			</AdvancedInsertTemplate>
			<TimelineView UserSelectable="false" />
		</telerik:RadScheduler>
 
        <asp:SqlDataSource ID="AppointmentsDataSource" runat="server"
            ProviderName="System.Data.SqlClient"
            ConnectionString="<%$ ConnectionStrings:SchedulerConnectionString %>"
            SelectCommand="SELECT * FROM [Appointments]"
            InsertCommand="INSERT INTO [Appointments] ([Subject], [Start], [End], [RoomID], [UserID], [Description], [RecurrenceRule], [RecurrenceParentID]) VALUES (@Subject, @Start, @End , @RoomID, @UserID, @Description, @RecurrenceRule, @RecurrenceParentID)"
            UpdateCommand="UPDATE [Appointments] SET [Subject] = @Subject, [Start] = @Start, [End] = @End, [RoomID] = @RoomID, [UserID] = @UserID, [Description] = @Description, [RecurrenceRule] = @RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID WHERE (ID = @ID)"
            DeleteCommand="DELETE FROM [Appointments] WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="ID" Type="Int32" />
                <asp:Parameter Name="Subject" Type="String" />
                <asp:Parameter Name="Start" Type="DateTime" />
                <asp:Parameter Name="End" Type="DateTime" />
                <asp:Parameter Name="RoomID" Type="Int32" />
                <asp:Parameter Name="UserID" Type="Int32" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="RecurrenceRule" Type="String" />
                <asp:Parameter Name="RecurrenceParentID" 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="RoomID" Type="Int32" />
                <asp:Parameter Name="UserID" Type="Int32" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="RecurrenceRule" Type="String" />
                <asp:Parameter Name="RecurrenceParentID" Type="Int32" />
            </InsertParameters>
        </asp:SqlDataSource>                    

        <asp:SqlDataSource ID="RoomsDataSource" runat="server"
            ProviderName="System.Data.SqlClient"
            ConnectionString="<%$ ConnectionStrings:SchedulerConnectionString %>"
            SelectCommand="SELECT * FROM [Rooms]"></asp:SqlDataSource>

        <asp:SqlDataSource ID="UsersDataSource" runat="server"
            ProviderName="System.Data.SqlClient"
            ConnectionString="<%$ ConnectionStrings:SchedulerConnectionString %>"
            SelectCommand="SELECT * FROM [Users]"></asp:SqlDataSource>
    </form>
</body>
</html>
