Print Page | Close Window

Load multiple resources and events

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=5174
Printed Date: 22 November 2024 at 3:54pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Load multiple resources and events
Posted By: Rod001
Subject: Load multiple resources and events
Date Posted: 29 September 2006 at 11:56am
Hi,
 
I'm new to this control, and I'm trying to test and understand the MultipleResources and date events. I'm able to set up the calendar with multiple resources but not able to add any date events.

  Private Sub Form_Load()
    Init
    
    BuildResourceItems "john,tim,rod,bill,nancy"
 
  End Sub
 
Public Sub BuildResourceItems(sNames As String)
Dim arResources As New CalendarResources
Dim pRes0 As New CalendarResource
Dim pRes1 As New CalendarResource
Dim NewEvent As CalendarEvent
Dim pSchedules As CalendarSchedules
Dim strConnectionString As String
Dim sArray() As String
Dim ldx As Integer
  
strConnectionString = "Provider=Custom;Data Source="
pRes0.SetDataProvider2 strConnectionString, True
If pRes0.DataProvider Is Nothing Then
    Debug.Assert False
    Exit Sub
End If
If Not pRes0.DataProvider.Open Then
    If Not pRes0.DataProvider.Create Then
         Debug.Assert False
         Exit Sub
    End If
End If
 '// ** schedules
 
 Set pSchedules = pRes0.DataProvider.Schedules
 sArray = Split(sNames, ",")
 For ldx = 0 To UBound(sArray)
    pSchedules.AddNewSchedule sArray(ldx)
  
 Next
 pRes0.DataProvider.Save
 
 
 pRes1.SetDataProvider pRes0.DataProvider, False
 
 pRes0.Name = pSchedules.Item(0).Name
 pRes0.ScheduleIDs.Add pSchedules.Item(0).Id
 
 
 sArray = Split(sNames, ",")
 For ldx = 0 To UBound(sArray)
    Set pRes1 = New CalendarResource
    pRes1.Name = sArray(ldx)
    pRes1.ScheduleIDs.Add ldx
    arResources.Add pRes1
  
 Next
 CalendarControl1.SetMultipleResources arResources
 
   Set NewEvent = CalendarControl1.DataProvider.CreateEvent ' error problem occurs here

   NewEvent.StartTime = Now
    NewEvent.EndTime = Now
    NewEvent.Subject = "Product Meeting"
    NewEvent.ScheduleID = 1
    CalendarControl1.DataProvider.AddEvent NewEvent
 CalendarControl1.Populate
End Sub
 
Thank you,
Rod001



Replies:
Posted By: sserge
Date Posted: 03 October 2006 at 10:44am
Hi,

You just mixed up some things a little, and as result - no data provider is attached to Calendar at all.
 
I mean that you create data provider in pRes0 but skip a step of adding pRes0 to an array.
Also you have to set data provider to each resource.
 

Public Sub BuildResourceItems(sNames As String)
    Dim arResources As New CalendarResources
    Dim pRes0 As New CalendarResource
    Dim pRes1 As New CalendarResource
    Dim NewEvent As CalendarEvent
    Dim pSchedules As CalendarSchedules
    Dim strConnectionString As String
    Dim sArray() As String
    Dim ldx As Integer
  
    strConnectionString = "Provider=Custom;Data Source="
    pRes0.SetDataProvider2 strConnectionString, True
    If pRes0.DataProvider Is Nothing Then
        Debug.Assert False
        Exit Sub
    End If
    If Not pRes0.DataProvider.Open Then
        If Not pRes0.DataProvider.Create Then
            Debug.Assert False
            Exit Sub
        End If
    End If
    '// ** schedules
 
    Set pSchedules = pRes0.DataProvider.Schedules
    sArray = Split(sNames, ",")
    For ldx = 0 To UBound(sArray)
        pSchedules.AddNewSchedule sArray(ldx)
    Next
    pRes0.DataProvider.Save
   
    pRes0.Name = pSchedules.Item(0).Name
    pRes0.ScheduleIDs.Add pSchedules.Item(0).Id
 
    ' Add first resource to array
    arResources.Add pRes0
 
        sArray = Split(sNames, ",")
    ' Add others (exclude first one)
    For ldx = 1 To UBound(sArray)
        Set pRes1 = New CalendarResource
        pRes1.Name = sArray(ldx)
        pRes1.ScheduleIDs.Add ldx
        ' set data provider from first resource
        pRes1.SetDataProvider pRes0.DataProvider, False
 
       arResources.Add pRes1
    Next
    CalendarControl1.SetMultipleResources arResources
 
        Set NewEvent = CalendarControl1.DataProvider.CreateEvent ' error problem occurs here

    NewEvent.StartTime = Now
    NewEvent.EndTime = Now
    NewEvent.Subject = "Product Meeting"
    NewEvent.ScheduleID = 1
    CalendarControl1.DataProvider.AddEvent NewEvent
 CalendarControl1.Populate
End Sub



--
WBR,
Serge


Posted By: Rod001
Date Posted: 03 October 2006 at 2:46pm
Serge,
 
The changes work great! I am trying to develop a proof of concept for our management team and would appreciate any and all help.
After updating the code with the changes I can't seem to make the events for adding dates to show up in the calendar.
 
Thank you,
Rod001 


Posted By: Rod001
Date Posted: 05 October 2006 at 3:01pm

Sorry for the previous question, everything did work. Things works a lot

better when you (me) cuts and paste all the code.

Thanks again,
Rod001
 
 
 



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net