Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - Multiple Schedules & Resources
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Multiple Schedules & Resources

 Post Reply Post Reply
Author
Message
djldc View Drop Down
Newbie
Newbie


Joined: 08 January 2010
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote djldc Quote  Post ReplyReply Direct Link To This Post Topic: Multiple Schedules & Resources
    Posted: 28 January 2010 at 3:16pm
I am trying to translate the code I have found on the message boards and I am having a very hard time. Would someone be able to tell me in english (followed by a snippet of sample code) how I would set up my calendar with multiple schedules. So far, it sounds like I need to create a dataprovider for each schedule, get the schedules, and then add the schedules to the resources. Am I on the right track? Thank you,
fyi, I am translating over to AlphaSoftware code (xbasic).
Don
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 28 January 2010 at 4:10pm
Here is something I threw together for another user trying to convert to a different language:

OK, I'll try to put this to an analogy to better understand.

A College has a calendar. Now this school has asked Codejock to help them keep track of their Professors schedules, ClassRooms, and what Course will occur in each room for any given day.

There are different ways to approach this, but I'll try to show you 2 different ways.

First we have our College Calendar. In this calendar we can display multiple resources\schedules. This calendar will display at least 2 columns of data per day. The data first column(s) will be professor schedules, the second\last column will be ClassRoom Activities.

For this setup lets say we have 10 professors and 5 classrooms (small college). Here we will give each professor his own calendar. With this setup we want to actually see each Professor's schedule in a column for any given day. To do this he must have his own RESOURCE. Inside this RESOURCE you can add his SCHEDULE.

Now the last column for a day will be used to display the current schedule for the rooms in the College. Here I'll show how to add multiple schedules to a single resource. We ONLY want to see ONE column for ALL rooms for any given day. With this setup we can use the Pre_Polulate event to filter un-wanted rooms. To do this we add a single RESOURCE. Inside this RESOURCE you can add a SCHEDULE for EACH room.

Let's put this to use.

Below is a fully functional example for VB6. Note I could have used a loop to add the Professor's resources, but I did them separate to make sure you can see what is happening.

Professor's
Dr. Tom
Dr. Bob
Dr. Oleg
Dr. Mark
Dr. Mike
Dr. Tony
Dr. Green
Dr. Brown
Dr. Black
Dr. Smith

Rooms:
MSB 101
MSB 102
MSB 103
MSB 104
MSB 105

'Add this to global variables section
Public CollegeDataResourcesManager As New CalendarResourcesManager

Private Sub mnuMultiSchedulesExtended_Click()

'// Prepare resource manager
Dim strCfgFile As String
strCfgFile = App.Path & "\" & "CodejockCollegeSample.xml"

' try to load previously saved configuration
CollegeDataResourcesManager.LoadCfg strCfgFile

'// Setup sample configuration
'// ** data provider
'Open\create new file for the calendar. It will create the file if it does not exist
Dim strConnectionString As String
strConnectionString = "Provider=XML;Data Source=" & App.Path & "\" & "CodejockCollegeCalendar.xtp_cal"

Dim bResult As Boolean
bResult = CollegeDataResourcesManager.AddDataProvider( _
strConnectionString, xtpCalendarDPF_CreateIfNotExists + _
xtpCalendarDPF_SaveOnDestroy + xtpCalendarDPF_CloseOnDestroy)

'Make sure the provider could be created and opened
If Not bResult Then
Exit Sub
End If

'Get access to the data provider
Dim pData As CalendarDataProvider
Set pData = CollegeDataResourcesManager.DataProvider(0)

'Get access to the schedules for the data provider
Dim pSchedules As CalendarSchedules
Set pSchedules = pData.Schedules

'Check that you can access the schedules
If pSchedules Is Nothing Then
Exit Sub
End If

'Create a collection of schedules, all schedules will be creates here
If pSchedules.Count < 1 Then
pSchedules.AddNewSchedule "Dr. Tom"
pSchedules.AddNewSchedule "Dr. Bob"
pSchedules.AddNewSchedule "Dr. Oleg"
pSchedules.AddNewSchedule "Dr. Mark"
pSchedules.AddNewSchedule "Dr. Mike"
pSchedules.AddNewSchedule "Dr. Tony"
pSchedules.AddNewSchedule "Dr. Green"
pSchedules.AddNewSchedule "Dr. Brown"
pSchedules.AddNewSchedule "Dr. Black"
pSchedules.AddNewSchedule "Dr. Smith"

pSchedules.AddNewSchedule "MSB 101"
pSchedules.AddNewSchedule "MSB 102"
pSchedules.AddNewSchedule "MSB 103"
pSchedules.AddNewSchedule "MSB 104"
pSchedules.AddNewSchedule "MSB 105"

'Save the new schedules to the provider
pData.Save
End If

'Add the resources for the Professor's and Classroom
'Only those with their own resource will get their own column
If CollegeDataResourcesManager.ResourcesCount = 0 Then

'Add a resource for EACH professor. This will allow them to have
'their own column to display their schedule(s)
CollegeDataResourcesManager.AddResource "Dr. Tom", True
CollegeDataResourcesManager.AddResource "Dr. Bob", True
CollegeDataResourcesManager.AddResource "Dr. Oleg", True
CollegeDataResourcesManager.AddResource "Dr. Mark", True
CollegeDataResourcesManager.AddResource "Dr. Mike", True
CollegeDataResourcesManager.AddResource "Dr. Tony", True
CollegeDataResourcesManager.AddResource "Dr. Green", True
CollegeDataResourcesManager.AddResource "Dr. Brown", True
CollegeDataResourcesManager.AddResource "Dr. Black", True
CollegeDataResourcesManager.AddResource "Dr. Smith", True

