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