Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Displaying Appts for Specific Contacts (Read 2974 times)
Bud Staniek
Guest


Displaying Appts for Specific Contacts
Jun 29th, 2006 at 10:26am
Print Post  
I am missing a piece of the Planner puzzle. Like the thread started by Billy Fish (5/10/06), I am trying to display the appointments for specific contacts. In my case, appointment and contact data are stored in a database. In the Form Load handler, I create the corresponding (MindFusion.Scheduling) Appointment and Contact objects. But how do I programmatically link an Appointment to a specific Contact so I can view just his/her appointments on the calendar?

For example, let's say I create Contact and Appointment objects as follows:

Dim con As New MindFusion.Scheduling.Contact
con.FirstName = "Bill"
con.LastName = "Gates"
con.Id = "1"
Calendar.Schedule.Contacts.Add(con)


Dim ap as New MindFusion.Scheduling.Appointment
ap.StartTime = <Some Date value>
ap.EndTime = <Some Date value>
ap.HeaderText = "Test Appointment"


From here (assuming the above is OK), how do proceed to display the ap Appointment within a column for the con Contact?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Displaying Appts for Specific Contacts
Reply #1 - Jun 29th, 2006 at 12:30pm
Print Post  
To associate a Contact with particular appointment, add a reference to that Contact to the appointment's Contacts collection. Assuming app is a reference to the appointment and contact is a reference to the contact, the sample code below "links" the contact to the appointment:

Code
Select All
app.Contacts.Add(contact); 



In order to display the appointment for this contact, you have to switch to a calendar view that supports grouping (such as Timetable), specify grouping by contact (i.e. set Calendar.GroupType to GroupType.GroupByContact) and also ensure that the aforementioned contact is selected for grouping (by adding it to the Calendar.Contacts collection). The sample code below shows you how to turn on grouping by contacts in Planner.NET.

Code
Select All
calendar.CurrentView = CalendarView.Timetable;
calendar.Contacts.Add(contact);
calendar.GroupType = GroupType.GroupByConacts; 



Meppy
  
Back to top
 
IP Logged
 
Bud Staniek
Guest


Re: Displaying Appts for Specific Contacts
Reply #2 - Jun 29th, 2006 at 7:23pm
Print Post  
Ahh! The Contacts collection! I was Add-ing the contact to the Appointment's Resources collection. Also, do not forget you need to Add the appointment to the Calendar.Schedule.Items collection.

For future reference, the following code demonstrates the complete process.

       ' Instantiate 2 contacts
       Dim con1 As New MindFusion.Scheduling.Contact
       con1.FirstName = "Fred"
       con1.LastName = "Flinstone"
       con1.Id = "1"

       Dim con2 As New MindFusion.Scheduling.Contact
       con2.FirstName = "Mr"
       con2.LastName = "Slate"
       con2.Id = "2"

       ' Instantiate an appointment and Add "Fred" to its Contacts collection
       Dim appt As New MindFusion.Scheduling.Appointment
       appt.HeaderText = "Meeting with B. Rubble"
       appt.StartTime = New Date(2006, 7, 3, 10, 0, 0, 0)
       appt.EndTime = New Date(2006, 7, 3, 12, 0, 0, 0)
       appt.Contacts.Add(con1)

       ' Important! Add the appointment to the schedule
       Calendar.Schedule.Items.Add(appt)

       ' Display columns  for both contacts, but Fred's appointment
       ' will only appear in his column.
       Calendar.Contacts.Add(con1)
       Calendar.Contacts.Add(con2)
       Calendar.CurrentView = MindFusion.Scheduling.WinForms.CalendarView.Timetable
       Calendar.TimetableSettings.VisibleColumns = 2
       Calendar.GroupType = MindFusion.Scheduling.WinForms.GroupType.GroupByContacts
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint