private void cmdSave_Click(object sender, EventArgs e) { if (_currentQuestion != null) { string saveSuccess = ValidateSave(); if (saveSuccess == string.Empty) { _currentQuestion.popup_question_text = txtQuestionText.Text; _currentQuestion.text = txtTreeText.Text; _currentQuestion.is_fork = radFork.Checked; _currentQuestion.type = (question.QuestionTypes)cmbQuestionType.SelectedIndex + 1; _currentQuestion.required_answer = cmbRequiredAnswer.Text; if ((_currentQuestion.type == question.QuestionTypes.Header) || (_currentQuestion.type == question.QuestionTypes.Spacer)) { // Headers and spacers are forced into being classifications radCallClassification.Checked = true; } else if (radCallClassification.Checked) { if (cmbStatusDropdown.SelectedIndex > 0) { _currentQuestion.linked_status = ((claim_status)cmbStatusDropdown.SelectedItem).id; // Go ahead and change the children status' here as well foreach (question q in _currentQuestion.GetSubClassifications()) { SetStatusRevisitAndChildren(q, _currentQuestion); } } else { _currentQuestion.linked_status = -1; } if (cmbRevisitDateOptions.SelectedIndex >= 0) { _currentQuestion.set_revisit_date = (frmEditQuestionTree.SetRevisitDateOptions)cmbRevisitDateOptions.SelectedIndex; _currentQuestion.default_revisit_date = Convert.ToInt32(nmbDefaultRevisitDate.Value); } SetChildrenStatusRevisit(_currentQuestion); } _currentQuestion.is_classification = radCallClassification.Checked; _currentQuestion.Save(); ((CallTreeQuestionNode)trvDisplay.SelectedNode).Question = _currentQuestion; QuestionChanged(false); SetQuestionImage(_currentQuestion, (CallTreeQuestionNode)trvDisplay.SelectedNode); trvDisplay.SelectedNode.Text = txtTreeText.Text; } else { MessageBox.Show(saveSuccess); } } }
private void SetStatusRevisitAndChildren(question childQuestion, question parentQuestion) { if (childQuestion.linked_status <= 0) { childQuestion.linked_status = parentQuestion.linked_status; } if (childQuestion.set_revisit_date <= 0) { childQuestion.set_revisit_date = parentQuestion.set_revisit_date; } if (childQuestion.default_revisit_date == 0) { childQuestion.default_revisit_date = parentQuestion.default_revisit_date; } childQuestion.Save(); foreach (question subs in childQuestion.GetSubClassifications()) { SetStatusRevisitAndChildren(subs, parentQuestion); } }