Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - Problem adding events with multiple resources
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Problem adding events with multiple resources

 Post Reply Post Reply
Author
Message
zeko78 View Drop Down
Groupie
Groupie


Joined: 21 August 2006
Location: Norway
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote zeko78 Quote  Post ReplyReply Direct Link To This Post Topic: Problem adding events with multiple resources
    Posted: 22 August 2006 at 4:10am

Hi all,

I'm new to this control, and I'm trying to understand the MultipleResources stuff. I'm able to set up the calendar with multiple resources (thanks to some posts on the forum), but I'm not able to add events.
 
I'm using C# with the following code:
 
            String strConnectionString = @"Provider=XML;Data Source=c:\CalendarMultipleSchedulesSample.xtp_cal";
            CalendarResources resoures = new CalendarResources();
            CalendarResource res0 = new CalendarResource();
            CalendarResource res1 = new CalendarResource();
            res0.SetDataProvider2(strConnectionString, true);
            CalendarSchedules schedules = res0.DataProvider.Schedules;
            if (schedules.Count < 1) {
                schedules.AddNewSchedule("John");
                schedules.AddNewSchedule("Jane");
                res0.DataProvider.Save();
            }
 
            schedules[0].Id = 100;
            res0.Name = schedules[0].Name;
            res0.ScheduleIDs.Add(schedules[0].Id);
 
            schedules[1].Id = 101;
            res1.SetDataProvider(res0.DataProvider, false);
            res1.Name = schedules[1].Name;
            res1.ScheduleIDs.Add(schedules[1].Id);
 
            resoures.Add(res0);
            resoures.Add(res1);
     
            wndCalendarControl.SetMultipleResources(resoures);
            wndCalendarControl.Populate();
            wndCalendarControl.RedrawControl();
 
            //Add test event
            DateTime fromTime = DateTime.Now;
            DateTime toTime = new DateTime(2006, 8, 22, 11, 11, 11);
            CalendarEvent calEvent = res0.DataProvider.CreateEvent();
            calEvent.StartTime  = fromTime;
            calEvent.EndTime    = toTime;
            calEvent.Subject    = "Hallo";
            calEvent.ScheduleID = schedules[0].Id;
            res0.DataProvider.AddEvent(calEvent);

            wndCalendarControl.ActiveView.SetSelection(DateTime.Now, toTime, false);
            wndCalendarControl.Populate();
            wndCalendarControl.RedrawControl();
 
The code I'm struggeling with is the part after //Add test event
The event simply never appears in the calendar...
 
Could someone please point me in the right direction??
 
 
Best regards,
Gøran
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 22 August 2006 at 2:38pm
Hi ,

You forgot to open/create data provider:


.....
res0.SetDataProvider2(strConnectionString, true);
 
if (res0.DataProvider == null)
{
    return;
}
if (!res0.DataProvider.Open())
{
    if (!res0.DataProvider.Create())
    {
        return;
    }
}
 
.....


--
WBR,
Serge
Back to Top
zeko78 View Drop Down
Groupie
Groupie


Joined: 21 August 2006
Location: Norway
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote zeko78 Quote  Post ReplyReply Direct Link To This Post Posted: 22 August 2006 at 2:57pm
Doh!  (hand smacking forhead)
 
Now it works!! Thank you very much Serge..
 
Best regards,
Gøran
 
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.188 seconds.