public void LoadActivities(int Month, int Year) { _Activities.Clear(); Activity activity = new Activity(); _dtActivities = activity.GetByMonth(Month, Year); foreach (Shiloh.BL.Shiloh.activityRow row in _dtActivities.Rows) { sActivity act = new sActivity(); act.Id = row.ID; act.Name = row.name; act.Description = row.description; act.StartDate = row.activityStart; act.EndDate = row.activityEnd; // add to the list of activities for the day AddActivity(act.StartDate, act); // if this is a date range then add an event for each day in the range int dayRange = Math.Abs(act.EndDate.Subtract(act.StartDate).Days); if (dayRange > 0) { for (double i = 1; i <= dayRange; i++) { AddActivity(act.StartDate.AddDays(i), act); } } } }
protected void BindEventList() { int activityCount = 0; Activity activity = new Activity(); _dtActivities = activity.GetByMonth(DateTime.Now.Month, DateTime.Now.Year); //_dtActivities = LoadDummyActvities(); List<Shiloh.BL.Shiloh.activityRow> shortList = new List<Shiloh.BL.Shiloh.activityRow>(); if (_dtActivities != null) { foreach (Shiloh.BL.Shiloh.activityRow row in _dtActivities.Rows) { if (activityCount < 2) { if (row.activityEnd.CompareTo(DateTime.Now.Date) >= 0) { shortList.Add(row); activityCount += 1; } } else break; } // flip header and footer status if (shortList.Count > 0) { pnlEvents.Visible = true; pnlFallback.Visible = false; } else { pnlEvents.Visible = false; pnlFallback.Visible = true; } dlEvents.DataSource = shortList; dlEvents.DataBind(); } }