Пример #1
0
        private void RenderWeeklySummary(HtmlTextWriter output)
        {
            if (attendance.Count == 0)
            {
                return;
            }

            int entryIndex = 0;

            // Variable to hold the current working entry
            DojoAttendanceEntry entry = attendance[entryIndex];

            // Variable to hold first and last class dates to start and stop the loop
            DojoAttendanceEntry lastEntry = attendance[attendance.Count - 1];

            // Variables for holding the first date of each week
            DateTime currentFirstDayOfWeek  = DateManipulator.FirstOfWeek(entry.Class.ClassStart);
            DateTime previousFirstDayOfWeek = currentFirstDayOfWeek - TimeSpan.FromDays(7);

            // Set hit counters to -1 to inform loop on first run
            int beginnerHits = 0;
            int mudanshaHits = 0;
            int yudanshaHits = 0;
            int totalHits    = 0;

            while (entry != lastEntry)
            {
                while (entry.Class.ClassStart > currentFirstDayOfWeek)
                {
                    // Increment Counters
                    totalHits++;

                    if (entry.Rank.ID == 1)
                    {
                        beginnerHits++;
                    }
                    if (entry.Rank.IsMudansha)
                    {
                        mudanshaHits++;
                    }
                    if (entry.Rank.IsYudansha)
                    {
                        yudanshaHits++;
                    }

                    entryIndex++;

                    if (entryIndex < attendance.Count)
                    {
                        entry = attendance[entryIndex];
                    }
                    else
                    {
                        break;
                    }
                }

                renderWeeklySummary(output, this.DefaultRowCssClass,
                                    currentFirstDayOfWeek,
                                    DateManipulator.LastOfWeek(currentFirstDayOfWeek),
                                    beginnerHits, mudanshaHits, yudanshaHits, totalHits);

                // Reset Counters
                beginnerHits = 0;
                mudanshaHits = 0;
                yudanshaHits = 0;
                totalHits    = 0;

                currentFirstDayOfWeek  = previousFirstDayOfWeek;
                previousFirstDayOfWeek = currentFirstDayOfWeek - TimeSpan.FromDays(7);
            }
        }
Пример #2
0
        /// <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;
            }
        }
Пример #3
0
        private void RenderView(HtmlTextWriter output, bool showWeeklyIndex)
        {
            // Variables for holding the days of a week
            DateTime currentIndexDate = DateTime.MinValue;
            DateTime lastIndexDate    = DateTime.MinValue;

            bool   rowflag = false;
            string rowCssClass;

            //
            // Render Records
            //
            foreach (DojoAttendanceEntry entry in attendance)
            {
                #region Render Indexing

                // Render Week Headers
                if (showWeeklyIndex)
                {
                    // Set the first and last day of week for the current entry
                    currentIndexDate = DateManipulator.FirstOfWeek(entry.Class.ClassStart);

                    if (lastIndexDate != currentIndexDate)
                    {
                        output.WriteFullBeginTag("tr");
                        output.WriteBeginTag("td");
                        output.WriteAttribute("class", indexRowCssClass);
                        output.WriteAttribute("colspan", "8");
                        output.Write(HtmlTextWriter.TagRightChar);
                        output.Write(currentIndexDate.ToLongDateString());
                        output.Write(" - ");
                        output.Write(DateManipulator.LastOfWeek(currentIndexDate).ToLongDateString());
                        output.WriteEndTag("td");
                        output.WriteEndTag("tr");

                        lastIndexDate = currentIndexDate;
                    }
                }
                else
                {
                    currentIndexDate = entry.Class.ClassStart.Date;

                    if (currentIndexDate != lastIndexDate)
                    {
                        output.WriteFullBeginTag("tr");
                        output.WriteBeginTag("td");
                        output.WriteAttribute("valign", "top");
                        output.WriteAttribute("colspan", "4");
                        output.WriteAttribute("class", indexRowCssClass);
                        output.Write(HtmlTextWriter.TagRightChar);
                        output.Write(currentIndexDate.ToLongDateString());
                        output.WriteEndTag("td");
                        output.WriteEndTag("tr");

                        lastIndexDate = currentIndexDate;
                    }
                }

                #endregion

                // Flip Rowstate
                if (rowflag)
                {
                    rowCssClass = this.defaultRowCssClass;
                }
                else
                {
                    rowCssClass = this.alternateRowCssClass;
                }
                rowflag = !rowflag;

                renderEntry(output, rowCssClass, entry);
            }
        }
Пример #4
0
        /// <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();
            }
        }