While the following works for any time during an appoint ment i need to disable the times before a shift but its not working the way that it should do;.
001.
protected
void
apertureAppointments_TimeSlotCreated(
object
sender, TimeSlotCreatedEventArgs e)
002.
{
003.
int
i = 0;
004.
bool
isFound =
false
;
005.
List<tblApertureNetShiftPattern> _list =
new
List<tblApertureNetShiftPattern>();
006.
_list = _dal.getHolidays();
007.
List<Resource> resources =
new
List<Resource>(apertureAppointments.Resources.GetResourcesByType(
"Managers"
));
008.
Label slotlabel =
new
Label();
009.
010.
foreach
(tblApertureNetShiftPattern sp
in
_list)
011.
{
012.
DateTime dt1 = Convert.ToDateTime(sp.startdate);
013.
DateTime dt2 = Convert.ToDateTime(sp.endDate);
014.
015.
016.
if
(e.TimeSlot.Start <= dt1 && e.TimeSlot.Resource.Text == sp.manager_name)
017.
018.
{
019.
020.
e.TimeSlot.CssClass =
"Disabled"
;
021.
slotlabel.CssClass =
"Disabled"
;
022.
023.
}
024.
025.
if
(e.TimeSlot.Start >= dt1 && e.TimeSlot.End <= dt2 && e.TimeSlot.Resource.Text == sp.manager_name)
026.
{
027.
028.
if
(DoDateRangesOverlap(e.TimeSlot.Start, e.TimeSlot.End, dt1, dt2))
029.
{
030.
031.
032.
if
(sp.appointmentType ==Constants.shiftsStartOfShift)
033.
{
034.
035.
e.TimeSlot.CssClass =
"Disabled"
;
036.
slotlabel.CssClass =
"Disabled"
;
037.
038.
}
039.
040.
if
(sp.appointmentType == Constants.shiftStat)
041.
{
042.
e.TimeSlot.CssClass =
"Disabled"
;
043.
slotlabel.CssClass =
"Disabled"
;
044.
045.
}
046.
047.
if
(sp.appointmentType == Constants.shfitsLunch)
048.
{
049.
e.TimeSlot.CssClass =
"shiftlunchOff"
;
050.
slotlabel.CssClass =
"shiftlunchOff"
;
051.
if
(i == 1)
052.
{
053.
slotlabel.Text =
"Lunch"
;
054.
055.
Image imageControl =
new
Image();
056.
// imageControl.ImageUrl = @"~\images\aperturenet\Calendar\resources\holidays.png";
057.
// e.TimeSlot.Control.Controls.AddAt(1, imageControl);
058.
059.
}
060.
}
061.
if
(sp.appointmentType == Constants.shiftDayoff)
062.
{
063.
e.TimeSlot.CssClass =
"shiftDayOff"
;
064.
065.
slotlabel.CssClass =
"shiftDayOff"
;
066.
067.
if
(i == 1)
068.
{
069.
slotlabel.Text =
"Off test"
;
070.
Image imageControl =
new
Image();
071.
imageControl.ImageUrl = @
"~\images\aperturenet\Calendar\resources\holidays.png"
;
072.
e.TimeSlot.Control.Controls.AddAt(1, imageControl);
073.
}
074.
}
075.
else
if
(sp.appointmentType == Constants.shiftHoliday)
076.
{
077.
e.TimeSlot.CssClass =
"HolidayCssStyle"
;
078.
slotlabel.CssClass =
"HolidayCssStyle"
;
079.
080.
if
(i == 1)
081.
{
082.
slotlabel.Text =
"Off"
;
083.
Image imageControl =
new
Image();
084.
imageControl.ImageUrl = @
"~\images\aperturenet\Calendar\resources\holidays.png"
;
085.
e.TimeSlot.Control.Controls.AddAt(1, imageControl);
086.
}
087.
}
088.
else
if
(sp.appointmentType == Constants.shiftStat)
089.
{
090.
e.TimeSlot.CssClass =
"statCssStyle"
;
091.
slotlabel.CssClass =
"statCssStyle"
;
092.
slotlabel.Text =
"Off"
;
093.
if
(i == 1)
094.
{
095.
Image imageControl =
new
Image();
096.
imageControl.ImageUrl = @
"~\images\aperturenet\Calendar\resources\holidays.png"
;
097.
e.TimeSlot.Control.Controls.AddAt(1, imageControl);
098.
}
099.
}
100.
else
if
(sp.appointmentType == Constants.shiftsickDay)
101.
{
102.
103.
e.TimeSlot.CssClass =
"SickDayStyle"
;
104.
slotlabel.CssClass =
"SickDayStyle"
;
105.
106.
if
(i == 1)
107.
{
108.
slotlabel.Text =
"Sick"
;
109.
Image imageControl =
new
Image();
110.
imageControl.ImageUrl = @
"~\images\aperturenet\Calendar\resources\Sick.png"
;
111.
e.TimeSlot.Control.Controls.AddAt(1, imageControl);
112.
}
113.
114.
115.
}
116.
117.
else
118.
i = i++;
119.
e.TimeSlot.Control.Controls.AddAt(1, slotlabel);
120.
dt2 = dt2.AddMinutes(60);
121.
}
122.
}
123.
}
124.
}
Basically all that get holidays do is return the shift patters for the resource
01.
public
List<tblApertureNetShiftPattern> getHolidays()
02.
{
03.
List<tblApertureNetShiftPattern> list =
new
List<tblApertureNetShiftPattern>();
04.
05.
var q = from _holidays
in
apertureNetEntities.tblApertureNetShiftPatterns.Where(w => w.isDeleted ==
false
)
06.
select _holidays;
07.
08.
list = q.ToList();
09.
10.
return
list;
11.
}
But as you can see from the second screen shot its filling out every timeslot before that time not just the 9 am to 11 am as it should be in realtion to the database I only use the appointment end type where the appointment type equals a sepcified guid.