|  | 
| Schedules with custom data provider | 
| Post Reply   | 
| Author | |
| dwise   Newbie   Joined: 23 January 2008 Status: Offline Points: 6 |  Post Options  Thanks(0)  Quote  Reply  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! | |
|  | |
| wlcabral   Groupie     Joined: 25 April 2007 Location: Brazil Status: Offline Points: 72 |  Post Options  Thanks(0)  Quote  Reply  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
     | |
|  | |
| dwise   Newbie   Joined: 23 January 2008 Status: Offline Points: 6 |  Post Options  Thanks(0)  Quote  Reply  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. | |
|  | |
| wlcabral   Groupie     Joined: 25 April 2007 Location: Brazil Status: Offline Points: 72 |  Post Options  Thanks(0)  Quote  Reply  Posted: 23 January 2008 at 4:20pm | 
| 
 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) Sche1.ScheduleIDs.Add(nID1) ‘ One for each ID for Schedule 
 Sche2.name = “title for schedule1” Sche1.ScheduleIDs.Add(nID3) ‘ One for each ID for Schedule Sche3…Sche4… 
 
 
 5 Each event must be populated in the righ dataprovider If a then 
 
 | |
| 
     wlcabral
     | |
|  | |
| dwise   Newbie   Joined: 23 January 2008 Status: Offline Points: 6 |  Post Options  Thanks(0)  Quote  Reply  Posted: 24 January 2008 at 3:43am | 
| 
   This looks very promissing, i'm going to give it a try. Thank you very much
    | |
|  | |
| dwise   Newbie   Joined: 23 January 2008 Status: Offline Points: 6 |  Post Options  Thanks(0)  Quote  Reply  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! | |
|  | |
| ericl   Newbie   Joined: 06 February 2008 Location: France Status: Offline Points: 7 |  Post Options  Thanks(0)  Quote  Reply  Posted: 20 February 2008 at 1:08pm | 
| 
   Thanks to everyone, your posts helped me so much !
    | |
|  | |
| cetinbudak   Newbie     Joined: 24 January 2010 Location: Turkey Status: Offline Points: 1 |  Post Options  Thanks(0)  Quote  Reply  Posted: 24 January 2010 at 5:48pm | 
| 
   thank you very much dwise!... you saved my lots of time... 
    | |
|  | |
| Post Reply   | |
| Tweet | 
| Forum Jump | Forum Permissions  You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |