Error On Delete With Recurrences

15 posts, 0 answers
  1. Steve Olson
    Steve Olson avatar
    6 posts
    Member since:
    Oct 2003

    Posted 11 Dec 2007 Link to this post

    I have a scheduler set up with an object data source.  I don't seem to have any problems binding the scheduler or making inserts or updates.  The problem comes when I try to delete the first occurrence in a series.  I get a bit of a cryptic error (below).  If I delete the whole series or any of the other occurrences beside the first one, it works.

    I also noticed when I look at the list of recurrences, the first item has a little red line between the Yen and Yang refresh icon.  I also notice I do not have a value in the DataRecurrenceParentKeyField that I set - I've tried it both as a varchar and an int.

    <-- Error -->
    Cannot locate the parent of appointment with ID = '1'. Ensure that the parent appointment with ID = '' exists and is loaded.

    <-- Code -->
    <radPro:RadScheduler ID="rsEvents" runat="server"
                DataKeyField="EventModuleId"
                DataStartField="StartDateTime"
                DataEndField="EndDateTime"
                DataSubjectField="Title"
                DataRecurrenceField="RecurrenceRule"
                DataRecurrenceParentKeyField="RecurrenceParentID"
                AllowDelete="True"
                AllowEdit="True"
                AllowInsert="True"
                HoursPanelTimeFormat="h:mm tt"
                ShowAllDayRow="true"
                DataSourceID="odsEvents"
                Height="525"
                StartEditingInAdvancedForm="true" />

    Protected Sub rsEvents_AppointmentInsert(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerCancelEventArgs) Handles rsEvents.AppointmentInsert
            Dim oAdmin As AdminPage = CType(Me.Page, AdminPage)
            Dim oEvent As New EventModule
            With oEvent
                .Title = e.Appointment.Subject
                .StartDateTime = e.Appointment.Start
                .EndDateTime = e.Appointment.End
                .RecurrenceRule = e.Appointment.RecurrenceRule
                .RecurrenceParentID = e.Appointment.RecurrenceParentID
                .Save()
            End With
        End Sub


  2. Steve Olson
    Steve Olson avatar
    6 posts
    Member since:
    Oct 2003

    Posted 12 Dec 2007 Link to this post

    Well, I am a bit of a loss here.  I tried several variations to what I had previously posted but to no avail.  From what I can tell, the recurrence parent key passed back from e.Appointment.RecurrenceParentID is always 0.  So, I tried using the insert and update parameters of the object data source directly, but that returns errors as well.  The updated code/error message is pasted below.

    <radPro:RadScheduler ID="rsEvents" runat="server"
                DataKeyField="EventModuleId"
                DataStartField="StartDateTime"
                DataEndField="EndDateTime"
                DataSubjectField="Subject"
                DataRecurrenceField="RecurrenceRule"
                DataRecurrenceParentKeyField="RecurrenceParentID"
                AllowDelete="True"
                AllowEdit="True"
                AllowInsert="True"
                HoursPanelTimeFormat="h:mm tt"
                ShowAllDayRow="true"
                DataSourceID="odsEvents"
                Height="525"
                SelectedView="WeekView" />
            <asp:ObjectDataSource ID="odsEvents" runat="server"
                TypeName="ProjectCore.EventModule"
                SelectMethod="GetEventModules"
                UpdateMethod="UpdateEventModule"
                InsertMethod="InsertEventModule">
                <SelectParameters>
                    <asp:Parameter DefaultValue="0" Name="PagePartId" Type="Int32" />
                </SelectParameters>
                <InsertParameters>
                    <asp:Parameter Type="String" Name="Subject" />
                    <asp:Parameter Type="DateTime" Name="StartDateTime" />
                    <asp:Parameter Type="DateTime" Name="EndDateTime" />
                    <asp:Parameter Type="String" Name="RecurrenceRule" />
                    <asp:Parameter Type="Int32" Name="RecurrenceParentID" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Type="String" Name="Subject" />
                    <asp:Parameter Type="DateTime" Name="StartDateTime" />
                    <asp:Parameter Type="DateTime" Name="EndDateTime" />
                    <asp:Parameter Type="String" Name="RecurrenceRule" />
                    <asp:Parameter Type="Int32" Name="RecurrenceParentID" />
                </UpdateParameters>
            </asp:ObjectDataSource>

    Public Sub UpdateEventModule(ByVal EventModuleId As Integer, ByVal StartDateTime As DateTime, ByVal EndDateTime As DateTime, ByVal Subject As String, ByVal RecurrenceRule As String, ByVal RecurrenceParentID As String)
                Dim sSQL As String = "Update EventModules Set "
                sSQL &= "StartDateTime = '" & Mindscape.Util.String.EscTrim(StartDateTime) & "',"
                sSQL &= "EndDateTime = '" & Mindscape.Util.String.EscTrim(EndDateTime) & "',"
                sSQL &= "Subject = '" & Mindscape.Util.String.EscTrim(Subject) & "',"
                sSQL &= "RecurrenceRule = '" & Mindscape.Util.String.EscTrim(RecurrenceRule) & "',"
                sSQL &= "RecurrenceParentID = " & RecurrenceParentID & " "
                sSQL &= "Where EventModuleId = " & EventModuleId & ";"
                DataAccess.RunCommand(sSQL)
            End Sub

            Public Sub InsertEventModule(ByVal StartDateTime As DateTime, ByVal EndDateTime As DateTime, ByVal Subject As String, ByVal RecurrenceRule As String, ByVal RecurrenceParentID As String)
                Dim sSQL As String = "Insert Into EventModules ("
                sSQL &= "StartDateTime, "
                sSQL &= "EndDateTime, "
                sSQL &= "Subject, "
                sSQL &= "RecurrenceRule, "
                sSQL &= "RecurrenceParentID) values ("
                sSQL &= "'" & Mindscape.Util.String.EscTrim(StartDateTime) & "',"
                sSQL &= "'" & Mindscape.Util.String.EscTrim(EndDateTime) & "',"
                sSQL &= "'" & Mindscape.Util.String.EscTrim(Subject) & "',"
                sSQL &= "'" & Mindscape.Util.String.EscTrim(RecurrenceRule) & "',"
                sSQL &= "" & RecurrenceParentID & ");"
                DataAccess.RunCommand(sSQL)
            End Sub

    Message

    Exception has been thrown by the target of an invocation.

    Stack Trace:

    Mindscape.MSException: Exception has been thrown by the target of an invocation. at Telerik.Web.UI.Scheduling.DataSourceViewSchedulerProvider.OnDataSourceOperationComplete(Int32 count, Exception e) at System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) at Telerik.Web.UI.Scheduling.DataSourceViewSchedulerProvider.Insert(RadScheduler owner, Appointment appointmentToInsert) at Telerik.Web.UI.RadScheduler.InsertAppointmentInline() at Telerik.Web.UI.RadScheduler.OnBubbleEvent(Object source, EventArgs args) at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


  3. Neil
    Neil avatar
    2 posts
    Member since:
    Oct 2006

    Posted 15 Dec 2007 Link to this post

    Hi Steve,

    Have you found a solution, my subscription has run out and cant place a support ticket and left high and searched and searched. The only indicator is casting the id to type int (int32) which I have not successfully achieved.

    Regards Neil, 
  4. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 17 Dec 2007 Link to this post

    Hello,

    I tried this scenario with a class in which the id is of type string and automatically generated as GUID:

     private string _id;  
     
    *  *  *   
     
     public string ID  
        {  
            get { return _id; }  
            set { _id = value; }  
        }  
     
    *   *   *  
     
     public AppointmentInfo()  
        {  
            this._id = Guid.NewGuid().ToString();  
        }  
     

    This worked fine. Can you try this approach as well?


    Best wishes,
    Peter
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Chris
    Chris avatar
    23 posts
    Member since:
    Nov 2003

    Posted 01 Jun 2009 Link to this post

    This is a pretty old post, so I assume that there has been a resolution to thism but I'm running into the same problem, or very close to the same.  I am getting the error:
        Telerik.Web.UI.Scheduling.DataSourceViewSchedulerProvider.OnDataSourceOperationComplete
    When I try and delete an occurrence in a series.  I can delete the series with no issues, I can also delete indivisial appointment including appointment that are exception to the series.  I've have tried everything that I can think of and have been over the forums to no avail.  I NEED HELP! :)  Please.

    Some background: I have a LINQ to Entities datasource, and am using a EntityDataSource that looks like this:
    1 <asp:EntityDataSource ID="TasksDataSource" runat="server"   
    2     ConnectionString="name=DataEntities" DefaultContainerName="DataEntities" EnableDelete="false"   
    3     EnableInsert="True" EnableUpdate="True" EntitySetName="Task" OnInserting="TaskDataSource_Inserting"   
    4     Where="it.AssignedTo.PersonId == @PersonId"   
    5     onupdated="TasksDataSource_Updated" onupdating="TasksDataSource_Updating" > 
    6 </asp:EntityDataSource> 

    My RadScheduler Looks like this:
    1 <telerik:RadScheduler ID="radScheduler" runat="server" DataEndField="EndDate"   
    2     DataKeyField="TaskId" DataRecurrenceField="RecurrenceRule"   
    3     DataRecurrenceParentKeyField="ParentTask.TaskId" DataStartField="StartDate"   
    4     DataSubjectField="Subject" HoursPanelTimeFormat="htt"   
    5     ValidationGroup="RadScheduler1" TimeZoneOffset="-06:00:00"   
    6     Skin="Office2007" onappointmentdelete="radScheduler_AppointmentDelete"   
    7     DataSourceID="TasksDataSource" onappointmentupdate="radScheduler_AppointmentUpdate" > 
    8 </telerik:RadScheduler> 

    My Code Behine looks like this:
    1 protected void Page_Load(object sender, EventArgs e)  
    2 {  
    3     if (!Page.IsPostBack)  
    4     {  
    5         TasksDataSource.WhereParameters.Add("PersonId", TypeCode.Int32, CurrentUser.PersonId.ToString());  
    6     }  
    7 }  
    8  
    9 protected void TaskDataSource_Inserting(object sender, EntityDataSourceChangingEventArgs e)  
    10 {  
    11     Task task = e.Entity as Task;  
    12     if (task != null)  
    13     {  
    14         Person person = Person.GetPersonById(CurrentUser.PersonId);  
    15         e.Context.Attach(person);  
    16         task.TaskType = 2;  
    17         task.CreatedBy = person;  
    18         task.AssignedTo = person;  
    19         task.DateAdded = DateTime.UtcNow;  
    20     }  
    21 }  
    22  
    23 protected void radScheduler_AppointmentDelete(object sender, Telerik.Web.UI.SchedulerCancelEventArgs e)  
    24 {  
    25     int taskId = Convert.ToInt32(e.Appointment.ID);  
    26     using (DataEntities de = new DataEntities())  
    27     {  
    28         var taskQuery = from delTask in de.Task  
    29                         where delTask.TaskId == taskId  
    30                         select delTask;  
    31  
    32         Task task = taskQuery.FirstOrDefault();  
    33         de.DeleteObject(task);  
    34  
    35         de.SaveChanges();  
    36     }  
    37 }  
    38  
    39 protected void radScheduler_AppointmentUpdate(object sender, Telerik.Web.UI.AppointmentUpdateEventArgs e)  
    40 {  
    41     //Task.UpdateRecurrenceRule((int)e.Appointment.ID, e.ModifiedAppointment.RecurrenceRule);  
    42     //e.Cancel = true;  
    43

    I'm sure I'm missing something but for the life of me I can't see it.  In the radScheduler_AppointmentUpdate event handler I've updated the appointment (Task in my system) manually and that works well for Deleted but then the Updates actually delete the appointment from the calendar because the exception is created in the Master record but the e.cancel = true stops the insert of the child record from happening.  I looked for an Action indicator (Delete vs. Update) but did not find that.

    The previous post from Pete to use a string that is a GUID for the ID is not a solutions I can use here as the Task table is used an a handleful of other application already in use.

    Sorry for the long post.  Please HELP!
    Thank you,
    Chris
  6. T. Tsonev
    Admin
    T. Tsonev avatar
    2815 posts

    Posted 05 Jun 2009 Link to this post

    Hi Chris,

    I think we can come up with a workaround for the problem. We've planned to introduce an event (OccurrenceDelete) that will be raised when a single occurrence is deleted, but no exception is created in its place. So you'll be able to use in your scenario:

    protected void RadScheduler1_OccurrenceDelete(object sender, OccurrenceDeleteEventArgs e)
    {
        RecurrenceRule rrule;
        if (!RecurrenceRule.TryParse(e.Appointment.RecurrenceRule, out rrule))
            return;

        // Manually add the exception
        rrule.Exceptions.Add(e.OccurrenceAppointment.Start);

        Task.UpdateRecurrenceRule((int)e.Appointment.ID, rrule.ToString());
        e.Cancel = true;
    }


    We've decided to implement this event now and it'll be available in the internal build (version 2009.1.605 and up) on Monday. You can also open a support ticket and I'll send you the build right away.

    But I'm really interested of what is causing the initial problem. Is it possible for you to send us a runnable project that we can use to debug it?

    Sincerely yours,
    Tsvetomir Tsonev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. Chris
    Chris avatar
    23 posts
    Member since:
    Nov 2003

    Posted 05 Jun 2009 Link to this post

    Thank you for the response, and I look forward to the new bits to implement your code example below.  As far as me sending a runnable project, my current project is HUGH, the EDMX that I am using is very large.  But as soon as I can carve out some time I'll put together a smaller sample, ensure that I am still getting the same error and send it to you to look over.

     

    Again thank you, Telerik provides excellent support!!!

  8. atul
    atul avatar
    7 posts
    Member since:
    Apr 2011

    Posted 27 Oct 2011 Link to this post

    Hi,

    Im using radsheduler my update and insert is working fine but when im trying to delete appointment im getting an error. For more clearification i am sending an zip file of my prjoject.

    And one more thing i got the developer version as well and if asked i can provide you the details but i dont know how to update my account.

    Any help in regards to my error is really appreciated. And another thing i cant provide my database interface class according to the company policy.

    Kind Regards,
    Atul Chaudhary

    couldn't attach my project so just copying it here
    My code behind code


    Imports System
    Imports System.Collections.Generic
    Imports System.Web.UI
    Imports Telerik.Web.UI
    Imports Telerik.Web.Examples.Scheduler.BindToList
    Imports User
    Partial Class RS_DS2
        Inherits System.Web.UI.Page
        Private Const AppointmentsKey As String = "Telerik.Web.Examples.Scheduler.BindToList.VB.Apts"


        Private ReadOnly Property Appointments() As List(Of AppointmentInfo)
            Get
                Dim sessApts As List(Of AppointmentInfo) = TryCast(Session(AppointmentsKey), List(Of AppointmentInfo))
                If sessApts Is Nothing Then
                    sessApts = New List(Of AppointmentInfo)()
                    Session(AppointmentsKey) = sessApts
                End If


                Return sessApts
            End Get
        End Property


        Protected Sub RS_DS2_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init


            If Not IsPostBack Then
                Session.Remove(AppointmentsKey)
                InitializeResources()
                InitializeAppointments()
            End If


            RadScheduler1.DataSource = Appointments


        End Sub


        Private Sub InitializeResources()


            Dim userList As List(Of User.User) = getUserList()


            Dim resType As New ResourceType("Room")
            resType.ForeignKeyField = "RoomID"


            RadScheduler1.ResourceTypes.Add(resType)
            RadScheduler1.Resources.Add(New Resource("Room", 1, "Room1"))
            RadScheduler1.Resources.Add(New Resource("Room", 2, "Room2"))
            RadScheduler1.Resources.Add(New Resource("Room", 3, "Room3"))


            Dim resType2 As New ResourceType("User")
            resType2.ForeignKeyField = "UserID"




            RadScheduler1.ResourceTypes.Add(resType2)
            RadScheduler1.Resources.Add(New Resource("User", 1, "Atul"))
            RadScheduler1.Resources.Add(New Resource("User", 2, "Ben"))
            RadScheduler1.Resources.Add(New Resource("User", 3, "Paul"))


        End Sub


        Protected Sub RadScheduler1_AppointmentInsert(ByVal sender As Object, ByVal e As SchedulerCancelEventArgs)
           
            Appointments.Add(New AppointmentInfo(e.Appointment))
            If Not InsertAppointment(e.Appointment) Then
                Exit Sub
            Else
                'InitializeAppointments()
                'RadScheduler1.DataSource = Appointments
            End If
        End Sub


       




        Protected Sub RadScheduler1_AppointmentDelete(ByVal sender As Object, ByVal e As AppointmentDeleteEventArgs)
            Appointments.Remove(FindById(e.Appointment.ID))
            'If Not deleteAppointment(e.Appointment.ID) Then
            '    Exit Sub
            'Else
            '    'InitializeAppointments()
            '    'RadScheduler1.DataSource = Appointments
            'End If
        End Sub




        Protected Sub RadScheduler1_AppointmentUpdate(ByVal sender As Object, ByVal e As Telerik.Web.UI.AppointmentUpdateEventArgs) Handles RadScheduler1.AppointmentUpdate


            Dim ai As AppointmentInfo = FindById(e.ModifiedAppointment.ID)
            If ai IsNot Nothing Then
                ai.CopyInfo(e.ModifiedAppointment)


                If Not updateAppointment(e.ModifiedAppointment) Then
                    Exit Sub
                Else
                    'InitializeAppointments()
                    'RadScheduler1.DataSource = Appointments
                End If
            End If
        End Sub




        Private Sub InitializeAppointments()


            Dim dbi As DbInterface = DBInstance.DBInterface
            Dim myQuery As DbInterface.SQLQuery = dbi.NewQuery("spTest")


            If Not myQuery.Execute() Then
                Throw myQuery.LastException
            Else
                While myQuery.dr.Read()
                    Dim ID As Integer = CInt(myQuery.dr("ID"))
                    Dim subject As String = Convert.ToString(myQuery.dr("Subject"))
                    Dim Start2 As DateTime = CType((myQuery.dr("StartDate")), DateTime)
                    Dim RecurrenceParentID As Integer = Convert.ToInt32(myQuery.dr("ReccurenceParentID"))
                    Dim userID As Integer = Convert.ToInt32(myQuery.dr("UserID"))
                    Dim roomID As Integer = Convert.ToInt32(myQuery.dr("RoomID"))
                    'Dim test As String = Convert.ToString(myQuery.dr("TEST"))


                    Appointments.Add(New AppointmentInfo(ID, subject, Convert.ToDateTime(myQuery.dr("StartDate")), Convert.ToDateTime(myQuery.dr("EndDate")), Nothing, RecurrenceParentID, Nothing, userID, roomID))
                End While
                myQuery.dr.Close()
            End If


            'Dim start As DateTime = DateTime.UtcNow.[Date]
            'start = start.AddHours(6)
            'Appointments.Add(New AppointmentInfo("Take the car to the service", start, start.AddHours(1), String.Empty, Nothing, New Reminder(30).ToString(), 1))
            'Appointments.Add(New AppointmentInfo("Meeting with Alex", start.AddHours(2), start.AddHours(3), String.Empty, Nothing, String.Empty, 2))
            'start = start.AddDays(-1)
            'Dim dayStart As DateTime = RadScheduler1.UtcDayStart(start)
            'Appointments.Add(New AppointmentInfo("Bob's Birthday", dayStart, dayStart.AddDays(1), String.Empty, Nothing, String.Empty, 1))
            'Appointments.Add(New AppointmentInfo("Call Charlie about the Project", start.AddHours(2), start.AddHours(3), String.Empty, Nothing, String.Empty, 2))
            'start = start.AddDays(2)
            'Appointments.Add(New AppointmentInfo("Get the car from the service", start.AddHours(2), start.AddHours(3), String.Empty, Nothing, String.Empty, 1))


        End Sub


        Private Function FindById(ByVal ID As Object) As AppointmentInfo
            For Each ai As AppointmentInfo In Appointments
                If ai.ID.Equals(ID) Then
                    Return ai
                End If
            Next
            Return Nothing
        End Function


       


    #Region "DATABASE FUNCTION"


        Public Function getUserList() As List(Of User.User)
            Dim userList As New List(Of User.User)




            Dim dbi As DbInterface = DBInstance.DBInterface
            Dim myQuery As DbInterface.SQLQuery = dbi.NewQuery("spSelectUser")


            If Not myQuery.Execute() Then
                Throw myQuery.LastException
            Else
                While myQuery.dr.Read()


                    Dim UD As New User.User
                    UD.UserID = CInt(myQuery.dr("UserID"))
                    UD.UserName = Convert.ToString(myQuery.dr("UserName"))
                    userList.Add(UD)
                End While
                myQuery.dr.Close()
            End If


            Return userList
        End Function


        Public Function InsertAppointment(ByVal newAppointment As Telerik.Web.UI.Appointment) As Boolean
            Dim boolSuccess As Boolean = False
            Dim user As Resource = newAppointment.Resources.GetResourceByType("User")
            Dim room As Resource = newAppointment.Resources.GetResourceByType("Room")
            Dim userID As Integer = -1
            Dim roomID As Integer = -1
            If user IsNot Nothing Then
                userID = DirectCast(user.Key, System.Nullable(Of Integer))
            Else
                Return False
                Exit Function
            End If
            If room IsNot Nothing Then
                roomID = DirectCast(room.Key, System.Nullable(Of Integer))
            Else
                Return False
                Exit Function
            End If


            Dim dbi As DbInterface = DBInstance.DBInterface
            Dim myQuery As DbInterface.SQLQuery = dbi.NewQuery("spInsertAppointment")
            myQuery.AddParameter("Subject", Data.SqlDbType.VarChar, newAppointment.Subject)
            myQuery.AddParameter("StartDate", Data.SqlDbType.DateTime, newAppointment.Start)
            myQuery.AddParameter("EndDate", Data.SqlDbType.DateTime, newAppointment.End)
            myQuery.AddParameter("RoomID", Data.SqlDbType.Int, roomID)
            myQuery.AddParameter("UserID", Data.SqlDbType.Int, userID)
            myQuery.AddParameter("RecurrenceRule", Data.SqlDbType.VarChar, newAppointment.RecurrenceRule)
            myQuery.AddParameter("ReccurenceParentID", Data.SqlDbType.VarChar, CInt(newAppointment.RecurrenceParentID))


            If Not myQuery.Execute() Then
                Throw myQuery.LastException
            Else
                boolSuccess = True
                myQuery.dr.Close()
            End If


            Return boolSuccess
        End Function


        Public Function updateAppointment(ByVal updatedAppointment As Telerik.Web.UI.Appointment) As Boolean
            Dim boolSuccess As Boolean = False
            Dim user As Resource = updatedAppointment.Resources.GetResourceByType("User")
            Dim room As Resource = updatedAppointment.Resources.GetResourceByType("Room")
            Dim userID As Integer = -1
            Dim roomID As Integer = -1
            If user IsNot Nothing Then
                userID = DirectCast(user.Key, System.Nullable(Of Integer))
            Else
                Return False
                Exit Function
            End If
            If room IsNot Nothing Then
                roomID = DirectCast(room.Key, System.Nullable(Of Integer))
            Else
                Return False
                Exit Function
            End If


            Dim dbi As DbInterface = DBInstance.DBInterface
            Dim myQuery As DbInterface.SQLQuery = dbi.NewQuery("spUpdateAppointment")
            myQuery.AddParameter("ID", Data.SqlDbType.VarChar, updatedAppointment.ID)
            myQuery.AddParameter("Subject", Data.SqlDbType.VarChar, updatedAppointment.Subject)
            myQuery.AddParameter("StartDate", Data.SqlDbType.DateTime, updatedAppointment.Start)
            myQuery.AddParameter("EndDate", Data.SqlDbType.DateTime, updatedAppointment.End)
            myQuery.AddParameter("RoomID", Data.SqlDbType.Int, roomID)
            myQuery.AddParameter("UserID", Data.SqlDbType.Int, userID)
            myQuery.AddParameter("RecurrenceRule", Data.SqlDbType.VarChar, updatedAppointment.RecurrenceRule)
            myQuery.AddParameter("ReccurenceParentID", Data.SqlDbType.VarChar, CInt(updatedAppointment.RecurrenceParentID))


            If Not myQuery.Execute() Then
                Throw myQuery.LastException
            Else
                boolSuccess = True
                myQuery.dr.Close()
            End If


            Return boolSuccess
        End Function


        Public Function deleteAppointment(ByVal ID As Integer) As Boolean
            Dim boolSuccess As Boolean = False
            Dim dbi As DbInterface = DBInstance.DBInterface
            Dim myQuery As DbInterface.SQLQuery = dbi.NewQuery("spDeleteAppointment")
            myQuery.AddParameter("ID", Data.SqlDbType.Int, CInt(ID))


            If Not myQuery.Execute() Then
                Throw myQuery.LastException
            Else
                boolSuccess = True
                myQuery.dr.Close()
            End If


            Return boolSuccess
        End Function


    #End Region




    End Class






    Namespace Telerik.Web.Examples.Scheduler.BindToList
        Public Class AppointmentInfo
            Inherits Appointment
            Private _id As String
            Private _subject As String
            Private _start As DateTime
            Private _end As DateTime
            Private _recurrenceRule As String
            Private _recurrenceParentId As String
            Private _reminder As String
            Private _userID As System.Nullable(Of Integer)
            Private _roomID As System.Nullable(Of Integer)
            Private _theatreID As System.Nullable(Of Integer)
            'Private _test As String




            Public Overloads Property ID() As String
                Get
                    Return _id
                End Get
                Set(ByVal value As String)
                    _id = value
                End Set
            End Property


            Public Overloads Property Subject() As String
                Get
                    Return _subject
                End Get
                Set(ByVal value As String)
                    _subject = value
                End Set
            End Property


            Public Overloads Property Start() As DateTime
                Get
                    Return _start
                End Get
                Set(ByVal value As DateTime)
                    _start = value
                End Set
            End Property


            Public Overloads Property [End]() As DateTime
                Get
                    Return _end
                End Get
                Set(ByVal value As DateTime)
                    _end = value
                End Set
            End Property


            Public Overloads Property RecurrenceRule() As String
                Get
                    Return _recurrenceRule
                End Get
                Set(ByVal value As String)
                    _recurrenceRule = value
                End Set
            End Property


            Public Overloads Property RecurrenceParentID() As String
                Get
                    Return _recurrenceParentId
                End Get
                Set(ByVal value As String)
                    _recurrenceParentId = value
                End Set
            End Property


            Public Property Reminder() As String
                Get
                    Return _reminder
                End Get
                Set(ByVal value As String)
                    _reminder = value
                End Set
            End Property


            Public Property UserID() As System.Nullable(Of Integer)
                Get
                    Return _userID
                End Get
                Set(ByVal value As System.Nullable(Of Integer))
                    _userID = value
                End Set
            End Property


            Public Property RoomID() As System.Nullable(Of Integer)
                Get
                    Return _roomID
                End Get
                Set(ByVal value As System.Nullable(Of Integer))
                    _roomID = value
                End Set
            End Property


            Public Property TheatreID() As System.Nullable(Of Integer)
                Get
                    Return _theatreID
                End Get
                Set(ByVal value As System.Nullable(Of Integer))
                    _theatreID = value
                End Set
            End Property


            'Public Property Test() As String
            '    Get
            '        Return _test
            '    End Get
            '    Set(ByVal value As String)
            '        _test = value
            '    End Set
            'End Property


            Private Sub New()
                Me._id = Guid.NewGuid().ToString()
            End Sub


            Public Sub New(ByVal ID As Integer, ByVal subject As String, ByVal start As DateTime, ByVal [end] As DateTime, ByVal recurrenceRule As String, ByVal recurrenceParentID As String, ByVal reminder As String, _
      ByVal userID As System.Nullable(Of Integer), ByVal roomID As System.Nullable(Of Integer))
                'Me.New()
                _id = ID
                _subject = subject
                _start = start
                _end = [end]
                _recurrenceRule = recurrenceRule
                _recurrenceParentId = recurrenceParentID
                _reminder = reminder
                _userID = userID
                _roomID = roomID


            End Sub


            Public Sub New(ByVal source As Appointment)
                Me.New()
                CopyInfo(source)
            End Sub


            Public Sub CopyInfo(ByVal source As Appointment)
                Subject = source.Subject
                Start = source.Start
                [End] = source.[End]
                RecurrenceRule = source.RecurrenceRule
                If source.RecurrenceParentID IsNot Nothing Then
                    RecurrenceParentID = source.RecurrenceParentID.ToString()
                End If
                If Not [String].IsNullOrEmpty(Reminder) Then
                    Reminder = source.Reminders(0).ToString()
                End If
                Dim user As Resource = source.Resources.GetResourceByType("User")
                Dim theatre As Resource = source.Resources.GetResourceByType("Room")
                If user IsNot Nothing Then
                    UserID = DirectCast(user.Key, System.Nullable(Of Integer))
                Else
                    UserID = Nothing
                End If
                Dim ID As Integer = source.ID


            End Sub


        End Class




    End Namespace




    Namespace User
        Public Class User
            Private _userName As String
            Private _userID As System.Nullable(Of Integer)


            Public Property UserName() As String
                Get
                    Return _userName
                End Get
                Set(ByVal value As String)
                    _userName = value
                End Set
            End Property


            Public Property UserID() As System.Nullable(Of Integer)
                Get
                    Return _userID
                End Get
                Set(ByVal value As System.Nullable(Of Integer))
                    _userID = value
                End Set
            End Property


           
        End Class
    End Namespace


    MY HTML

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="RS_DS2.aspx.vb" Inherits="RS_DS2" %>


    <%--http://demos.telerik.com/aspnet-ajax/scheduler/examples/bindtolist/defaultvb.aspx--%>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="false">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
        <div class="exampleContainer">
            <%--<telerik:RadScheduler runat="server" ID="RadScheduler1" Width="750px" DayStartTime="08:00:00"
                DayEndTime="18:00:00" TimeZoneOffset="03:00:00" OnAppointmentInsert="RadScheduler1_AppointmentInsert"
                OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" OnAppointmentDelete="RadScheduler1_AppointmentDelete"
                DataKeyField="ID" DataSubjectField="Subject" DataStartField="Start" DataEndField="End"
                DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentId"   
                DataReminderField="Reminder">                                                            
                
                OnAppointmentDelete="RadScheduler1_AppointmentDelete"


                --%>
            <telerik:RadScheduler runat="server" ID="RadScheduler1"  DayStartTime="08:00:00"
                DayEndTime="18:00:00" OnAppointmentInsert="RadScheduler1_AppointmentInsert" AllowDelete="true"
                 DataKeyField="ID" DataSubjectField="Subject" OnAppointmentDelete="RadScheduler1_AppointmentDelete"
                DataStartField="Start" DataEndField="End" DataRecurrenceField="RecurrenceRule"
                DataRecurrenceParentKeyField="RecurrenceParentId" SelectedView="TimelineView">
                <AdvancedForm Modal="true" />
                 <TimelineView UserSelectable="true" GroupingDirection="Vertical" GroupBy="Room"
                    ColumnHeaderDateFormat="HH:mm" NumberOfSlots="9" SlotDuration="01:00:00" StartTime="01:00:00" />
                <TimeSlotContextMenuSettings EnableDefault="true" />
                <AppointmentContextMenuSettings EnableDefault="true" />
                <Reminders Enabled="true" />
            </telerik:RadScheduler>
        </div>
        </form>
    </body>
    </html>


    Error im getting


  9. Plamen
    Admin
    Plamen avatar
    2958 posts

    Posted 28 Oct 2011 Link to this post

    Hello Atul,

    As far as I see in the screen shots the problem is that some appointments are set to have RecurrenceParentID="0" and in this case the error is expected since there is no appointment with such ID. The correct definition is to set the RecurrenceParenRule="null" or an ID of an appointment that have a RecurrenceRule.

    Hope this will help.

    All the best, Plamen Zdravkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  10. Nikola
    Nikola avatar
    65 posts
    Member since:
    Sep 2012

    Posted 18 Oct 2012 Link to this post

    heey guys i got the same problem can plzz some one help me 

    <%@ Page Title="" Language="C#" MasterPageFile="~/ABBMaster.Master" AutoEventWireup="true" CodeBehind="UserScheduler.aspx.cs" Inherits="HolidayTracker.User.PublicScheduler" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="MainRegionContentPlaceHolder" runat="server">
        <style type="text/css">
            #Label1Panel {
                display: inline !important;
            }
     
            .lblError {
                background: #CC0000;
                border: 1px solid darkred;
                color: white;
                font: bold 16px "Segoe UI", Arial, sans-serif;
                vertical-align: middle;
                display: none;
                height: 30px;
                line-height: 28px;
                position: absolute;
                padding-left: 5px;
                width: 743px;
                z-index: 1001;
                cursor: pointer;
                opacity: 0.9;
                -moz-opacity: 0.9;
                filter: alpha(opacity=90);
            }
        </style>
     
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                        <telerik:AjaxUpdatedControl ControlID="Label1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
        <asp:Label ID="Label1" runat="server" CssClass="lblError"></asp:Label>
        <div class="exampleContainer">
            <telerik:RadScheduler runat="server" ID="RadScheduler1" Width="750px" SelectedDate="2012-04-16"
                DayStartTime="08:00:00" DayEndTime="18:00:00" DataSourceID="SqlDataSource1"
                DataKeyField="VacationID" DataSubjectField="Description" DataStartField="FromDate" DataEndField="ToDate"
                DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="VacationID"
                OnAppointmentInsert="RadScheduler1_AppointmentInsert"
                OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" OnRecurrenceExceptionCreated="RadScheduler1_RecurrenceExceptionCreated">
                <AdvancedForm Modal="true"></AdvancedForm>
                <TimelineView UserSelectable="false"></TimelineView>
                <TimeSlotContextMenuSettings EnableDefault="true"></TimeSlotContextMenuSettings>
                <AppointmentContextMenuSettings EnableDefault="true"></AppointmentContextMenuSettings>
            </telerik:RadScheduler>
        </div>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:HolidayTrackerConnectionString %>"
            DeleteCommand="DELETE FROM [Vacation] WHERE [VacationID] = @VacationID"
            InsertCommand="INSERT INTO [Vacation] ([FromDate], [ToDate], [Description], [RecurrenceRule]) VALUES (@FromDate, @ToDate, @Description, @RecurrenceRule)"
            SelectCommand="SELECT * FROM [Vacation]"
            UpdateCommand="UPDATE [Vacation] SET [FromDate] = @FromDate, [ToDate] = @ToDate, [Description] = @Description, [RecurrenceRule] = @RecurrenceRule WHERE [VacationID] = @VacationID">
            <DeleteParameters>
                <asp:Parameter Name="VacationID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="FromDate" Type="DateTime" />
                <asp:Parameter Name="ToDate" Type="DateTime" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="RecurrenceRule" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="FromDate" Type="DateTime" />
                <asp:Parameter Name="ToDate" Type="DateTime" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="RecurrenceRule" Type="String" />
                <asp:Parameter Name="VacationID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        </asp:Content>



    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
     
    namespace HolidayTracker.User
    {
        public partial class PublicScheduler : System.Web.UI.Page
        {
            private const int AppointmentsLimit = 1;
     
            private bool ExceedsLimit(Appointment apt)
            {
                int appointmentsCount = 0;
                foreach (Appointment existingApt in RadScheduler1.Appointments.GetAppointmentsInRange(apt.Start, apt.End))
                {
                    if (existingApt.Visible)
                        appointmentsCount++;
                }
     
                return (appointmentsCount > AppointmentsLimit - 1);
            }
     
            private bool AppointmentsOverlap(Appointment appointment)
            {
                if (ExceedsLimit(appointment))
                {
                    foreach (Appointment a in RadScheduler1.Appointments.GetAppointmentsInRange(appointment.Start, appointment.End))
                    {
                        if (a.ID != appointment.ID)
                        {
                            return true;
                        }
                    }
                }
     
                return false;
            }
     
     
            private void RegisterScript()
            {
                Label1.Text = "Invalid move! There are appointments arranged for this time period.";
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "LabelUpdated",
                        "$telerik.$('.lblError').show().animate({ opacity: 0.9 }, 200000).fadeOut('slow');", true);
            }
     
            protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
            {
                if (ExceedsLimit(e.Appointment))
                {
                    e.Cancel = true;
                    RegisterScript();
                }
            }
     
            protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
            {
                if (AppointmentsOverlap(e.ModifiedAppointment))
                {
                    e.Cancel = true;
                    RegisterScript();
                }
            }
     
            protected void RadScheduler1_RecurrenceExceptionCreated(object sender, RecurrenceExceptionCreatedEventArgs e)
            {
                if (AppointmentsOverlap(e.ExceptionAppointment))
                {
                    e.Cancel = true;
                    RegisterScript();
                }
            }
                protected void RadScheduler1_AppointmentCommand(object sender, AppointmentCommandEventArgs e)
            {
                if (e.CommandName == "Export")
                {
                    WriteCalendar(RadScheduler.ExportToICalendar(e.Container.Appointment));
                }
            }
     
            protected void Button2_Click(object sender, ImageClickEventArgs e)
            {
                WriteCalendar(RadScheduler.ExportToICalendar(RadScheduler1.Appointments));
            }
     
            private void WriteCalendar(string data)
            {
                HttpResponse response = Page.Response;
     
                response.Clear();
                response.Buffer = true;
     
                response.ContentType = "text/calendar";
                response.ContentEncoding = Encoding.UTF8;
                response.Charset = "utf-8";
     
                response.AddHeader("Content-Disposition", "attachment;filename=\"HolidayTrackerExport.ics\"");
     
                response.Write(data);
                response.End();
            }
        }
    }









  11. Plamen
    Admin
    Plamen avatar
    2958 posts

    Posted 23 Oct 2012 Link to this post

    Hi Nikola,

     
    You can review the DateBase Structure that may be causing this error if is not set properly.

    Hope this will help you.

    All the best,
    Plamen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  12. Nikola
    Nikola avatar
    65 posts
    Member since:
    Sep 2012

    Posted 23 Oct 2012 Link to this post

    Heey thanks for the answer nope dont help  i can gif you a pic from my db  if this is oke 
  13. Nikola
    Nikola avatar
    65 posts
    Member since:
    Sep 2012

    Posted 24 Oct 2012 Link to this post

    I solve the problem 

    You should set different fields to the DataRecurrenceField and DataRecurrenceParentKeyField properties. In case you don't need recurring appointments, these properties can be unset.

    The ScheduleID value is auto increment and can't be set in the insert query.

    for me that helps a lot
  14. Plamen
    Admin
    Plamen avatar
    2958 posts

    Posted 24 Oct 2012 Link to this post

    Hi Nikola,

    Thank you for sharing your solution and for your concern with RadControls.

    Kind regards,
    Plamen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  15. Nikola
    Nikola avatar
    65 posts
    Member since:
    Sep 2012

    Posted 24 Oct 2012 Link to this post

    Heey 

    No problem love to help people that help me ^^ if you want you can mark it as an answer I cant ... 
Back to Top