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))); }
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))); }