GetAppointmentsForPeriod() question
Posted: Thu Sep 05, 2013 7:19 pm
I was a bit confuse with this function as it always give me empty list result:
I think the checking condition may be the problem as it's always true. It should be "end" rather than "start", shouldn't it?
Cheers
M
Code: Select all
public static List<Appointment> GetAppointmentsForPeriod(DateTime start,DateTime end) {
if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
return Meth.GetObject<List<Appointment>>(MethodBase.GetCurrentMethod(),start,end);
}
string command="SELECT * FROM appointment WHERE ";
command+="AptDateTime >= "+POut.DateT(start.Date);//to check to see if an appointment scheduled beforehand overlaps this time segment
command+="AND AptDateTime <= "+POut.DateT(end);
List<Appointment> retVal = Crud.AppointmentCrud.TableToList(Db.GetTable(command));
for(int i=retVal.Count-1;i>=0;i--) {
if(retVal[i].AptDateTime.AddMinutes(retVal[i].Pattern.Length*PrefC.GetInt(PrefName.AppointmentTimeIncrement))>start) {
retVal.RemoveAt(i);
}
}
return retVal;
}Cheers
M