'Add a resource for ALL classrooms. This will be used to display the
'schedule for all 5 classrooms in a single column.
CollegeDataResourcesManager.AddResource "Class Rooms", True

'Create a description object so we can add details for each resource
Dim pRCDesc As CalendarResourceDescription

'Add Dr. Tom's resource to the data provider
Set pRCDesc = CollegeDataResourcesManager.Resource(0)
pRCDesc.Resource.SetDataProvider pData, False
pRCDesc.Resource.ScheduleIDs.Add pSchedules(0).Id
pRCDesc.GenerateName = True

'Add Dr. Bob's resource to the data provider
Set pRCDesc = CollegeDataResourcesManager.Resource(1)
pRCDesc.Resource.SetDataProvider pData, False
pRCDesc.Resource.ScheduleIDs.Add pSchedules(1).Id
pRCDesc.GenerateName = True

'Add Dr. Oleg's resource to the data provider
Set pRCDesc = CollegeDataResourcesManager.Resource(2)
pRCDesc.Resource.SetDataProvider pData, False
pRCDesc.Resource.ScheduleIDs.Add pSchedules(2).Id
pRCDesc.GenerateName = True

'Add Dr. Mark's resource to the data provider
Set pRCDesc = CollegeDataResourcesManager.Resource(3)
pRCDesc.Resource.SetDataProvider pData, False
pRCDesc.Resource.ScheduleIDs.Add pSchedules(3).Id
pRCDesc.GenerateName = True

'Add Dr. Mike's resource to the data provider
Set pRCDesc = CollegeDataResourcesManager.Resource(4)
pRCDesc.Resource.SetDataProvider pData, False
pRCDesc.Resource.ScheduleIDs.Add pSchedules(4).Id
pRCDesc.GenerateName = True

'Add Dr. Tony's resource to the data provider
Set pRCDesc = CollegeDataResourcesManager.Resource(5)
pRCDesc.Resource.SetDataProvider pData, False
pRCDesc.Resource.ScheduleIDs.Add pSchedules(5).Id
pRCDesc.GenerateName = True

'Add Dr. Green's resource to the data provider
Set pRCDesc = CollegeDataResourcesManager.Resource(6)
pRCDesc.Resource.SetDataProvider pData, False
pRCDesc.Resource.ScheduleIDs.Add pSchedules(6).Id
pRCDesc.GenerateName = True

'Add Dr. Brown's resource to the data provider
Set pRCDesc = CollegeDataResourcesManager.Resource(7)
pRCDesc.Resource.SetDataProvider pData, False
pRCDesc.Resource.ScheduleIDs.Add pSchedules(7).Id
pRCDesc.GenerateName = True

'Add Dr. Black's resource to the data provider
Set pRCDesc = CollegeDataResourcesManager.Resource(8)
pRCDesc.Resource.SetDataProvider pData, False
pRCDesc.Resource.ScheduleIDs.Add pSchedules(8).Id
pRCDesc.GenerateName = True

'Add Dr. Smith's resource to the data provider
Set pRCDesc = CollegeDataResourcesManager.Resource(9)
pRCDesc.Resource.SetDataProvider pData, False
pRCDesc.Resource.ScheduleIDs.Add pSchedules(9).Id
pRCDesc.GenerateName = True

Set pRCDesc = CollegeDataResourcesManager.Resource(10)
pRCDesc.Resource.SetDataProvider pData, False
pRCDesc.Resource.ScheduleIDs.Add pSchedules(10).Id
pRCDesc.Resource.ScheduleIDs.Add pSchedules(11).Id
pRCDesc.Resource.ScheduleIDs.Add pSchedules(12).Id
pRCDesc.Resource.ScheduleIDs.Add pSchedules(13).Id
pRCDesc.Resource.ScheduleIDs.Add pSchedules(14).Id
pRCDesc.GenerateName = False

'// Save changed resources configuration
CollegeDataResourcesManager.SaveCfg strCfgFile
End If

'// Apply resources configuration
CollegeDataResourcesManager.ApplyToCalendar CalendarControl

CalendarControl.Populate
CalendarControl.RedrawControl
End Sub

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 28 January 2010 at 4:13pm
FYI, in PowerBuilder, the "default" property for an object is not referenced the same as in VB6, for example:

PowerBuilder:

// 'Add Dr. Oleg's resource to the data provider
    pRCDesc = OleCalendarResourceManager.Resource(2)
    pRCDesc.Resource.SetDataProvider(pData, False)
    pRCDesc.Resource.ScheduleIDs.Add(pSchedules.Item(2).Id)
    pRCDesc.GenerateName = True

VB6
'Add Dr. Oleg's resource to the data provider
Set pRCDesc = CollegeDataResourcesManager.Resource(2)
pRCDesc.Resource.SetDataProvider pData, False
pRCDesc.Resource.ScheduleIDs.Add pSchedules(2).Id
pRCDesc.GenerateName = True


Back to Top
djldc View Drop Down
Newbie
Newbie


Joined: 08 January 2010
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote djldc Quote  Post ReplyReply Direct Link To This Post Posted: 29 January 2010 at 6:37am
Great example! Thank you. Now I just need to figure out how to translate some of this into AlphaSoftware language.
Back to Top
djldc View Drop Down
Newbie
Newbie


Joined: 08 January 2010
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote djldc Quote  Post ReplyReply Direct Link To This Post Posted: 16 February 2010 at 2:30pm
OK.. got it working. Now I am trying to get the schedule ID of the resource/column I click on. That is, when I click to create an event I would like to get the id of the schedule I clicked on. Is that possible? Thank you.

Don
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.