Print Page | Close Window

Problem adding events with multiple resources

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=4847
Printed Date: 22 November 2024 at 4:58pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Problem adding events with multiple resources
Posted By: zeko78
Subject: Problem adding events with multiple resources
Date 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



Replies:
Posted By: sserge
Date 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


Posted By: zeko78
Date Posted: 22 August 2006 at 2:57pm
Doh!  (hand smacking forhead)
 
Now it works!! Thank you very much Serge..
 
Best regards,
Gøran
 



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