protected void ViewMonth(HttpResponse Response, DateTime dtBegMonth, DateTime dtEndMonth) { GetData(); DateTime dtBegOfWeek = dtBegMonth.AddDays(1 - (int)dtBegMonth.Day); dtBegOfWeek = dtBegOfWeek.AddDays(-(int)dtBegOfWeek.DayOfWeek); DateTime dtEndOfWeek = dtBegOfWeek.AddDays(6); string Html = ""; if (fnBegCal != null) { Html += fnBegCal(); } // Month top Html += (fNewPage ? "<div style='page-break-before: always;'> </div>\n" : "") + WebPage.Tabs(0) + WebPage.Table("align='center' valign='top' class='CalSched'") + WebPage.Tabs(1) + "<tr><td colspan='" + (fShowTimeColumn ? 8 : 7) + "' align='center' class='RptNotice'>" + dtBegMonth.ToString("MMMM yyyy") + "</td></tr>\n" + WebPage.Tabs(1) + "<tr>\n" + (fShowTimeColumn ? WebPage.Tabs(2) + "<td align='center'>Time</td>\n" : ""); // days of the week DateTime dtDay = dtBegOfWeek; while (dtDay <= dtEndOfWeek) { Html += WebPage.Tabs(2) + "<td align='center'><b>" + dtDay.ToString("ddd") + "</b></td>\n"; dtDay = dtDay.AddDays(1); } Html += WebPage.Tabs(1) + "</tr>\n" + WebPage.Tabs(1) + "<tr>\n"; // min width for column dtDay = dtBegOfWeek; while (dtDay <= dtEndOfWeek) { Html += WebPage.Tabs(2) + "<td class='NoBorder'>" + WebPage.NoOp(80, 1) + "</td>\n"; dtDay = dtDay.AddDays(1); } Html += WebPage.Tabs(1) + "</tr>\n"; while (dtBegOfWeek < dtEndMonth) { DateTime tmBegBlockWeek = new DateTime(dtBegOfWeek.Year, dtBegOfWeek.Month, dtBegOfWeek.Day); DateTime tmEndBlockWeek = new DateTime(dtBegOfWeek.Year, dtBegOfWeek.Month, dtBegOfWeek.Day, tmBegDay.Hour, tmBegDay.Minute, 0); DateTime tmEndDayWeek = new DateTime(dtBegOfWeek.Year, dtBegOfWeek.Month, dtBegOfWeek.Day, tmEndDay.Hour, tmEndDay.Minute, 0); TimeSpan tsBlock = new TimeSpan(0, this.TimeBlock, 0); string sTime = "Before<br>" + tmEndBlockWeek.ToString("h:mmt").ToLower(); string sClass = "CalSched"; bool fFirstBlock = true; bool fLastBlock = false; while (!fLastBlock) { fLastBlock = (tmEndBlockWeek.Hour == 0); // last block of time will end at 00:00 of the next day Html += WebPage.Tabs(1) + "<tr>\n"; if (fShowTimeColumn) { Html += WebPage.Tabs(2) + "<td align='center' valign='top' class='" + sClass + "'>" + sTime + "</td>\n"; } dtDay = dtBegOfWeek; while (dtDay <= dtEndOfWeek) { dtDay = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, 0, 0, 0); DateTime tmBegBlockDay = dtDay; DateTime tmEndBlockDay = (tmBegBlockWeek.Day == tmEndBlockWeek.Day ? dtDay : dtDay.AddDays(1)); tmBegBlockDay = new DateTime(tmBegBlockDay.Year, tmBegBlockDay.Month, tmBegBlockDay.Day, tmBegBlockWeek.Hour, tmBegBlockWeek.Minute, 0); tmEndBlockDay = new DateTime(tmEndBlockDay.Year, tmEndBlockDay.Month, tmEndBlockDay.Day, tmEndBlockWeek.Hour, tmEndBlockWeek.Minute, 0); string sInRange = ""; string sEvent = (fFirstBlock ? WebPage.Tabs(3) + "<div align='right'>" + dtDay.Day + "</div>\n" : ""); if (dtDay.Month == dtBegMonth.Month && dtDay >= dtBeg && dtDay <= dtEnd) { int iEvent = FirstEvent(tmBegBlockDay, tmEndBlockDay); if (iEvent > -1) { while (iEvent > -1) { sEvent += (sEvent.Length > 0 ? WebPage.SpaceTable(1, 2) : "") + FormatEvent(iEvent); iEvent = NextEvent(iEvent, tmBegBlockDay, tmEndBlockDay); } } else { sEvent += WebPage.Tabs(3) + " \n"; } } else { sInRange = "Not"; sEvent += WebPage.Tabs(3) + " \n"; } Html += WebPage.Tabs(2) + "<td class='" + sClass + sInRange + "' valign='top'>\n" + sEvent + WebPage.Tabs(2) + "</td>\n"; dtDay = dtDay.AddDays(1); } Html += WebPage.Tabs(1) + "</tr>\n"; sClass = "CalSchedMid"; fFirstBlock = false; // 2 cases exist here, // the last block of time at the end of the normal day (tmEndDay) // or anytime before that if (tmEndBlockWeek >= tmEndDayWeek) { // last block of time for the day (after the End of Day time) tmBegBlockWeek = tmEndDayWeek; tmEndBlockWeek = new DateTime(dtBegOfWeek.Year, dtBegOfWeek.Month, dtBegOfWeek.Day).AddDays(1); sTime = tmBegBlockWeek.ToString("h:mmt").ToLower() + "<br>& After"; } else { tmBegBlockWeek = tmEndBlockWeek; tmEndBlockWeek += tsBlock; sTime = tmBegBlockWeek.ToString("h:mmt").ToLower(); } Debug.WriteLine("BegBlockWeek " + tmBegBlockWeek.ToString()); Debug.WriteLine("EndBlockWeek " + tmEndBlockWeek.ToString()); } dtBegOfWeek = dtEndOfWeek.AddDays(1); dtEndOfWeek = dtBegOfWeek.AddDays(6); } Html += WebPage.Tabs(0) + WebPage.TableEnd(); if (fnEndCal != null) { Html += fnEndCal(); } Response.Write(Html); }
protected void ViewWeek(HttpResponse Response) { GetData(); string Html = ""; if (fnBegCal != null) { Html += fnBegCal(); } DateTime dtBegOfWeek = dtBeg; Html = WebPage.Tabs(0) + WebPage.Table("align='center' class='CalSched'") + WebPage.Tabs(1) + "<tr>\n"; if (fShowTimeColumn) { Html += WebPage.Tabs(2) + "<td align='center'>Time</td>\n"; } // days of the week DateTime dtDay = dtBeg; while (dtDay <= dtEnd) { Html += WebPage.Tabs(2) + "<td align='center'><b>" + dtDay.ToString("MM/dd<br>ddd") + "</b></td>\n"; dtDay = dtDay.AddDays(1); } Html += WebPage.Tabs(1) + "</tr>\n" + WebPage.Tabs(1) + "<tr>\n"; // min width for column dtDay = dtBeg; while (dtDay <= dtEnd) { Html += WebPage.Tabs(2) + "<td class='NoBorder'>" + WebPage.NoOp(80, 1) + "</td>\n"; dtDay = dtDay.AddDays(1); } Html += WebPage.Tabs(1) + "</tr>\n"; DateTime tmBegBlockWeek = new DateTime(dtBegOfWeek.Year, dtBegOfWeek.Month, dtBegOfWeek.Day); DateTime tmEndBlockWeek = new DateTime(dtBegOfWeek.Year, dtBegOfWeek.Month, dtBegOfWeek.Day, tmBegDay.Hour, tmBegDay.Minute, 0); DateTime tmEndDayWeek = new DateTime(dtBegOfWeek.Year, dtBegOfWeek.Month, dtBegOfWeek.Day, tmEndDay.Hour, tmEndDay.Minute, 0); TimeSpan tsBlock = new TimeSpan(0, this.TimeBlock, 0); string sTime = "Before<br>" + tmEndBlockWeek.ToString("h:mmt").ToLower(); string sClass = "CalSched"; bool fLastBlock = false; while (!fLastBlock) { fLastBlock = (tmEndBlockWeek.Hour == 0); // last block of time will end at 00:00 of the next day Html += WebPage.Tabs(1) + "<tr>\n"; if (fShowTimeColumn) { Html += WebPage.Tabs(2) + "<td align='center' valign='top' class='" + sClass + "'>" + sTime + "</td>\n"; } dtDay = dtBeg; while (dtDay <= dtEnd) { dtDay = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, 0, 0, 0); DateTime tmBegBlockDay = dtDay; DateTime tmEndBlockDay = (tmBegBlockWeek.Day == tmEndBlockWeek.Day ? dtDay : dtDay.AddDays(1)); tmBegBlockDay = new DateTime(tmBegBlockDay.Year, tmBegBlockDay.Month, tmBegBlockDay.Day, tmBegBlockWeek.Hour, tmBegBlockWeek.Minute, 0); tmEndBlockDay = new DateTime(tmEndBlockDay.Year, tmEndBlockDay.Month, tmEndBlockDay.Day, tmEndBlockWeek.Hour, tmEndBlockWeek.Minute, 0); string sEvent = ""; int iEvent = FirstEvent(tmBegBlockDay, tmEndBlockDay); if (iEvent > -1) { while (iEvent > -1) { sEvent += (sEvent.Length > 0 ? WebPage.SpaceTable(1, 2) : "") + FormatEvent(iEvent); iEvent = NextEvent(iEvent, tmBegBlockDay, tmEndBlockDay); } } else { sEvent = WebPage.Tabs(3) + " \n"; } Html += WebPage.Tabs(2) + "<td class='" + sClass + "' valign='top'>\n" + sEvent + WebPage.Tabs(2) + "</td>\n"; dtDay = dtDay.AddDays(1); } Html += WebPage.Tabs(1) + "</tr>\n"; sClass = "CalSchedMid"; // 2 cases exist here, // the last block of time at the end of the normal day (tmEndDay) // or anytime before that if (tmEndBlockWeek >= tmEndDayWeek) { // last block of time for the day (after the End of Day time) tmBegBlockWeek = tmEndDayWeek; tmEndBlockWeek = new DateTime(dtBegOfWeek.Year, dtBegOfWeek.Month, dtBegOfWeek.Day).AddDays(1); sTime = tmBegBlockWeek.ToString("h:mmt").ToLower() + "<br>& After"; } else { tmBegBlockWeek = tmEndBlockWeek; tmEndBlockWeek += tsBlock; sTime = tmBegBlockWeek.ToString("h:mmt").ToLower(); } Debug.WriteLine("BegBlockWeek " + tmBegBlockWeek.ToString()); Debug.WriteLine("EndBlockWeek " + tmEndBlockWeek.ToString()); } Html += WebPage.Tabs(0) + WebPage.TableEnd(); if (fnEndCal != null) { Html += fnEndCal(); } Response.Write(Html); }