private void tvwCall_AfterSelect(object sender, TreeViewEventArgs e) { CallTreeQuestionNode qNode = tvwCall.SelectedNode as CallTreeQuestionNode; currentQuestionNode = null; if (qNode != null) { if (!pnlDataEntry.Visible) { pnlDataEntry.Visible = true; } if (currentChoicePanel != null) { currentChoicePanel.Visible = false; } lblDataDescription.Text = qNode.Question.popup_question_text; switch (qNode.Question.type) { case question.QuestionTypes.Category: currentChoicePanel = null; pnlDataEntry.Visible = false; break; case question.QuestionTypes.Date: currentChoicePanel = pnlChoiceDate; pnlDataEntry.Height = 66; if (qNode.Choice != null) { DateTime choiceDate; if (DateTime.TryParse(qNode.Choice.answer, out choiceDate)) { ctlDate.CurrentDate = choiceDate; } else if (qNode.Choice.answer == "") { ctlDate.CurrentDate = null; } else { ctlDate.CurrentDate = DateTime.Now; } } else { ctlDate.SetDefaultDate(DateTime.Now); } break; case question.QuestionTypes.LargeText: currentChoicePanel = pnlChoiceLargeText; pnlDataEntry.Height = 125; if (qNode.Choice != null) { txtLarge.Text = qNode.Choice.answer; } else { txtLarge.Text = ""; } break; case question.QuestionTypes.MultipleChoice: currentChoicePanel = pnlChoiceMultiple; pnlDataEntry.Height = 100; cmbMultipleChoice.Items.Clear(); // Use ComboBox foreach (multiple_choice_answer mca in qNode.Question.MultipleChoiceAnswers) { cmbMultipleChoice.Items.Add(mca); } if (qNode.Choice != null) { for (int i = 0; i < cmbMultipleChoice.Items.Count; i++) { if (cmbMultipleChoice.Items[i].ToString() == qNode.Choice.answer) { cmbMultipleChoice.SelectedIndex = i; break; } } } else { cmbMultipleChoice.SelectedIndex = -1; } break; case question.QuestionTypes.NormalText: currentChoicePanel = pnlChoiceNormalText; pnlDataEntry.Height = 66; if (qNode.Choice != null) { txtNormal.Text = qNode.Choice.answer; } else { txtNormal.Text = ""; } break; case question.QuestionTypes.Numeric: currentChoicePanel = pnlChoiceNumeric; pnlDataEntry.Height = 66; if (qNode.Choice != null) { if (CommonFunctions.IsNumeric(qNode.Choice.answer)) { numNumber.Value = Convert.ToDecimal(qNode.Choice.answer); } else { numNumber.Value = 0; } } else { numNumber.Value = 0; } break; case question.QuestionTypes.SmallText: currentChoicePanel = pnlChoiceSmallText; pnlDataEntry.Height = 100; if (qNode.Choice != null) { txtSmall.Text = qNode.Choice.answer; } else { txtSmall.Text = ""; } break; case question.QuestionTypes.YesNo: currentChoicePanel = pnlChoiceYesNo; pnlDataEntry.Height = 84; if (qNode.Choice != null) { bool YesNo = CommonFunctions.FromYesNo(qNode.Choice.answer); if (YesNo) { radYes.Checked = true; } else { radNo.Checked = true; } } else { radYes.Checked = false; radNo.Checked = false; } break; default: if (pnlDataEntry.Visible) { pnlDataEntry.Visible = false; } currentChoicePanel = null; break; } if (qNode.Choice == null) { cmdClearAnswer.Visible = false; } else { cmdClearAnswer.Visible = false; } if (currentChoicePanel != null) { currentChoicePanel.Visible = true; currentQuestionNode = qNode; } } else { pnlDataEntry.Visible = false; currentQuestionNode = null; } tvwCall.SelectedNode.EnsureVisible(); }