Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic relationship between appointment and contact (Read 3365 times)
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
relationship between appointment and contact
Oct 17th, 2007 at 7:59am
Print Post  
I have a timetable view calendar and can add an appointment and save it to a database without any problems.

I have modified on the fly the AppointmentForm to show a new textbox and a button which will allow the user to save a contact against the current appointment.

I can save the appointment which is created in the drag_drop event as a local variable to that event without problem.

I can create a contact via my custom button on the AppointmentForm and save it.

However the two are not linked? 

I look in my database and I see the appointment in the Item table and the contact in the Contact table but nothing in the ItemContact table which I believe links the two?

Here is the contact creation code:

Code
Select All
Private Sub EditContact(ByVal sender As System.Object, ByVal e As System.EventArgs)

	  Dim frm As ContactDialog = New ContactDialog

	  frm.ShowDialog()

	  If frm.DialogResult = Windows.Forms.DialogResult.OK Then

		Dim c As Contact = New Contact

		c.FirstName = frm.txtCarrier.Text

		c.LastName = frm.txtContact.Text

		c.Phone = frm.txtTelephone.Text

		c.Email = frm.txtEmail.Text

		Me.calTimeTableView.Schedule.Contacts.Add(c)

	  End If

End Sub
 



How do I find the required appointment in the Calendar to asscociate the newly created (or to be edited) contact?

Thnx



  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: relationship between appointment and contact
Reply #1 - Oct 17th, 2007 at 8:43am
Print Post  
To establish a relationship between an item and a contact in the schedule, you have to add a reference to the contact to the item's Contacts collection.

You can obtain a reference to the item being edited in the AppointmentForm through its Appointment property.

Hope this helps.

Meppy
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: relationship between appointment and contact
Reply #2 - Oct 17th, 2007 at 9:34am
Print Post  
KOOL Wink

I have managed to link the two but have the added problem now that the ItemContact table does not remove the existing entry and just keeps adding a new row?

Here is my code, the item and contact table seem to be doing as I expect, any pointers???

Thnx

Code
Select All
Private Sub EditContact(ByVal sender As System.Object, ByVal e As System.EventArgs)

	  ' create the contact entry form

	  Dim frm As ContactDialog = New ContactDialog

	  ' required objects and variables

	  Dim a As Appointment
	  Dim app As Appointment = New Appointment
	  Dim c As Contact = New Contact
	  Dim x As Boolean = False

	  ' save the id of the selected appointment so we can asscociate the contact

	  For Each a In Me.calTimeTableView.Schedule.Items

		If a.Id = strAppID Then

		    app = a

		    Exit For

		End If

	  Next

	  ' if count > 0 then set the fields on the contact detail form the exisitng data
	  ' note we will restrict this appplication to only 1 contact per appointment, no groups

	  If app.Contacts.Count > 0 Then

		c = app.Contacts.Item(0)

		frm.txtCarrier.Text = c.FirstName

		frm.txtContact.Text = c.LastName

		frm.txtTelephone.Text = c.Phone

		frm.txtEmail.Text = c.Email

		x = True

	  End If

	  ' display contact detail form to user

	  frm.ShowDialog()

	  ' if we get an ok save the changes

	  If frm.DialogResult = Windows.Forms.DialogResult.OK Then

		c.FirstName = frm.txtCarrier.Text

		c.LastName = frm.txtContact.Text

		c.Phone = frm.txtTelephone.Text

		c.Email = frm.txtEmail.Text

		If x = False Then

		    Me.calTimeTableView.Schedule.Contacts.Add(c)

		    app.Contacts.Add(c)

		End If

	  End If

 End Sub

 

  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: relationship between appointment and contact
Reply #3 - Oct 18th, 2007 at 6:47am
Print Post  
Are you using the SQL built-in relationships between the tables in your database? If that is the case, remove all relationships between the tables. Planner.NET will take care of them internally. Otherwise SQL might prevent deleting records in one of the databases if there is a relation between dependent records.

Meppy
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: relationship between appointment and contact
Reply #4 - Oct 18th, 2007 at 1:37pm
Print Post  
Hi,  I have been into the designer and removed all relationships lines and the itemcontacts table still keeps adding new lines and not updating or removing the old ones?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: relationship between appointment and contact
Reply #5 - Oct 19th, 2007 at 7:06am
Print Post  
Is it possible to send me your database with the records within it?

Thank you,
Meppy
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: relationship between appointment and contact
Reply #6 - Oct 19th, 2007 at 8:31am
Print Post  
sure, can you give me an email address as I don't know how to attach a file here?

Thnx
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: relationship between appointment and contact
Reply #7 - Oct 19th, 2007 at 10:53am
Print Post  
You can send it to support@mindfusion.eu.

Thank you,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint