protected void Page_Load(object sender, EventArgs e)
        {
            ItemGuid = ParmParser.GetGuidIDFromQuery();

            btnCopyButton.Visible   = !(ItemGuid == Guid.Empty);
            btnDeleteButton.Visible = !(ItemGuid == Guid.Empty);
            btnCopy.Visible         = !(ItemGuid == Guid.Empty);
            btnDelete.Visible       = !(ItemGuid == Guid.Empty);

            if (!IsPostBack)
            {
                CalendarHelper.BindRepeater(rpDays, CalendarHelper.DaysOfTheWeek);

                Dictionary <Guid, string> colors = (from c in CalendarHelper.GetCalendarCategories(SiteID)
                                                    select new KeyValuePair <Guid, string>(c.CalendarEventCategoryID, string.Format("{0}|{1}", c.CategoryBGColor, c.CategoryFGColor)))
                                                   .ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

                CalendarHelper.BindDropDownList(ddlColors, colors);

                var freq = CalendarFrequencyHelper.GetCalendarFrequencies();
                var cat  = CalendarHelper.GetCalendarCategories(SiteID);

                txtEventStartDate.Text = SiteData.CurrentSite.Now.ToShortDateString();
                txtEventEndDate.Text   = SiteData.CurrentSite.Now.ToShortDateString();

                CalendarHelper.BindDropDownList(ddlRecurr, freq, CalendarFrequencyHelper.GetIDByFrequencyType(CalendarFrequencyHelper.FrequencyType.Once).ToString());
                CalendarHelper.BindDropDownList(ddlCategory, cat);

                var itm = CalendarHelper.GetProfile(ItemGuid);

                if (itm != null)
                {
                    selectedDatePattern = itm.EventRepeatPattern;
                    CalendarHelper.BindRepeater(rpDays, CalendarHelper.DaysOfTheWeek);

                    txtEventTitle.Text = itm.EventTitle;
                    reContent.Text     = itm.EventDetail;

                    chkIsPublic.Checked          = itm.IsPublic;
                    chkIsAllDayEvent.Checked     = itm.IsAllDayEvent;
                    chkIsCancelled.Checked       = itm.IsCancelled;
                    chkIsCancelledPublic.Checked = itm.IsCancelledPublic;

                    txtEventStartDate.Text = itm.EventStartDate.ToShortDateString();
                    txtEventEndDate.Text   = itm.EventEndDate.ToShortDateString();

                    txtRecursEvery.Text = itm.RecursEvery.ToString();

                    CalendarHelper.SetTextboxToTimeSpan(txtEventStartTime, itm.EventStartTime);
                    CalendarHelper.SetTextboxToTimeSpan(txtEventEndTime, itm.EventEndTime);

                    ddlRecurr.SelectedValue   = itm.CalendarFrequencyID.ToString();
                    ddlCategory.SelectedValue = itm.CalendarEventCategoryID.ToString();
                }
            }
        }
        protected void SetCalendar()
        {
            SiteData site = SiteData.CurrentSite;

            DateTime dtStart = Calendar1.CalendarDate.AddDays(1 - Calendar1.CalendarDate.Day).Date;
            DateTime dtEnd   = dtStart.AddMonths(1).Date;

            dtStart = site.ConvertSiteTimeToUTC(dtStart);
            dtEnd   = site.ConvertSiteTimeToUTC(dtEnd);

            List <vw_carrot_CalendarEvent> lst = null;

            using (CalendarDataContext db = CalendarDataContext.GetDataContext()) {
                lst = (from c in db.vw_carrot_CalendarEvents
                       where c.EventDate >= dtStart &&
                       c.EventDate < dtEnd &&
                       c.SiteID == SiteID &&
                       c.IsPublic == true &&
                       (!c.IsCancelledEvent || c.IsCancelledPublic) &&
                       (!c.IsCancelledSeries || c.IsCancelledPublic)
                       orderby c.EventDate ascending, c.EventStartTime ascending, c.IsCancelledEvent ascending
                       select c).ToList();
            }

            lst.ForEach(x => x.EventDate = site.ConvertUTCToSiteTime(x.EventDate));

            List <DateTime> dates = (from dd in lst select dd.EventDate.Date).Distinct().ToList();

            List <Guid> cats = (from dd in lst select dd.CalendarEventCategoryID).Distinct().ToList();

            Calendar1.HilightDateList = dates;

            CalendarHelper.BindRepeater(rpEvent, lst);

            if (lst.Count > 0)
            {
                phNone.Visible = false;
            }
            else
            {
                phNone.Visible = true;
            }

            SetDDLSelections();

            CalendarHelper.BindRepeater(rpCat, CalendarHelper.GetCalendarCategories(SiteID).Where(x => cats.Contains(x.CalendarEventCategoryID)));
        }
Esempio n. 3
0
        protected void SetCalendar()
        {
            SiteData site = SiteData.CurrentSite;

            DateTime dtStart = DateTime.Now.AddDays(DaysInPast).Date;
            DateTime dtEnd   = DateTime.Now.AddDays(DaysInFuture).Date;

            dtStart = site.ConvertSiteTimeToUTC(dtStart);
            dtEnd   = site.ConvertSiteTimeToUTC(dtEnd);

            using (CalendarDataContext db = CalendarDataContext.GetDataContext()) {
                var lst = (from c in db.vw_carrot_CalendarEvents
                           where c.EventDate >= dtStart &&
                           c.EventDate <= dtEnd &&
                           c.SiteID == SiteID &&
                           c.IsPublic == true &&
                           (!c.IsCancelledEvent || c.IsCancelledPublic) &&
                           (!c.IsCancelledSeries || c.IsCancelledPublic)
                           orderby c.EventDate, c.EventStartTime
                           select c).Take(TakeTop).ToList();

                lst.ForEach(x => x.EventDate = site.ConvertUTCToSiteTime(x.EventDate));

                CalendarHelper.BindRepeater(rpDates, lst);
            }

            if (!string.IsNullOrEmpty(this.CalendarURL))
            {
                lnkHyper.NavigateUrl = this.CalendarURL;
                phLink.Visible       = true;
            }
            else
            {
                phLink.Visible = false;
            }
        }