Here is the entire block of code I now have working in a sort of way, well it gets further than before anyhow!
Private Sub CalTimeTableView_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles calTimeTableView.DragDrop
If Not e.Data.GetDataPresent(DataFormats.StringFormat) Then
Return
End If
' only drop an appointment on the calendar if the date is in the present
' user is not permitted to book deliveries in the past
If Not dtPointedDate < Date.Today Then
Dim app As Appointment = New Appointment
Dim l As Location = New Location
Dim i As Item = Nothing
With l
.Id = Me.PlannerSQLDataSet.Location.Rows(0).Item("id").ToString
.Name = Me.PlannerSQLDataSet.Location.Rows(0).Item("Name").ToString
End With
' set appointment detail
app.HeaderText = strHeader
app.DescriptionText = strDetail
app.StartTime = dtPointedDate
app.EndTime = dtPointedDate.Add(New TimeSpan(30 * TimeSpan.TicksPerMinute))
app.Location = l
' add the new appointment to the schedule
calTimeTableView.Schedule.Items.Add(app)
' no date is pointed to at present
dtPointedDate = DateTime.MinValue
' process new item
ProcessItemCreated(app)
' get the item just created so we can access its id field to add to po table
i = calTimeTableView.Schedule.Items.Item(calTimeTableView.Schedule.Items.Count - 1)
If Not LinkedPO(i.Id, True) Then
Exit Sub
End If
WriteLog("create", String.Empty, app.HeaderText & " " & app.DescriptionText & " start time:" & app.StartTime & " end time:" & app.EndTime, app.HeaderText)
Try
' update calendar tables in database
Me.calTimeTableView.SaveToDataSource(Me.ReminderTableAdapter1, Me.StyleTableAdapter1, Me.CustomBrushesTableAdapter1, Me.ContactTableAdapter1, Me.LocationTableAdapter1, Me.ResourceTableAdapter1, Me.TaskTableAdapter1, Me.ItemTableAdapter1, Me.ItemContactsTableAdapter1, Me.ItemResourcesTableAdapter1, Me.RecurrenceTableAdapter1, Me.RecurrenceExceptionTableAdapter1, Me.RecurrenceExceptionsTableAdapter1)
' force calendar to redraw
calTimeTableView.Invalidate()
Catch objError As Exception
MessageBox.Show("Location: CalTimeTableView_DragDrop" & System.Environment.NewLine & System.Environment.NewLine & _
"The following error occurred whilst saving delivery data" & _
System.Environment.NewLine & System.Environment.NewLine & objError.Message & _
System.Environment.NewLine & System.Environment.NewLine & _
"Please contact Distribution IT Support, the PO and Delivery are not synchronised.", _
"Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
I now get an error on the save to datasource line whereas I din not before?
"index -1 is either negative or above rows count"
????