Ejemplo n.º 1
0
        public static List <carrot_CalendarEventCategory> GetCalendarCategories(Guid siteID)
        {
            using (CalendarDataContext db = CalendarDataContext.GetDataContext()) {
                if (!db.carrot_CalendarEventCategories.Where(x => x.SiteID == siteID).Any())
                {
                    carrot_CalendarEventCategory itm = new carrot_CalendarEventCategory();

                    itm = new carrot_CalendarEventCategory();
                    itm.CalendarEventCategoryID = Guid.NewGuid();
                    itm.SiteID = siteID;

                    itm.CategoryName    = "Default";
                    itm.CategoryFGColor = HEX_Black;
                    itm.CategoryBGColor = HEX_White;

                    db.carrot_CalendarEventCategories.InsertOnSubmit(itm);

                    db.SubmitChanges();
                }

                return((from c in db.carrot_CalendarEventCategories
                        orderby c.CategoryName
                        where c.SiteID == siteID
                        select c).ToList());
            }
        }
Ejemplo n.º 2
0
        protected void btnSaveButton_Click(object sender, EventArgs e)
        {
            bool bAdd = false;

            using (CalendarDataContext db = CalendarDataContext.GetDataContext()) {
                var itm = (from c in db.carrot_CalendarEventCategories
                           where c.CalendarEventCategoryID == ItemGuid
                           select c).FirstOrDefault();

                if (itm == null)
                {
                    bAdd     = true;
                    ItemGuid = Guid.NewGuid();
                    itm      = new carrot_CalendarEventCategory();
                    itm.CalendarEventCategoryID = ItemGuid;
                    itm.SiteID = SiteID;
                }

                itm.CategoryName    = txtCategoryName.Text;
                itm.CategoryFGColor = ddlFGColor.SelectedValue;
                itm.CategoryBGColor = ddlBGColor.SelectedValue;

                if (bAdd)
                {
                    db.carrot_CalendarEventCategories.InsertOnSubmit(itm);
                }

                db.SubmitChanges();
            }

            Response.Redirect(CreateLink(ModuleName, String.Format("id={0}", ItemGuid)));
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            bool bAdd = false;

            using (CalendarDataContext db = CalendarDataContext.GetDataContext()) {
                var currItem = (from c in db.carrot_CalendarEvents
                                where c.CalendarEventID == ItemGuid
                                select c).FirstOrDefault();

                if (currItem == null)
                {
                    bAdd     = true;
                    ItemGuid = Guid.NewGuid();
                    currItem = new carrot_CalendarEvent();
                    currItem.CalendarEventID = ItemGuid;
                }

                currItem.EventDetail = reContent.Text;
                currItem.IsCancelled = chkIsCancelled.Checked;

                currItem.EventStartTime = CalendarHelper.GetTimeSpanFromTextbox(txtEventStartTime);
                currItem.EventEndTime   = CalendarHelper.GetTimeSpanFromTextbox(txtEventEndTime);

                if (bAdd)
                {
                    db.carrot_CalendarEvents.InsertOnSubmit(currItem);
                }

                db.SubmitChanges();
            }

            Response.Redirect(CreateLink(ModuleName, String.Format("id={0}", ItemGuid)));
        }
Ejemplo n.º 4
0
        public static carrot_CalendarEventProfile CopyEvent(Guid calendarEventProfileID)
        {
            var srcProfile = GetProfile(calendarEventProfileID);

            using (CalendarDataContext db = CalendarDataContext.GetDataContext()) {
                var item = new carrot_CalendarEventProfile();
                item.CalendarEventProfileID = Guid.NewGuid();
                item.SiteID      = srcProfile.SiteID;
                item.EventDetail = srcProfile.EventDetail;

                item.EventRepeatPattern      = srcProfile.EventRepeatPattern;
                item.CalendarFrequencyID     = srcProfile.CalendarFrequencyID;
                item.CalendarEventCategoryID = srcProfile.CalendarEventCategoryID;

                item.EventStartDate = srcProfile.EventStartDate;
                item.EventEndDate   = srcProfile.EventEndDate;
                item.EventStartTime = srcProfile.EventStartTime;
                item.EventEndTime   = srcProfile.EventEndTime;

                item.IsPublic          = srcProfile.IsPublic;
                item.IsAllDayEvent     = srcProfile.IsAllDayEvent;
                item.IsCancelled       = srcProfile.IsCancelled;
                item.IsCancelledPublic = srcProfile.IsCancelledPublic;

                db.carrot_CalendarEventProfiles.InsertOnSubmit(item);

                if (srcProfile != null)
                {
                    var lst = (from m in db.carrot_CalendarEvents
                               where m.CalendarEventProfileID == calendarEventProfileID
                               select m);

                    foreach (carrot_CalendarEvent date in lst)
                    {
                        carrot_CalendarEvent evt = new carrot_CalendarEvent {
                            CalendarEventID        = Guid.NewGuid(),
                            CalendarEventProfileID = item.CalendarEventProfileID,
                            EventDate   = date.EventDate,
                            EventDetail = date.EventDetail,
                            IsCancelled = date.IsCancelled
                        };

                        db.carrot_CalendarEvents.InsertOnSubmit(evt);
                    }

                    db.SubmitChanges();
                }

                return(item);
            }
        }
