protected void DayPilotCalendar1_EventResize(object sender, EventResizeEventArgs e) { #region Simulation of database update DataRow dr = table.Rows.Find(e.Id); if (e.Recurrent && !e.RecurrentException) { DataRow master = table.Rows.Find(e.RecurrentMasterId); dr = table.NewRow(); dr["id"] = Guid.NewGuid().ToString(); dr["recurrence"] = RecurrenceRule.EncodeExceptionModified(e.RecurrentMasterId, e.OldStart); dr["start"] = e.NewStart; dr["end"] = e.NewEnd; dr["name"] = master["name"]; table.Rows.Add(dr); table.AcceptChanges(); } else if (dr != null) { dr["start"] = e.NewStart; dr["end"] = e.NewEnd; table.AcceptChanges(); } #endregion DayPilotCalendar1.DataBind(); DayPilotCalendar1.Update("Event resized"); }
protected void ButtonSave_Click(object sender, EventArgs e) { string id = Request.QueryString["id"]; string masterId = Request.QueryString["master"]; DataRow master = table.Rows.Find(masterId); DataRow row = table.Rows.Find(id); switch (Mode) { case EventMode.Master: RecurrenceRule rule = RecurrenceRule.FromJson(masterId, (DateTime)master["start"], Recurrence.Value); master["name"] = TextBoxName.Text; master["start"] = Convert.ToDateTime(TextBoxStart.Text); master["end"] = Convert.ToDateTime(TextBoxEnd.Text); master["recurrence"] = rule.Encode(); table.AcceptChanges(); break; case EventMode.NewException: DataRow r = table.NewRow(); r["id"] = Guid.NewGuid().ToString(); r["name"] = TextBoxName.Text; r["start"] = Convert.ToDateTime(TextBoxStart.Text); r["end"] = Convert.ToDateTime(TextBoxEnd.Text); r["recurrence"] = RecurrenceRule.EncodeExceptionModified(masterId, Occurrence); table.Rows.Add(r); table.AcceptChanges(); break; case EventMode.Exception: row["name"] = TextBoxName.Text; row["start"] = Convert.ToDateTime(TextBoxStart.Text); row["end"] = Convert.ToDateTime(TextBoxEnd.Text); table.AcceptChanges(); break; case EventMode.Regular: row["name"] = TextBoxName.Text; row["start"] = Convert.ToDateTime(TextBoxStart.Text); row["end"] = Convert.ToDateTime(TextBoxEnd.Text); row["recurrence"] = RecurrenceRule.FromJson(id, (DateTime)row["start"], Recurrence.Value).Encode(); table.AcceptChanges(); break; default: throw new ArgumentOutOfRangeException(); } Modal.Close(this, "OK"); }
protected void DayPilotMonth1_EventMove(object sender, EventMoveEventArgs e) { #region Simulation of database update DataRow dr = table.Rows.Find(e.Id); // recurrent event but no exception if (e.Recurrent && !e.RecurrentException) { DataRow master = table.Rows.Find(e.RecurrentMasterId); dr = table.NewRow(); dr["id"] = Guid.NewGuid().ToString(); dr["name"] = master["name"]; dr["start"] = e.NewStart; dr["end"] = e.NewEnd; dr["recurrence"] = RecurrenceRule.EncodeExceptionModified(e.RecurrentMasterId, e.OldStart); table.Rows.Add(dr); table.AcceptChanges(); DayPilotMonth1.UpdateWithMessage("Recurrent event exception added."); } // recurrent exception or regular event else if (dr != null) { dr["start"] = e.NewStart; dr["end"] = e.NewEnd; table.AcceptChanges(); DayPilotMonth1.UpdateWithMessage("Event moved."); } else { DayPilotMonth1.UpdateWithMessage("No update."); } #endregion DayPilotMonth1.UpdateWithMessage("Update. Start: " + DayPilotMonth1.VisibleStart + " end: " + DayPilotMonth1.VisibleEnd); DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); }
protected void DayPilotMonth1_EventResize(object sender, EventResizeEventArgs e) { #region Simulation of database update DataRow dr = table.Rows.Find(e.Id); /* * if (dr != null) * { * dr["start"] = e.NewStart; * dr["end"] = e.NewEnd; * table.AcceptChanges(); * } */ if (e.Recurrent && !e.RecurrentException) { DataRow master = table.Rows.Find(e.RecurrentMasterId); dr = table.NewRow(); dr["id"] = Guid.NewGuid().ToString(); dr["recurrence"] = RecurrenceRule.EncodeExceptionModified(e.RecurrentMasterId, e.OldStart); dr["start"] = e.NewStart; dr["end"] = e.NewEnd; dr["name"] = master["name"]; table.Rows.Add(dr); table.AcceptChanges(); } else if (dr != null) { dr["start"] = e.NewStart; dr["end"] = e.NewEnd; table.AcceptChanges(); } #endregion DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.UpdateWithMessage("Event resized"); }
public ActionResult Edit(FormCollection form) { string id = form["Id"]; string masterId = Request.QueryString["master"]; string recurrence = form["Recurrence"]; DateTime start = Convert.ToDateTime(form["Start"]); DateTime end = Convert.ToDateTime(form["End"]); string text = form["Text"]; string resource = form["Resource"]; var row = new EventManager().Get(id) ?? new EventManager.Event(); var master = new EventManager().Get(masterId) ?? new EventManager.Event(); switch (Mode(id)) { case EventMode.Master: RecurrenceRule rule = RecurrenceRule.FromJson(masterId, master.Start, recurrence); new EventManager().EventEdit(masterId, text, start, end, resource, rule.Encode()); break; case EventMode.NewException: new EventManager().EventCreateException(start, end, text, resource, RecurrenceRule.EncodeExceptionModified(masterId, Occurrence)); break; case EventMode.Exception: new EventManager().EventEdit(id, text, start, end, resource); break; case EventMode.Regular: new EventManager().EventEdit(id, text, start, end, resource, RecurrenceRule.FromJson(id, row.Start, recurrence).Encode()); break; default: throw new ArgumentOutOfRangeException(); } return(JavaScript(SimpleJsonSerializer.Serialize("OK"))); }
protected void DayPilotCalendar1_EventMove(object sender, EventMoveEventArgs e) { #region Simulation of database update DataRow dr = table.Rows.Find(e.Id); // recurrent event but no exception if (e.Recurrent && !e.RecurrentException) { DataRow master = table.Rows.Find(e.RecurrentMasterId); dr = table.NewRow(); dr["id"] = Guid.NewGuid().ToString(); dr["name"] = master["name"]; dr["start"] = e.NewStart; dr["end"] = e.NewEnd; dr["recurrence"] = RecurrenceRule.EncodeExceptionModified(e.RecurrentMasterId, e.OldStart); table.Rows.Add(dr); table.AcceptChanges(); } // recurrent exception or regular event else if (dr != null) { dr["start"] = e.NewStart; dr["end"] = e.NewEnd; table.AcceptChanges(); } #endregion DayPilotCalendar1.DataBind(); Hashtable ht = new Hashtable(); ht["message"] = "Event moved."; ht["id"] = e.Id; DayPilotCalendar1.Update(ht); }
protected override void OnEventMove(EventMoveArgs e) { if (e.Recurrent && !e.RecurrentException) { new EventManager().EventCreateException(e.NewStart, e.NewEnd, e.Text, e.NewResource, RecurrenceRule.EncodeExceptionModified(e.RecurrentMasterId, e.OldStart)); UpdateWithMessage("Wyjątek od powtarzalnego wydarzenia został utworzony."); } else { new EventManager().EventMove(e.Id, e.NewStart, e.NewEnd, e.NewResource); UpdateWithMessage("Wydarzenie zostało przeniesione."); } }