When i delete an appoinment the resources remain

2 posts, 0 answers
  1. Martin Gartmann
    Martin Gartmann avatar
    54 posts
    Member since:
    Apr 2004

    Posted 16 Oct 2020 Link to this post

    Hi all,

    when i delete an appoinment i my winform application the resources of this appointment is not been deleted-

    here is my code block is use, copied from an telerik example

    Private Sub UpdSchedulerData(ByVal sender As Object, ByVal e As EventArgs) Handles RadScheduler1.AppointmentChanged
           AppointmentsResourcesTableAdapter.Adapter.AcceptChangesDuringUpdate = False
           Dim deletedRelationRecords As SchedulerDataDataSet.AppointmentsResourcesDataTable = TryCast(Me.SchedulerDataDataSet.AppointmentsResources.GetChanges(DataRowState.Deleted), SchedulerDataDataSet.AppointmentsResourcesDataTable)
           Dim newRelationRecords As SchedulerDataDataSet.AppointmentsResourcesDataTable = TryCast(Me.SchedulerDataDataSet.AppointmentsResources.GetChanges(DataRowState.Added), SchedulerDataDataSet.AppointmentsResourcesDataTable)
           Dim modifiedRelationRecords As SchedulerDataDataSet.AppointmentsResourcesDataTable = TryCast(Me.SchedulerDataDataSet.AppointmentsResources.GetChanges(DataRowState.Modified), SchedulerDataDataSet.AppointmentsResourcesDataTable)
           Dim newAppointmentRecords As SchedulerDataDataSet.AppointmentsDataTable = TryCast(Me.SchedulerDataDataSet.Appointments.GetChanges(DataRowState.Added), SchedulerDataDataSet.AppointmentsDataTable)
           Dim deletedAppointmentRecords As SchedulerDataDataSet.AppointmentsDataTable = TryCast(Me.SchedulerDataDataSet.Appointments.GetChanges(DataRowState.Deleted), SchedulerDataDataSet.AppointmentsDataTable)
           Dim modifiedAppointmentRecords As SchedulerDataDataSet.AppointmentsDataTable = TryCast(Me.SchedulerDataDataSet.Appointments.GetChanges(DataRowState.Modified), SchedulerDataDataSet.AppointmentsDataTable)
           Try
               If newAppointmentRecords IsNot Nothing Then
                   Dim newAppointmentIds As New Dictionary(Of Integer, Integer)()
                   Dim oldAppointmentIds As New Dictionary(Of Object, Integer)()
                   For i As Integer = 0 To newAppointmentRecords.Count - 1
                       oldAppointmentIds.Add(newAppointmentRecords(i), newAppointmentRecords(i).ID)
                   Next
                   AppointmentsTableAdapter.Update(newAppointmentRecords)
                   For i As Integer = 0 To newAppointmentRecords.Count - 1
                       newAppointmentIds.Add(oldAppointmentIds(newAppointmentRecords(i)), newAppointmentRecords(i).ID)
                   Next
                   If newRelationRecords IsNot Nothing Then
                       For i As Integer = 0 To newRelationRecords.Count - 1
                           newRelationRecords(i).AppointmentID = newAppointmentIds(newRelationRecords(i).AppointmentID)
                       Next
                   End If
               End If
               If deletedRelationRecords IsNot Nothing Then
                   AppointmentsResourcesTableAdapter.Update(deletedRelationRecords)
               End If
               If deletedAppointmentRecords IsNot Nothing Then
                   AppointmentsTableAdapter.Update(deletedAppointmentRecords)
               End If
               If modifiedAppointmentRecords IsNot Nothing Then
                   AppointmentsTableAdapter.Update(modifiedAppointmentRecords)
               End If
               If newRelationRecords IsNot Nothing Then
                   AppointmentsResourcesTableAdapter.Update(newRelationRecords)
               End If
               If modifiedRelationRecords IsNot Nothing Then
                   AppointmentsResourcesTableAdapter.Update(modifiedRelationRecords)
               End If
               Me.SchedulerDataDataSet.AcceptChanges()
           Catch ex As Exception
               MessageBox.Show(String.Format("An error occurred during the update process:" & vbLf & "{0}", ex.Message))
           Finally
               If deletedRelationRecords IsNot Nothing Then
                   deletedRelationRecords.Dispose()
               End If
               If newRelationRecords IsNot Nothing Then
                   newRelationRecords.Dispose()
               End If
               If modifiedRelationRecords IsNot Nothing Then
                   modifiedRelationRecords.Dispose()
               End If
           End Try
       End Sub

     

    when i move an appointment between resources and deleting in ran into an parallel exception in delete command.

    any suggestions around what might the cause?

    Kind regards

    Martin


  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4127 posts

    Posted 20 Oct 2020 Link to this post

    Hello, Martin, 

    According to the provided information, I suppose that you hit the problem explained in the following knowledge base article: https://docs.telerik.com/devtools/winforms/knowledge-base/scheduler-delete-appointments 

    Please give this approach a try and see how it works on your end.

    In case you are still experiencing any further difficulties, it would be greatly appreciated if you can submit a support ticket from your Telerik account and provide a sample project demonstrating the undesired behavior that you are facing. Thus, we would be able to get better understanding of the setup that you have on your end, investigate the precise and think about a suitable solution.

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Back to Top