/// <summary> /// Render this control to the output parameter specified. /// </summary> /// <param name="output"> The HTML writer to write out to </param> protected override void RenderContent(HtmlTextWriter output) { EnsureChildControls(); DojoAttendanceEntryFlags[] options = new DojoAttendanceEntryFlags[] { DojoAttendanceEntryFlags.Class, DojoAttendanceEntryFlags.Member, DojoAttendanceEntryFlags.Rank, DojoAttendanceEntryFlags.MemberPrivateContact }; DojoAttendanceEntryManager m = new DojoAttendanceEntryManager(); StringBuilder whereQuery = new StringBuilder(); if (ddMembers.SelectedItem.Value != "-1") { whereQuery.Append("MemberID="); whereQuery.Append(ddMembers.SelectedItem.Value); } if (ddClassDefinitions.SelectedItem.Value != "-1") { if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } if (ddClassDefinitions.SelectedItem.Value == "0") { whereQuery.Append("ParentDefinitionID=null"); } else { whereQuery.Append("ParentDefinitionID="); whereQuery.Append(ddClassDefinitions.SelectedItem.Value); } } if (ddInstructors.SelectedItem.Value != "-1") { if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("kitTessen_Classes.InstructorID="); whereQuery.Append(ddInstructors.SelectedItem.Value); } switch (ddSearchMode.SelectedItem.Text) { case "Today": // today if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(LocalTime.Date); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(LocalTime.Date.AddDays(1)); whereQuery.Append("#)"); break; case "This Month": if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date)); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date).AddMonths(1)); whereQuery.Append("#)"); break; case "Last Month": if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(DateManipulator.SubtractMonths(LocalTime.Date, 1)); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date)); whereQuery.Append("#)"); break; case "This Week": if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(DateManipulator.FirstOfWeek(LocalTime.Date)); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(DateManipulator.LastOfWeek(LocalTime.Date).AddDays(1)); whereQuery.Append("#)"); break; case "Last Week": if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(DateManipulator.FirstOfWeek(LocalTime.Date).Subtract(TimeSpan.FromDays(7))); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(DateManipulator.LastOfWeek(LocalTime.Date).Subtract(TimeSpan.FromDays(6))); whereQuery.Append("#)"); break; } attendance = m.GetCollection(whereQuery.ToString(), "ClassStart DESC", options); switch (ddView.SelectedItem.Value) { case "default": RenderView(output, false); break; case "weekly": RenderView(output, true); break; case "weeklysummary": RenderWeeklySummary(output); break; } }
/// <summary> /// Render this control to the output parameter specified. /// </summary> /// <param name="output"> The HTML writer to write out to </param> protected override void RenderContent(HtmlTextWriter output) { EnsureChildControls(); StringBuilder whereQuery = new StringBuilder(); DojoClassManager m = new DojoClassManager(); // // Qualify Parent Definition Selection in Query // if (parentDefinitionID == 0) { whereQuery.Append("(ParentDefinitionID=null OR ParentDefinitionID=0) "); } else if (parentDefinitionID > 0) { whereQuery.Append("ParentDefinitionID=" + parentDefinitionID.ToString() + ") "); } // // Qualify Parent Seminar Selection in Query // if (parentSeminarID == 0) { if (whereQuery.Length > 0) { whereQuery.Append("AND (ParentSeminarID=null OR ParentSeminarID=0) "); } else { whereQuery.Append("(ParentSeminarID=null OR ParentSeminarID=0) "); } } else if (parentSeminarID > 0) { whereQuery.Append("(ParentSeminarID=" + parentSeminarID.ToString() + ") "); } switch (ddSearchMode.SelectedItem.Text) { case "Today": // today if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(LocalTime.Date); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(LocalTime.Date.AddDays(1)); whereQuery.Append("#)"); break; case "This Month": if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date)); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date).AddMonths(1)); whereQuery.Append("#)"); break; case "Last Month": if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(DateManipulator.SubtractMonths(DateManipulator.FirstOfMonth(LocalTime.Date), 1)); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date)); whereQuery.Append("#)"); break; case "This Week": if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(DateManipulator.FirstOfWeek(LocalTime.Date)); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(DateManipulator.LastOfWeek(LocalTime.Date).AddDays(1)); whereQuery.Append("#)"); break; case "Last Week": if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(DateManipulator.FirstOfWeek(LocalTime.Date).Subtract(TimeSpan.FromDays(7))); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(DateManipulator.LastOfWeek(LocalTime.Date).Subtract(TimeSpan.FromDays(6))); whereQuery.Append("#)"); break; case "This Year": if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(DateTime.Parse("1/1/" + LocalTime.Date.Year.ToString())); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(DateTime.Parse("1/1/" + (LocalTime.Date.Year + 1).ToString())); whereQuery.Append("#)"); break; } if (cbSeminarFilter.Checked) { if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("ParentSeminarID IS NOT NULL"); } DojoClassCollection dojoClassCollection = m.GetCollection(whereQuery.ToString(), "ClassStart ASC", new DojoClassFlags[] { DojoClassFlags.Instructor, DojoClassFlags.InstructorPrivateContact }); bool rowflag = false; string rowCssClass; string currentIndex = string.Empty; string previousIndex = string.Empty; // // Render Records // foreach (DojoClass entry in dojoClassCollection) { #region Index Rows Rendering currentIndex = entry.ClassStart.ToLongDateString(); if (currentIndex != previousIndex) { output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("valign", "top"); output.WriteAttribute("colspan", "4"); output.WriteAttribute("class", indexRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write(currentIndex); output.WriteEndTag("td"); output.WriteEndTag("tr"); previousIndex = currentIndex; } #endregion if (rowflag) { rowCssClass = this.defaultRowCssClass; } else { rowCssClass = this.alternateRowCssClass; } rowflag = !rowflag; output.WriteBeginTag("tr"); output.WriteAttribute("i", entry.ID.ToString()); output.WriteLine(HtmlTextWriter.TagRightChar); output.Indent++; // // Render Main Representation of Record // output.WriteBeginTag("td"); output.WriteAttribute("valign", "top"); output.WriteAttribute("class", rowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.WriteFullBeginTag("strong"); output.Write(entry.Name); output.WriteEndTag("strong"); output.Write("<br>"); output.Write(entry.Instructor.PrivateContact.FullName); output.WriteEndTag("td"); output.WriteLine(); // // Render Class Start and End Dates // output.WriteBeginTag("td"); output.WriteAttribute("class", rowCssClass); output.WriteAttribute("valign", "top"); output.Write(HtmlTextWriter.TagRightChar); // output.Write(entry.ClassStart.ToLongDateString()); // output.Write("<br />"); output.Write(entry.ClassStart.ToShortTimeString()); output.Write(" - "); output.Write(entry.ClassEnd.ToShortTimeString()); output.WriteEndTag("td"); output.WriteLine(); output.Indent--; output.WriteEndTag("tr"); output.WriteLine(); } }