Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - Schedules with custom data provider
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Schedules with custom data provider

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


Joined: 23 January 2008
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote dwise Quote  Post ReplyReply Direct Link To This Post Topic: Schedules with custom data provider
    Posted: 23 January 2008 at 11:46am
Hi,
 
I use the follwing code to fill my calendar:
 
    Dim objCalendar As XtremeCalendarControl.CalendarControl
    Dim objEvent As XtremeCalendarControl.CalendarEvent
    Dim objRecordset As ADODB.Recordset
    Dim a As Boolean
   
    Set objRecordset = New ADODB.Recordset
    Set objCalendar = Me.ActCalendar.Object
  
    objCalendar.ActiveView.ShowDay Me.TxtCurrentdag, True
    objCalendar.ViewType = xtpCalendarMonthView
    objCalendar.DataProvider.Schedules.AddNewSchedule "Test1"
    objCalendar.DataProvider.Schedules.AddNewSchedule "Test2"
    objCalendar.DataProvider.Save
    objCalendar.DataProvider.RemoveAllEvents
 
    objRecordset.Open "OnderhoudPlanning_TotaalView", CurrentProject.AccessConnection, adOpenForwardOnly, adLockReadOnly
   
    While Not objRecordset.EOF
        Set objEvent = objCalendar.DataProvider.CreateEventEx(objRecordset!id)
 
        With objEvent
            .StartTime = objRecordset!Datum
            .EndTime = DateAdd("h", 1, objRecordset!Datum)
            .Body = "Test"
            .subject = "Test"
            'Code to split over different schedules
            If a Then
                .ScheduleID = 1
                a = False
            Else
                .ScheduleID = 2
                a = True
            End If
        End With
 
        objCalendar.DataProvider.AddEvent objEvent
        Set objEvent = Nothing
        objRecordset.MoveNext
    Wend
 
    objRecordset.Close
    Set objRecordset = Nothing
 
    objCalendar.Populate
    Set objCalendar = Nothing
 
 
The schedules do not show up. Can anyone give me an example of how this is done?  All the different schedules are based on one table.
 
Thanks in advance!
 
Back to Top
wlcabral View Drop Down
Groupie
Groupie
Avatar

Joined: 25 April 2007
Location: Brazil
Status: Offline
Points: 72
Post Options Post Options   Thanks (0) Thanks(0)   Quote wlcabral Quote  Post ReplyReply Direct Link To This Post Posted: 23 January 2008 at 12:53pm

In my case (ms Foxpro) I can see 2 different options :

 I call .dataprovider.Create() before starts and I use createevent() instead createeventEx().

I don’t know if helps, but, here is the code ...

Foxpro CODE:

This.xtremecalendar.dataprovider.Create()   && I used in INIT event

     

This.xtremecalendar.dataprovider.removeallevents()

This.xtremecalendar.populate()

 

 

Select (ccursor)

Scan

 

      oevent = This.xtremecalendar.Object.dataprovider.createevent()

 

      with oevent

            .starttime        = starttime

            .endtime          = endtime

            .subject          = Alltrim(subject)

            .body             = body

            .Label          = Label

            .busystatus     = busystatus

            .importance     = importance

            .privateflag    = Private

            .meetingflag    = meeting

 

            .customproperties.property('ukey') = ukey

      endwith

 

      This.xtremecalendar.Object.dataprovider.addevent( oevent )

 

Endscan

wlcabral
Back to Top
dwise View Drop Down
Newbie
Newbie


Joined: 23 January 2008
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote dwise Quote  Post ReplyReply Direct Link To This Post Posted: 23 January 2008 at 2:06pm
Hi wlcabral ,
 
Thanks for the code. The part of populating the calendar is not the problem.
 
I would like to use different schedules (events belonging to different recources/persons).
 
I've seen examples for this with different datasources, in my case i only have one datasource, i also do not have a connectionstring because the events are manually added.
Back to Top
wlcabral View Drop Down
Groupie
Groupie
Avatar

Joined: 25 April 2007
Location: Brazil
Status: Offline
Points: 72
Post Options Post Options   Thanks (0) Thanks(0)   Quote wlcabral Quote  Post ReplyReply Direct Link To This Post Posted: 23 January 2008 at 4:20pm


Ops :)    In this case I think it’s a little more complicated:

Again talking in FOXPRO way :

1 . You need to create a CalendarResources collection :

calResourceS = createobject("Codejock.CalendarResourceS.11.2.2")