Ejemplo n.º 5
0
        public static void RemoveEvent(Guid calendarEventProfileID)
        {
            using (CalendarDataContext db = CalendarDataContext.GetDataContext()) {
                var profile = (from c in db.carrot_CalendarEventProfiles
                               where c.CalendarEventProfileID == calendarEventProfileID
                               select c).FirstOrDefault();

                if (profile != null)
                {
                    var lst = (from m in db.carrot_CalendarEvents
                               where m.CalendarEventProfileID == profile.CalendarEventProfileID
                               select m);

                    db.carrot_CalendarEvents.DeleteAllOnSubmit(lst);
                    db.carrot_CalendarEventProfiles.DeleteOnSubmit(profile);
                    db.SubmitChanges();
                }
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            bool bAdd = false;

            using (CalendarDataContext db = CalendarDataContext.GetDataContext()) {
                var currItem = (from c in db.carrot_CalendarEventProfiles
                                where c.CalendarEventProfileID == ItemGuid
                                select c).FirstOrDefault();

                var origItem = new CalendarEvent(currItem);

                if (currItem == null)
                {
                    bAdd     = true;
                    ItemGuid = Guid.NewGuid();
                    currItem = new carrot_CalendarEventProfile();
                    currItem.CalendarEventProfileID = ItemGuid;
                    currItem.SiteID          = SiteID;
                    currItem.IsHoliday       = false;
                    currItem.IsAnnualHoliday = false;
                    currItem.RecursEvery     = 1;
                }

                currItem.CalendarFrequencyID     = new Guid(ddlRecurr.SelectedValue);
                currItem.CalendarEventCategoryID = new Guid(ddlCategory.SelectedValue);

                currItem.EventRepeatPattern = null;

                List <string> days = CalendarHelper.GetCheckedItemStringByValue(rpDays, true, "chkDay");

                if (CalendarFrequencyHelper.GetFrequencyTypeByID(currItem.CalendarFrequencyID) == CalendarFrequencyHelper.FrequencyType.Weekly &&
                    days.Count > 0)
                {
                    int dayMask = (from d in days select int.Parse(d)).Sum();

                    if (dayMask > 0)
                    {
                        currItem.EventRepeatPattern = dayMask;
                    }
                }

                currItem.EventTitle  = txtEventTitle.Text;
                currItem.EventDetail = reContent.Text;
                currItem.RecursEvery = int.Parse(txtRecursEvery.Text);

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

                currItem.EventStartDate = Convert.ToDateTime(txtEventStartDate.Text);
                currItem.EventStartTime = CalendarHelper.GetTimeSpanFromTextbox(txtEventStartTime);

                currItem.EventEndDate = Convert.ToDateTime(txtEventEndDate.Text);
                currItem.EventEndTime = CalendarHelper.GetTimeSpanFromTextbox(txtEventEndTime);

                if (bAdd)
                {
                    db.carrot_CalendarEventProfiles.InsertOnSubmit(currItem);
                }

                CalendarFrequencyHelper.SaveFrequencies(db, new CalendarEvent(currItem), origItem);

                db.SubmitChanges();
            }

            Response.Redirect(CreateLink(ModuleName, String.Format("id={0}", ItemGuid)));
        }