This is a migrated thread and some comments may be shown as answers.

Error On Delete With Recurrences

14 Answers 329 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Steve Olson
Top achievements
Rank 1
Steve Olson asked on 11 Dec 2007, 10:03 PM
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


14 Answers, 1 is accepted

Sort by
0
Steve Olson
Top achievements
Rank 1
answered on 12 Dec 2007, 09:40 PM
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)


0
Neil
Top achievements
Rank 2
answered on 15 Dec 2007, 10:44 AM
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, 
0
Peter
Telerik team
answered on 17 Dec 2007, 12:22 PM
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
0
Chris
Top achievements
Rank 2
answered on 02 Jun 2009, 04:49 AM
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:
<asp:EntityDataSource ID="TasksDataSource" runat="server"   
    ConnectionString="name=DataEntities" DefaultContainerName="DataEntities" EnableDelete="false"   
    EnableInsert="True" EnableUpdate="True" EntitySetName="Task" OnInserting="TaskDataSource_Inserting"   
    Where="it.AssignedTo.PersonId == @PersonId"   
    onupdated="TasksDataSource_Updated" onupdating="TasksDataSource_Updating" > 
</asp:EntityDataSource> 

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

My Code Behine looks like this:
protected void Page_Load(object sender, EventArgs e)  
{  
    if (!Page.IsPostBack)  
    {  
        TasksDataSource.WhereParameters.Add("PersonId", TypeCode.Int32, CurrentUser.PersonId.ToString());  
    }  
}  
 
protected void TaskDataSource_Inserting(object sender, EntityDataSourceChangingEventArgs e)  
{  
    Task task = e.Entity as Task;  
    if (task != null)  
    {  
        Person person = Person.GetPersonById(CurrentUser.PersonId);  
        e.Context.Attach(person);  
        task.TaskType = 2;  
        task.CreatedBy = person;  
        task.AssignedTo = person;  
        task.DateAdded = DateTime.UtcNow;  
    }  
}  
 
protected void radScheduler_AppointmentDelete(object sender, Telerik.Web.UI.SchedulerCancelEventArgs e)  
{  
    int taskId = Convert.ToInt32(e.Appointment.ID);  
    using (DataEntities de = new DataEntities())  
    {  
        var taskQuery = from delTask in de.Task  
                        where delTask.TaskId == taskId  
                        select delTask;  
 
        Task task = taskQuery.FirstOrDefault();  
        de.DeleteObject(task);  
 
        de.SaveChanges();  
    }  
}  
 
protected void radScheduler_AppointmentUpdate(object sender, Telerik.Web.UI.AppointmentUpdateEventArgs e)  
{  
    //Task.UpdateRecurrenceRule((int)e.Appointment.ID, e.ModifiedAppointment.RecurrenceRule);  
    //e.Cancel = true;  

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
0
T. Tsonev
Telerik team
answered on 05 Jun 2009, 08:50 AM
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.
0
Chris
Top achievements
Rank 2
answered on 05 Jun 2009, 05:17 PM

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!!!

0
atul
Top achievements
Rank 1
answered on 27 Oct 2011, 06:27 AM
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


0
Plamen
Telerik team
answered on 28 Oct 2011, 03:45 PM
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
0
Nikola
Top achievements
Rank 2
answered on 18 Oct 2012, 12:16 PM
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();
        }
    }
}









0
Plamen
Telerik team
answered on 23 Oct 2012, 10:11 AM
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.
0
Nikola
Top achievements
Rank 2
answered on 23 Oct 2012, 10:56 AM
Heey thanks for the answer nope dont help  i can gif you a pic from my db  if this is oke 
0
Nikola
Top achievements
Rank 2
answered on 24 Oct 2012, 07:46 AM
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
0
Plamen
Telerik team
answered on 24 Oct 2012, 08:10 AM
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.
0
Nikola
Top achievements
Rank 2
answered on 24 Oct 2012, 11:55 AM
Heey 

No problem love to help people that help me ^^ if you want you can mark it as an answer I cant ... 
Tags
Scheduler
Asked by
Steve Olson
Top achievements
Rank 1
Answers by
Steve Olson
Top achievements
Rank 1
Neil
Top achievements
Rank 2
Peter
Telerik team
Chris
Top achievements
Rank 2
T. Tsonev
Telerik team
atul
Top achievements
Rank 1
Plamen
Telerik team
Nikola
Top achievements
Rank 2
Share this question
or