/// <summary> /// Validates the form and returns an error string with all errors. Returns string.empty if valid /// </summary> /// <returns></returns> private string ValidateSave() { bool valid = true; string Problems = "The question can not be saved for the following reason(s): \n"; if (radCallClassification.Checked) { if (!CheckValidClassification()) { valid = false; Problems += "\nThis question can not be marked as 'Classification'. To be valid as a classification, a question " + "must either be at the base level or every parent must be a classification."; } } question.QuestionTypes newType = (question.QuestionTypes)cmbQuestionType.SelectedIndex + 1; if ((newType != question.QuestionTypes.Header) && (newType != question.QuestionTypes.Spacer)) { if (txtTreeText.Text == "") { valid = false; Problems += "\nPlease enter valid tree text."; } if (newType != question.QuestionTypes.Category) { if (txtQuestionText.Text == "") { valid = false; Problems += "\nPlease enter valid question text."; } } } if (valid) { return(string.Empty); } else { return(Problems); } }
private void cmbQuestionType_SelectedIndexChanged(object sender, EventArgs e) { if (cmbQuestionType.SelectedIndex > -1) { question.QuestionTypes questionType = (question.QuestionTypes)(cmbQuestionType.SelectedIndex + 1); if ((questionType == question.QuestionTypes.YesNo) || (questionType == question.QuestionTypes.MultipleChoice)) { radFork.Enabled = true; } else { radFork.Enabled = false; radFork.Checked = false; } MakeQuestionTextVisible(questionType); lnkEditMultipleChoiceOptions.Enabled = questionType == question.QuestionTypes.MultipleChoice; QuestionChanged(true); } }
private void MakeQuestionTextVisible(question.QuestionTypes type) { if ((type == question.QuestionTypes.Category) || (type == question.QuestionTypes.Header) || (type == question.QuestionTypes.Spacer)) { txtQuestionText.Enabled = false; } else { txtQuestionText.Enabled = true; } if (type == question.QuestionTypes.Spacer) { txtTreeText.Enabled = false; txtTreeText.Text = "(Spacer)"; } else { txtTreeText.Enabled = true; } }