private void Save() { int?questionId = null; int surveyId = int.Parse(MetaSurveyId); // save question MetadataSurveyQuestion question = new MetadataSurveyQuestion(); if (!string.IsNullOrEmpty(QuestionId.Value)) { questionId = int.Parse(QuestionId.Value); question.Get(questionId.Value); } else { question[MetadataSurveyQuestion.MetadataSurveyId] = surveyId; } CICHelper.SetBOValues(this.Controls, question, surveyId); question.Save(); questionId = (int)question[MetadataSurveyQuestion.MetadataSurveyQuestionId]; // save responses SurveyQuestionResponsesGrid.Save(questionId.Value); // rebuild form PopulateForm(questionId); ReloadMainPage(surveyId.ToString()); }
protected void DeleteClick(object sender, EventArgs e) { if (!string.IsNullOrEmpty(MetaQuestionId)) { MetadataSurveyQuestion question = new MetadataSurveyQuestion(); question.Delete(int.Parse(MetaQuestionId)); } ReloadMainPage(MetaSurveyId); }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); if (!Page.IsPostBack) { int?surveyId = null; int?questionId = null; if (!string.IsNullOrEmpty(MetaSurveyId)) { surveyId = int.Parse(MetaSurveyId); } if (!string.IsNullOrEmpty(MetaQuestionId)) { questionId = int.Parse(MetaQuestionId); } if (QueryAction == "load") { if (surveyId.HasValue) { IEnumerable <MetadataSurveyQuestion> questions = new MetadataSurveyQuestion[0]; // load single question if (questionId.HasValue) { MetadataSurveyQuestion question = new MetadataSurveyQuestion(); question.Get(questionId.Value); questions = new MetadataSurveyQuestion[] { question }; } // load all questions else { questions = BusinessObject.GetByParent <MetadataSurveyQuestion>(surveyId.Value); } // data bind DataView questionsView = questions.AsDataView <MetadataSurveyQuestion>(); questionsView.Table.Columns.Add(new DataColumn("ColSortOrder", typeof(Int32), "ISNULL(SortNumber," + int.MaxValue + ")")); questionsView.Sort = "ColSortOrder ASC"; ReadOnlyRptr.DataSource = questionsView; ReadOnlyRptr.DataBind(); } } else if (QueryAction == "delete") { if (questionId.HasValue) { MetadataSurveyQuestion question = new MetadataSurveyQuestion(); question.Delete(questionId.Value); } } PopulateForm(questionId); } }
private void PopulateForm(int?questionId) { // populate question if (questionId.HasValue) { MetadataSurveyQuestion question = new MetadataSurveyQuestion(); question.Get(questionId.Value); CICHelper.SetFieldValues(this.Controls, question); } else { CICHelper.ClearCaisisInputControlValues(this); } // populate responses PopulateResponses(questionId); QuestionId.Value = questionId.HasValue ? questionId.Value.ToString() : ""; }