Пример #1
0
        internal CalendarEvent(carrot_CalendarEventProfile p)
        {
            if (p != null) {
                this.CalendarEventProfileID = p.CalendarEventProfileID;
                this.CalendarFrequencyID = p.CalendarFrequencyID;
                this.CalendarEventCategoryID = p.CalendarEventCategoryID;
                this.EventStartDate = p.EventStartDate;
                this.EventStartTime = p.EventStartTime;
                this.EventEndDate = p.EventEndDate;
                this.EventEndTime = p.EventEndTime;
                this.EventTitle = p.EventTitle;
                this.EventDetail = p.EventDetail;
                this.EventRepeatPattern = p.EventRepeatPattern;
                this.RecursEvery = p.RecursEvery;
                this.IsCancelled = p.IsCancelled;
                this.IsCancelledPublic = p.IsCancelledPublic;
                this.IsAllDayEvent = p.IsAllDayEvent;
                this.IsPublic = p.IsPublic;
                this.IsAnnualHoliday = p.IsAnnualHoliday;
                this.IsHoliday = p.IsHoliday;

                this.SiteID = p.SiteID;

                this.Frequency = CalendarFrequencyHelper.GetFrequencyTypeByID(p.CalendarFrequencyID);
            }
        }
		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)));
		}
		private void detach_carrot_CalendarEventProfiles(carrot_CalendarEventProfile entity)
		{
			this.SendPropertyChanging();
			entity.carrot_CalendarFrequency = null;
		}
 partial void Deletecarrot_CalendarEventProfile(carrot_CalendarEventProfile instance);
 partial void Insertcarrot_CalendarEventProfile(carrot_CalendarEventProfile instance);
		private void attach_carrot_CalendarEventProfiles(carrot_CalendarEventProfile entity)
		{
			this.SendPropertyChanging();
			entity.carrot_CalendarEventCategory = this;
		}
Пример #7
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;
            }
        }