protected void SaveClicked(object o, EventArgs e) { if (CurrentPoll != null) { //CurrentPoll.IsActive = cbIsActive.Checked; //CurrentPoll.EndDate = (DateTime)tbEndDate.SelectedDate; CurrentPoll.LastUpdated = DateTime.Now; CurrentPoll.Question = tbQuestion.Text; //CurrentPoll.StartDate = (DateTime)tbStartDate.SelectedDate; new PollServices().Save(CurrentPoll); } else { var p = new HRR.Core.Domain.Poll(); p.IsActive = true; p.Question = tbQuestion.Text; p.EndDate = DateTime.Now.AddDays(14); p.StartDate = DateTime.Now; p.LastUpdated = DateTime.Now; p.DateCreated = DateTime.Now; p.EnteredBy = SecurityContextManager.Current.CurrentUser.ID; p.ChangedBy = SecurityContextManager.Current.CurrentUser.ID; p.AccountID = SecurityContextManager.Current.CurrentAccount.ID; new PollServices().Save(p); Response.Redirect("/Polls/" + p.ID.ToString()); } }
protected void ItemCommand(object o, GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) { e.Canceled = true; var i = new HRR.Core.Domain.PollOption(); i.Title = ""; i.PollID = 0; i.ID = 0; e.Item.OwnerTableView.InsertItem(i); } if (e.CommandName == RadGrid.PerformInsertCommandName) { var p = new HRR.Core.Domain.PollOption(); p.Title = (e.Item.FindControl("tbTitle") as IdeaSeed.Web.UI.TextBox).Text; p.PollID = CurrentPoll.ID; new PollOptionServices().Save(p); } if (e.CommandName == RadGrid.UpdateCommandName) { if (e.Item is GridEditableItem) { var p = new PollOptionServices().GetByID((int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"]); p.Title = (e.Item.FindControl("tbTitle") as IdeaSeed.Web.UI.TextBox).Text; p.PollID = CurrentPoll.ID; new PollOptionServices().Save(p); } } if (e.CommandName == RadGrid.DeleteCommandName) { var p = new PollOptionServices().GetByID((int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"]); new PollOptionServices().Delete(p); } CurrentPoll = new PollServices().GetByID(Convert.ToInt32(HttpContext.Current.Request.Url.Segments[HttpContext.Current.Request.Url.Segments.Count() - 1])); }
protected override void OnUnload(EventArgs e) { base.OnUnload(e); CurrentPoll = null; }