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

When i delete an appoinment the resources remain

1 Answer 82 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Martin Gartmann
Top achievements
Rank 2
Martin Gartmann asked on 16 Oct 2020, 01:50 PM

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


1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Oct 2020, 01:24 PM
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).

Tags
Scheduler and Reminder
Asked by
Martin Gartmann
Top achievements
Rank 2
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or