We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to know what appointments to get from the DB

Thread ID:

Created:

Updated:

Platform:

Replies:

101126 Sep 27,2011 05:32 PM Dec 8,2011 07:03 AM ASP.NET Web Forms (Classic) 6
loading
Tags: Schedule
Michael Bell
Asked On September 27, 2011 05:32 PM

in our application i only want to query the DB for appointments that will be showing the current view. We have written our own custom service to fetch the data but are looking for a way to tell what start date and end date we should pass to our query so that we only get appointment data for the days that will be shown by the scheduler.


Eswari S [Syncfusion]
Replied On September 28, 2011 09:18 AM

Hi Michael,

Thank you for using Syncfusion products.

Your requirement can be achieved by checking the condition with ScheduleViewType startdate ,end date with appointment start and end date.

Please refer to the following code snippets :

protected void Page_Load(object sender, EventArgs e)
{
var startdate = DateTime.Now;
var enddate = DateTime.Now;
ScheduleWebAppointmentList arr = Schedule1.Appointments;
if (Schedule1.ScheduleType == ScheduleViewType.Week)
{
startdate = Schedule1.StartDate;
enddate = startdate.AddDays(7); // as it is week ,end date will be 7 days later

}
else if (Schedule1.ScheduleType == ScheduleViewType.Month)
{
startdate = Schedule1.StartDate;
enddate = startdate.AddMonths(1); // as it is week ,end date will be one month later

}
else if (Schedule1.ScheduleType == ScheduleViewType.Day)
{
startdate = Schedule1.StartDate;
enddate = startdate.AddDays(0);
}
else if (Schedule1.ScheduleType == ScheduleViewType.WorkWeek)
{
startdate = Schedule1.StartDate;
enddate = startdate.AddDays(5);
}
ArrayList currentViewAppointments = new ArrayList();
foreach (ScheduleWebAppointment obj in arr)
{
if (obj.StartTime >= startdate && obj.EndTime <= enddate)
{
currentViewAppointments.Add(obj); // you can get the current view appoitments list
}
}
}

For your conveniance, we have prepared the sample and the same can be downloaded from the following link :

Sample-1202204828.zip

Please try this and let us know if you have any queries.

Regards,
Eswari.S




Michael Bell
Replied On September 28, 2011 10:06 AM

I would agree with this, however for some reason my startdate property does not change values when i navigate to the next work week or month. Any thoughts on why this would be the case?


Michael Bell
Replied On September 28, 2011 04:18 PM

I resolved this by overriding the OnStartDateChanged and calling the base followed by databind. This seems to have the correct start date as the overriden call to DataBind gets called in several places. The only issue im running into is that DataBind is getting called twice for every calendar navigation.

Also i updated the code snippet you posted to get the date range:

DateTime? startDate = null;
DateTime? endDate = null;
int diff;

switch(this.ScheduleType)
{
case ScheduleViewType.Day:
startDate = this.StartDate.Date;
endDate = startDate.Value.AddDays(1);
break;
case ScheduleViewType.WorkWeek:
diff = this.StartDate.DayOfWeek - DayOfWeek.Monday;
if (diff < 0)
diff += 7;
startDate = this.StartDate.AddDays(-1 * diff).Date;
endDate = startDate.Value.AddDays(5);
break;
case ScheduleViewType.Week:
diff = this.StartDate.DayOfWeek - DayOfWeek.Sunday;
if (diff < 0)
diff += 7;
startDate = this.StartDate.AddDays(-1 * diff).Date;
endDate = startDate.Value.AddDays(7);
break;
case ScheduleViewType.Month:
startDate = new DateTime(this.StartDate.Year, this.StartDate.Month, 1);
endDate = startDate.Value.AddMonths(1);
break;
}



Yogeshwaran [Syncfusion]
Replied On October 4, 2011 10:18 AM

Hi Michael,

Thanks for your update.

Before we start providing the solution, we would like to hear more details to reproduce the issue since we are unable to get the details of the issue from your last update. Could you please modify the below sample to reproduce your issue and send back to us to sort out the issue and provide you with the solution? The information provided would be of great help in resolving the issue.

For your convenience,we have created sample for your reference and can be downloaded from below link:

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=DataBindSample514735498.zip

Please let me know if you have any concerns.

Regards,
Yogesh.


Mike Dearman
Replied On December 1, 2011 10:21 AM

I was able to use the GetRenderDays method within the PreRender event:

Dim aRenderDays As Date() = oSchedControl.GetRenderDays(oSchedControl.StartDate)
_dVisibleStartDate = aRenderDays(0)
_dVisibleEndDate = aRenderDays(aRenderDays.Length - 1)



Sridhar N [Syncfusion]
Replied On December 8, 2011 07:03 AM

Hi Mike,

Thanks for your update.

Yes you can use GetRenderDays in Schedule PreRender event.

Please let us know if you have any other concerns so that we will be happy to help you out.

Regards,
Sridhar N


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;