/// <summary> /// Bind a list of "start times" (OccurrenceTypeTemplate's StartTime values) /// for all the AttendanceTypes (OccurrenceTypes) for this group (Attendance Type Category). /// </summary> private void BindStartTimes() { OccurrenceTypeCollection occurrenceTypes = new OccurrenceTypeCollection(groupID); OccurrenceTypeTemplateCollection frequencies; Dictionary <string, string> times = new Dictionary <string, string>(); times.Add("*", string.Empty); foreach (OccurrenceType type in occurrenceTypes) { frequencies = new OccurrenceTypeTemplateCollection(type.OccurrenceTypeId); foreach (OccurrenceTypeTemplate frequency in frequencies) { string time = frequency.StartTime.ToShortTimeString(); if (!times.ContainsKey(time)) { times.Add(time, time); } } } ddlStartTimes.DataSource = times; ddlStartTimes.DataBind(); }
/// <summary> /// Used to custom bind related stuff such as the OccurrenceTypeAttributes, locations, etc. /// </summary> /// <param name="source"></param> /// <param name="e"></param> private void dgList_ItemDataBound(object source, DataGridItemEventArgs e) { switch (e.Item.ItemType) { case ListItemType.Item: case ListItemType.AlternatingItem: { DataRowView dataItem = (DataRowView)e.Item.DataItem; int attendanceTypeID = (int)dataItem["occurrence_type_id"]; CacheOTAs(attendanceTypeID); // set the start time column value(s) OccurrenceTypeTemplateCollection startTimes = new OccurrenceTypeTemplateCollection(attendanceTypeID); StringBuilder sb = new StringBuilder(); bool matchTime = false; bool oneTimeFlag = false; foreach (OccurrenceTypeTemplate ott in startTimes) { switch (ott.OccurrenceFreqType) { case OccurrenceFrequencyType.Daily: sb.Append("* "); sb.Append(ott.StartTime.ToShortTimeString() + seperator); break; case OccurrenceFrequencyType.Monthly: sb.Append("/" + ott.FreqQualifier + "/ "); sb.Append(ott.StartTime.ToShortTimeString() + seperator); break; case OccurrenceFrequencyType.OneTime: oneTimeFlag = true; DateTime ottDate = DateTime.Parse(ott.FreqQualifier); if (DateTime.Now.AddDays(-1) <= ottDate && ottDate <= DateTime.Now.AddDays(7 * OneTimeWindowWeeks)) { sb.Append(ott.FreqQualifier + " "); sb.Append(ott.StartTime.ToShortTimeString() + seperator); } break; case OccurrenceFrequencyType.Undefined: sb.Append(ott.StartTime.ToShortTimeString() + seperator); break; case OccurrenceFrequencyType.Weekly: sb.Append(Days[int.Parse(ott.FreqQualifier)] + " "); sb.Append(ott.StartTime.ToShortTimeString() + seperator); break; default: break; } // Filter by time if the filter is set if (matchTime != true && ott.StartTime.ToShortTimeString() == timeFilter) { matchTime = true; } lblOneTimeFreqNotice.Visible = oneTimeFlag; } // clean off the trailing seperator if (sb.Length > 0) { sb.Remove(sb.Length - seperator.Length, seperator.Length); } e.Item.Cells[2].Text = sb.ToString(); // Filter by time if the FILTER IS SET and we did not find a matching time // above when we were looping through all the occurrence type templates if (!timeFilter.Equals(string.Empty) && !matchTime) { e.Item.Visible = false; } else { filteredList.Add(dataItem); } // set the age column value if ((decimal)dataItem["max_age"] != 0) { e.Item.Cells[3].Text = String.Format("{0}-{1}", (decimal)dataItem["min_age"], (decimal)dataItem["max_age"]); } // set the grade column value if ((int)dataItem["min_grade"] != -1 && (int)dataItem["max_grade"] != -1) { if ((int)dataItem["min_grade"] == (int)dataItem["max_grade"]) { e.Item.Cells[4].Text = String.Format("{0}", (int)dataItem["min_grade"]).Replace('0', 'K'); } else { e.Item.Cells[4].Text = String.Format("{0}-{1}", (int)dataItem["min_grade"], (int)dataItem["max_grade"]).Replace('0', 'K'); } } // set the extended, Attribute column values if (cachedOTAs.ContainsKey(attendanceTypeID)) { OccurrenceTypeAttribute ota = cachedOTAs[attendanceTypeID]; // set the Ability level column value if (ota.AbilityLevelLookupIDs.Count == 0) { e.Item.Cells[5].Text = ""; } else { sb = new StringBuilder(); foreach (int abilityLevelID in ota.AbilityLevelLookupIDs) { sb.Append(new Lookup(abilityLevelID, true) + seperator); } // clean off the trailing seperator if (sb.Length > 0) { sb.Remove(sb.Length - seperator.Length, seperator.Length); } e.Item.Cells[5].Text = sb.ToString(); } // set the Special Needs column value if (!ota.IsSpecialNeeds) { e.Item.Cells[6].Text = ""; } // set the lastname letter range string lastNameRange = String.Format("{0}-{1}", ota.LastNameStartingLetter, ota.LastNameEndingLetter); if (lastNameRange.Length > 1) { e.Item.Cells[8].Text = lastNameRange; } else { e.Item.Cells[8].Text = ""; } } else { e.Item.Cells[6].Text = ""; } // set the Gender preference column if ((int)dataItem["gender_preference"] != 2) { e.Item.Cells[7].Text = (int)dataItem["gender_preference"] == 1 ? "F" : "M"; } // set the Location/Rooms column value sb = new StringBuilder(); LocationCollection locations = new LocationCollection(); locations.LoadByOccurrenceTypeID(attendanceTypeID); foreach (Location location in locations) { if (location.RoomClosed) { sb.Append("<del style='text-decoration: line-through; color: red;' title='closed'><span style='color:#000'>" + location.LocationName + "</span></del>" + seperator); } else { sb.Append(location.LocationName + seperator); } } if (sb.Length > 0) { sb.Remove(sb.Length - seperator.Length, seperator.Length); } e.Item.Cells[9].Text = sb.ToString(); break; } } }