- Home
- Forum
- ASP.NET Web Forms (Classic)
- How to know what appointments to get from the DB
How to know what appointments to get from the DB
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.
SIGN IN To post a reply.
6 Replies
ES
Eswari S
Syncfusion Team
September 28, 2011 01:18 PM UTC
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
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
MB
Michael Bell
September 28, 2011 02:06 PM UTC
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?
MB
Michael Bell
September 28, 2011 08:18 PM UTC
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;
}
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;
}
YO
Yogeshwaran
Syncfusion Team
October 4, 2011 02:18 PM UTC
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.
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.
MD
Mike Dearman
December 1, 2011 03:21 PM UTC
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)
Dim aRenderDays As Date() = oSchedControl.GetRenderDays(oSchedControl.StartDate)
_dVisibleStartDate = aRenderDays(0)
_dVisibleEndDate = aRenderDays(aRenderDays.Length - 1)
SN
Sridhar N
Syncfusion Team
December 8, 2011 12:03 PM UTC
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
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
SIGN IN To post a reply.
- 6 Replies
- 5 Participants
-
MB Michael Bell
- Sep 27, 2011 09:32 PM UTC
- Dec 8, 2011 12:03 PM UTC