private void cmdAddNew_Click(object sender, EventArgs e)
        {
            question newQuestion = new question();

            newQuestion.type              = question.QuestionTypes.Category;
            newQuestion.text              = "Type your new question here...";
            newQuestion.order_id          = trvDisplay.SelectedNode.Nodes.Count;
            newQuestion.is_classification = false;
            newQuestion.is_fork           = false;


            if (trvDisplay.SelectedNode is CallTreeQuestionNode)
            {
                newQuestion.parent = ((CallTreeQuestionNode)trvDisplay.SelectedNode).Question.id;
                question parentQuestion = new question(newQuestion.parent);
                newQuestion.linked_status        = parentQuestion.linked_status;
                newQuestion.set_revisit_date     = parentQuestion.set_revisit_date;
                newQuestion.default_revisit_date = parentQuestion.default_revisit_date;
            }
            else
            {
                newQuestion.linked_status = 0;
                newQuestion.parent        = 0;
            }

            newQuestion.Save();

            trvDisplay.SelectedNode = AddQuestionToTree(newQuestion, trvDisplay.SelectedNode);
            ForceReorderNodes(trvDisplay.SelectedNode);

            txtQuestionText.Focus();
        }
        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);
                }
            }
        }
Exemple #3
0
        private void CreateQuestion(int parentID, string currentLine, int orderID)
        {
            question newQ        = new question();
            string   workingText = currentLine;

            workingText = workingText.Replace("==", "|");
            string[] splitText = workingText.Split("|".ToCharArray());
            // [0] = text, [1] = type, [2] = question text or if combo, drop down options

            if ((splitText.Length < 2) || (splitText.Length > 4))
            {
                System.Diagnostics.Debug.Print("Length is wrong (" + splitText.Length + ")");
                return;
            }

            newQ.order_id = orderID;
            newQ.parent   = parentID;
            newQ.text     = CommonFunctions.TrimSpaces(splitText[0].Replace("- ", ""));

            newQ.type = GetQuestionType(CommonFunctions.TrimSpaces(splitText[1]));


            if (newQ.type == question.QuestionTypes.MultipleChoice)
            {
                if (splitText.Length == 3)
                {
                    newQ.popup_question_text = newQ.text;
                }
                else
                {
                    newQ.popup_question_text = CommonFunctions.TrimSpaces(splitText[2]);
                }
            }
            else
            {
                if (splitText.Length > 2)
                {
                    newQ.popup_question_text = CommonFunctions.TrimSpaces(splitText[2]);
                }
                else
                {
                    newQ.popup_question_text = newQ.text;
                }
            }

            newQ.Save();

            if (newQ.type == question.QuestionTypes.MultipleChoice)
            {
                GenerateMultipleChoiceAnswers(splitText[splitText.Length - 1], newQ.id);
            }
        }
Exemple #4
0
        private question CreateCategoryQuestion(int parentID, string currentLine, int orderID)
        {
            question newQ         = new question();
            string   questionText = currentLine.Replace("question: ", "");

            questionText = questionText.Replace(" == EXPAND", "");

            newQ.parent   = parentID;
            newQ.type     = question.QuestionTypes.Category;
            newQ.text     = questionText;
            newQ.order_id = orderID;
            System.Diagnostics.Debug.Print(newQ.order_id.ToString());
            newQ.Save();

            return(newQ);
        }
        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);
            }
        }