2. Create a calendar Resource object for each Schedule that you want

Sche1 = createobject("Codejock.CalendarResource.11.2.2")

and for each Schedule created, set some properties :

Sche1.name = “title for schedule1”

Sche1.setDataProvider2(“memory”, false)
 dataProvider1 = sche1.dataProvider 
 dataProvider1.create()

Sche1.ScheduleIDs.Add(nID1) ‘ One for each ID for Schedule
Sche1.ScheduleIDs.Add(nID2) ‘ One for each ID for Schedule


 
Sche2 = createobject("Codejock.CalendarResource.11.2.2")

Sche2.name = “title for schedule1”
Sche2.setDataProvider2(“memory”, false)
 dataProvider2 = sche1.dataProvider 
 dataProvider2.create()

Sche1.ScheduleIDs.Add(nID3) ‘ One for each ID for Schedule

Sche3…Sche4…


3.  Add the schedule to Schedule collections
 CalResourceS.Add( Sche1 )
 CalResourceS.Add( Sche2 )
 CalResourceS.Add( ScheN )


4 Inform the control that you want multiples resource :
 .SetMultipleResources( CalResourceS )

 

5 Each event must be populated in the righ dataprovider

If a then
 dataP =.MultipleResources.Item(0).DataProvider
else
 dataP =.MultipleResources.Item(1).DataProvider
end if


Set objEvent = dataP.CreateEvent()


dataP.AddEvent objEvent


 

wlcabral
Back to Top
dwise View Drop Down
Newbie
Newbie


Joined: 23 January 2008
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote dwise Quote  Post ReplyReply Direct Link To This Post Posted: 24 January 2008 at 3:43am
This looks very promissing, i'm going to give it a try. Thank you very much
Back to Top
dwise View Drop Down
Newbie
Newbie


Joined: 23 January 2008
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote dwise Quote  Post ReplyReply Direct Link To This Post Posted: 24 January 2008 at 4:43am

Ok That worked! For anyone who is interrested, the working code:

Public Sub LoadCalendar()
 
    Dim objResources As XtremeCalendarControl.CalendarResources
    Dim objCalendar As XtremeCalendarControl.CalendarControl
   
    Set objCalendar = Me.ActCalendar.Object
   
    Set objResources = New XtremeCalendarControl.CalendarResources
   
    objResources.Add CreateResource("test1", 1)
    objResources.Add CreateResource("Test2", 2)
   
    AddEvent objResources(0).DataProvider, 1
    AddEvent objResources(1).DataProvider, 2
   
    objCalendar.SetMultipleResources objResources
    objCalendar.ActiveView.ShowDay Me.TxtCurrentdag, True
    objCalendar.ViewType = xtpCalendarWorkWeekView
    objCalendar.Populate
   
    Set objCalendar = Nothing

End Sub
 
Private Function CreateResource(prmName As String, prmId As Long) As XtremeCalendarControl.CalendarResource
 
    Dim objResource As XtremeCalendarControl.CalendarResource
   
    Set objResource = New XtremeCalendarControl.CalendarResource
   
    With objResource
        .name = prmName
        .SetDataProvider2 "memory", False
        .DataProvider.Create
        .ScheduleIDs.Add prmId
    End With
   
    Set CreateResource = objResource
   
End Function
 
Private Sub AddEvent(ByRef prmData As XtremeCalendarControl.CalendarDataProvider, prmId As Long)
 
    Dim objEvent As XtremeCalendarControl.CalendarEvent
   
    Set objEvent = prmData.CreateEvent
   
    With objEvent
        .subject = "Event for id: " & prmId
        .StartTime = Now
        .EndTime = DateAdd("h", 1, Now)
        .ScheduleID = prmId
    End With
   
    prmData.AddEvent objEvent
   
    Set objEvent = Nothing
 
End Sub
 
Again, thank you very much!
 
Back to Top
ericl View Drop Down
Newbie
Newbie


Joined: 06 February 2008
Location: France
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote ericl Quote  Post ReplyReply Direct Link To This Post Posted: 20 February 2008 at 1:08pm
Thanks to everyone, your posts helped me so much !
Back to Top
cetinbudak View Drop Down
Newbie
Newbie
Avatar

Joined: 24 January 2010
Location: Turkey
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote cetinbudak Quote  Post ReplyReply Direct Link To This Post Posted: 24 January 2010 at 5:48pm
thank you very much dwise!... you saved my lots of time...
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.156 seconds.