Пример #1
0
        public void ___LoadDialogQuestionnaires()
        {
            m_AnswerBindingOnProgress = true;
            m_HasMustSaveDefaultValues = false;
            this.ResetToDefaultState();
            this.BindDialogManagerData();

            using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection))
            {
                m_oDialog = _efDbContext.dialogs.FirstOrDefault(i => i.subcampaign_id == SubCampaignId && i.is_active == true);
                if (m_oDialog == null)
                {
                    bbiEditDialog.Enabled = false;
                    NotificationDialog.Warning("Bright Sales", "There is no current dialog created for this customer's subcampaign.");
                    return;
                }
                _efDbContext.Detach(m_oDialog);

                /**
                 * Populate each JSON questionnaire from dialog text to list object type.
                 */
                #region Code Logic
                var CQList = new List<CampaignQuestionnaire>();
                CampaignQuestionnaire oQuestionnaire = null;
                List<string> cbdList = new List<string>();
                DataBindings oBindings = null;
                if (!string.IsNullOrEmpty(m_oDialog.dialog_text_json))
                {
                    var jaDiag = JArray.Parse(m_oDialog.dialog_text_json);
                    jaDiag.ForEach(delegate(JToken jt)
                    {
                        /**
                         * [@jeff 06.08.2012]: https://brightvision.jira.com/browse/PLATFORM-1467
                         * added json converter to convert raw json to string, before unescaping.
                         */
                        string _jsonData = ValidationUtility.StripJsonInvalidChars(JsonConvert.ToString(jt.ToString(Formatting.None)).Unescape());
                        oQuestionnaire = CampaignQuestionnaire.InstanciateWith(_jsonData);
                        if (oQuestionnaire != null)
                        {
                            CQList.Add(oQuestionnaire);
                            oBindings = oQuestionnaire.Form.Settings.DataBindings;
                            if (oBindings != null)
                            {
                                if (!string.IsNullOrEmpty(oBindings.questionlayout_id))
                                    cbdList.Add(oBindings.questionlayout_id);
                            }
                        }
                    });
                }
                #endregion

                /**
                 * Populate Answers to each questionnaire.
                 */
                #region Code Logic
                int? campaign_id = CampaignId;
                int? account_id = AccountId;
                int? contact_id = SelectedContact == null || SelectedContact.id <= 0 ? (int?)null : SelectedContact.id;
                int? dialog_id = m_oDialog.id;
                List<int> answerIdList = new List<int>();

                //get all dialog answers based on questionlayout_ids and other params
                var listDialogAnswers = _efDbContext.FIGetDialogAnswers(
                    string.Join(",", cbdList.Distinct().ToArray()),
                    campaign_id,
                    account_id,
                    contact_id,
                    dialog_id

                ).ToList().Clone();

                /*
                 * DAN: FIX for issue:
                 * https://brightvision.jira.com/browse/PLATFORM-2948
                 * https://brightvision.jira.com/browse/PLATFORM-2952
                 */
                //------------------------------------------------------------------------------------------------
                ((System.ComponentModel.ISupportInitialize)(this.groupControlDialog)).BeginInit();
                this.groupControlDialog.SuspendLayout();
                ((System.ComponentModel.ISupportInitialize)(this.layoutControlDialog)).BeginInit();
                this.layoutControlDialog.SuspendLayout();
                ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup2)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup3)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup4)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem5)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.pnlDialogControls)).BeginInit();
                this.pnlDialogControls.SuspendLayout();
                ((System.ComponentModel.ISupportInitialize)(this.layoutControlMain)).BeginInit();
                this.layoutControlMain.SuspendLayout();
                this.SuspendLayout();
                //------------------------------------------------------------------------------------------------

                //layoutControlGroupQuestionnaire.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                //this.layoutControlQuestionnaire.Visible = false;
                int rowcount = CQList.Count;
                IsInitializingDialogComponents = true;
                IsInitializedComponentsValid = false;

                var a = from oquestion in CQList select oquestion.Form.Settings.DataBindings;
                CTDialogAnswers dlgAnswer = null;
                for (int i = 0; i < rowcount; ++i)
                {
                    oQuestionnaire = CQList[i];
                    oBindings = oQuestionnaire.Form.Settings.DataBindings;
                    if (oBindings.account_level)
                    {
                        dlgAnswer = listDialogAnswers.FirstOrDefault(p =>
                                    p.questionlayout_id == int.Parse(oBindings.questionlayout_id) &&
                                    p.campaign_id == campaign_id &&
                                    p.account_id == account_id &&
                                    (p.account_level == true) &&
                                    p.dialog_id == dialog_id);
                    }
                    else
                    {
                        dlgAnswer = listDialogAnswers.FirstOrDefault(p =>
                                    p.questionlayout_id == int.Parse(oBindings.questionlayout_id) &&
                                    p.campaign_id == campaign_id &&
                                    p.account_id == account_id &&
                                    (p.contact_id == contact_id && p.account_level == false) &&
                                    p.dialog_id == dialog_id);
                    }

                    if (dlgAnswer != null)
                    {
                        oBindings.answer_id = dlgAnswer.id.ToString();
                        oBindings.account_level = dlgAnswer.account_level;
                        oBindings.contact_id = contact_id.ToString();
                        answerIdList.Add(dlgAnswer.id);
                    }
                    else
                    {
                        m_HasMustSaveDefaultValues = true;
                        oBindings.language_code = "SE";
                        oBindings.account_id = account_id.ToString();
                        oBindings.campaign_id = campaign_id.ToString();
                        oBindings.contact_id = contact_id.ToString();
                        oBindings.dialog_id = dialog_id.ToString();
                    }
                }
                //BPContext = new BrightPlatformEntities(UserSession.EntityConnection);
                var oQuestionsAnswers = _efDbContext.answers.Include("sub_answers").Where(ans => answerIdList.Contains(ans.id));
                //if (oQuestionsAnswers != null)
                //    _efDbContext.Detach(oQuestionsAnswers);

                for (int i = 0; i < rowcount; ++i)
                {
                    oQuestionnaire = CQList[i];
                    oBindings = oQuestionnaire.Form.Settings.DataBindings;

                    if (!oBindings.account_level && (contact_id == null || contact_id == 0))
                        continue;

                    dlgAnswer = null;
                    if (oBindings.answer_id != null)
                        if (oBindings.answer_id.Length > 0)
                            dlgAnswer = listDialogAnswers.FirstOrDefault(an => an.id == int.Parse(oBindings.answer_id));

                    switch (oQuestionnaire.Type.ToLower())
                    {
                        #region Drop Box
                        case QuestionTypeConstants.Dropbox:
                            {
                                Dropbox oDropbox = new Dropbox(this.layoutControlQuestionnaire)
                                {
                                    ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId,
                                    DisableSelection = true,
                                    ToolTipController = defaultToolTipController1,
                                    IsInitializing = true,
                                    HasMustSaveDefaultValues = false,
                                    AccountId = m_BrightSalesProperty.CommonProperty.CurrentWorkedAccountId
                                };

                                if (dlgAnswer != null)
                                {
                                    int ansnwerID = int.Parse(oBindings.answer_id.ToString());
                                    var answer = oQuestionsAnswers.FirstOrDefault(oa => oa.id == ansnwerID);
                                    oDropbox.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire, answer);
                                }
                                else
                                {
                                    oDropbox.Questionnaire = oQuestionnaire;
                                    oDropbox.HasMustSaveDefaultValues = true;
                                }

                                oDropbox.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged);
                                oDropbox.BindControls();
                                if (oDropbox.ControlFooter != null && dlgAnswer != null)
                                    oDropbox.ControlFooter.SetSourceTooltip(dlgAnswer.source_contact, dlgAnswer.source_last_modified_by, dlgAnswer.source_last_modified_on.Value.ToString("yyyy-MM-dd"));

                                this.layoutControlGroupQuestionnaire.Add(oDropbox.ControlGroup);
                                controlsInDialog.Add(oDropbox);
                                oDropbox.IsInitializing = false;
                                break;
                            }
                        #endregion
                        #region Multiple Choice
                        case QuestionTypeConstants.MultipleChoice:
                            {
                                Multiplechoice oMultipleChoice = new Multiplechoice(this.layoutControlQuestionnaire)
                                {
                                    ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId,
                                    DisableSelection = true,
                                    ToolTipController = defaultToolTipController1,
                                    IsInitializing = true,
                                    HasMustSaveDefaultValues = false,
                                    AccountId = m_BrightSalesProperty.CommonProperty.CurrentWorkedAccountId
                                };

                                if (dlgAnswer != null)
                                {
                                    int ansnwerID = int.Parse(oBindings.answer_id.ToString());
                                    var answer = oQuestionsAnswers.FirstOrDefault(oa => oa.id == ansnwerID);
                                    oMultipleChoice.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire, answer);
                                }
                                else
                                {
                                    oMultipleChoice.Questionnaire = oQuestionnaire;
                                    oMultipleChoice.HasMustSaveDefaultValues = true;
                                }

                                oMultipleChoice.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged);
                                oMultipleChoice.BindControls();
                                if (oMultipleChoice.ControlFooter != null && dlgAnswer != null)
                                    oMultipleChoice.ControlFooter.SetSourceTooltip(dlgAnswer.source_contact, dlgAnswer.source_last_modified_by, dlgAnswer.source_last_modified_on.Value.ToString("yyyy-MM-dd"));

                                this.layoutControlGroupQuestionnaire.Add(oMultipleChoice.ControlGroup);
                                controlsInDialog.Add(oMultipleChoice);
                                oMultipleChoice.IsInitializing = false;
                                break;
                            }
                        #endregion
                        #region Text Box
                        case QuestionTypeConstants.Textbox:
                            {
                                Textbox oTextbox = new Textbox(this.layoutControlQuestionnaire)
                                {
                                    ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId,
                                    DisableSelection = true,
                                    ToolTipController = defaultToolTipController1,
                                    IsInitializing = true,
                                    HasMustSaveDefaultValues = false,
                                    AccountId = m_BrightSalesProperty.CommonProperty.CurrentWorkedAccountId
                                };

                                if (dlgAnswer != null)
                                {
                                    int ansnwerID = int.Parse(oBindings.answer_id.ToString());
                                    var answer = oQuestionsAnswers.FirstOrDefault(oa => oa.id == ansnwerID);
                                    oTextbox.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire, answer);
                                }
                                else
                                {
                                    oTextbox.Questionnaire = oQuestionnaire;
                                    oTextbox.HasMustSaveDefaultValues = true;
                                }

                                oTextbox.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged);
                                oTextbox.BindControls();
                                if (oTextbox.ControlFooter != null && dlgAnswer != null)
                                    oTextbox.ControlFooter.SetSourceTooltip(dlgAnswer.source_contact, dlgAnswer.source_last_modified_by, dlgAnswer.source_last_modified_on.Value.ToString("yyyy-MM-dd"));

                                this.layoutControlGroupQuestionnaire.Add(oTextbox.ControlGroup);
                                controlsInDialog.Add(oTextbox);
                                oTextbox.IsInitializing = false;
                                break;
                            }
                        #endregion
                        #region Schedule
                        case QuestionTypeConstants.Schedule:
                            {
                                Schedule oSchedule = new Schedule(this.layoutControlQuestionnaire)
                                {
                                    ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId,
                                    IsInitializing = true,
                                    HasMustSaveDefaultValues = false,
                                    AccountId = m_BrightSalesProperty.CommonProperty.CurrentWorkedAccountId
                                };

                                var result = SubCampaignContactList;
                                if (result != null)
                                    oSchedule.ContactList = result;

                                oSchedule.SubcampaignID = SubCampaignId;
                                oSchedule.DisableSelection = true;
                                oSchedule.ToolTipController = defaultToolTipController1;
                                if (SelectedContact != null)
                                    oSchedule.SetCurrentCaller(SelectedContact, AccountId);

                                if (dlgAnswer != null)
                                {
                                    int ansnwerID = int.Parse(oBindings.answer_id.ToString());
                                    var answer = oQuestionsAnswers.FirstOrDefault(oa => oa.id == ansnwerID);
                                    oSchedule.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire, answer);
                                }
                                else
                                {
                                    oSchedule.Questionnaire = oQuestionnaire;
                                    oSchedule.HasMustSaveDefaultValues = true;
                                }

                                oSchedule.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged);
                                oSchedule.BindControls();
                                if (oSchedule.ControlFooter != null && dlgAnswer != null)
                                    oSchedule.ControlFooter.SetSourceTooltip(dlgAnswer.source_contact, dlgAnswer.source_last_modified_by, dlgAnswer.source_last_modified_on.Value.ToString("yyyy-MM-dd"));

                                oSchedule.ShowCalendarBookingClick += new EventHandler(oSchedule_ShowCalendarBookingClick);
                                this.layoutControlGroupQuestionnaire.Add(oSchedule.ControlGroup);
                                controlsInDialog.Add(oSchedule);
                                oSchedule.IsInitializing = false;
                                break;
                            }
                        #endregion
                        #region Smart Text
                        case QuestionTypeConstants.SmartText:
                            {
                                SmartText oSmartText = new SmartText(this.layoutControlQuestionnaire)
                                {
                                    ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId,
                                    DisableSelection = true,
                                    ToolTipController = defaultToolTipController1,
                                    IsInitializing = true,
                                    HasMustSaveDefaultValues = false,
                                    AccountId = m_BrightSalesProperty.CommonProperty.CurrentWorkedAccountId
                                };

                                if (dlgAnswer != null)
                                {
                                    int ansnwerID = int.Parse(oBindings.answer_id.ToString());
                                    var answerD = oQuestionsAnswers.FirstOrDefault(oa => oa.id == ansnwerID);
                                    oSmartText.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire, answerD);
                                }
                                else
                                {
                                    oSmartText.Questionnaire = oQuestionnaire;
                                    oSmartText.HasMustSaveDefaultValues = true;
                                }

                                oSmartText.UserId = UserSession.CurrentUser.UserId;
                                oSmartText.UserName = UserSession.CurrentUser.UserFullName;

                                /**
                                 * [jeff 05.16.2012]: https://brightvision.jira.com/browse/PLATFORM-1413
                                 * added checking for null selected contact.
                                 */
                                if (SelectedContact == null)
                                    oSmartText.ContactName = "";
                                else
                                    oSmartText.ContactName = SelectedContact.first_name + ", " + SelectedContact.last_name;

                                if (UserSession.CurrentUser.IsSubCampaignManager || UserSession.CurrentUser.IsCampaignOwner)
                                    oSmartText.CanEditAllRows = true;
                                else
                                    oSmartText.CanEditAllRows = false;

                                oSmartText.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged);
                                oSmartText.BindControls();
                                oSmartText.BindPropertyGrid();

                                if (oSmartText.ControlFooter != null && dlgAnswer != null)
                                    oSmartText.ControlFooter.SetSourceTooltip(dlgAnswer.source_contact, dlgAnswer.source_last_modified_by, dlgAnswer.source_last_modified_on.Value.ToString("yyyy-MM-dd"));

                                this.layoutControlGroupQuestionnaire.Add(oSmartText.ControlGroup);
                                controlsInDialog.Add(oSmartText);
                                oSmartText.IsInitializing = false;
                                break;
                            }
                        #endregion
                    }
                }
                #endregion
            }

            EmptySpaceItem emptySpaceItem1 = new EmptySpaceItem();
            emptySpaceItem1.CustomizationFormText = "emptySpaceItemBottom";
            emptySpaceItem1.Name = "emptySpaceItemBottom";
            emptySpaceItem1.ShowInCustomizationForm = false;
            emptySpaceItem1.Size = new System.Drawing.Size(0, 0);
            emptySpaceItem1.Text = "emptySpaceItemBottom";
            emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);

            this.layoutControlGroupQuestionnaire.AddItem(emptySpaceItem1);

            /*
                 * DAN: FIX for issue:
                 * https://brightvision.jira.com/browse/PLATFORM-2948
                 * https://brightvision.jira.com/browse/PLATFORM-2952
                 */
            //------------------------------------------------------------------------------------------------
            ((System.ComponentModel.ISupportInitialize)(this.groupControlDialog)).EndInit();
            this.groupControlDialog.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlDialog)).EndInit();
            this.layoutControlDialog.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup2)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup3)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup4)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem5)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pnlDialogControls)).EndInit();
            this.pnlDialogControls.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlMain)).EndInit();
            this.layoutControlMain.ResumeLayout(false);
            this.ResumeLayout(false);
            //------------------------------------------------------------------------------------------------

            this.SetEditableComponent(false);
            IsInitializedComponentsValid = this.ValidateDialog(false);

            //this.layoutControlGroupQuestionnaire.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            //this.layoutControlQuestionnaire.BestFit();
            //this.layoutControlQuestionnaire.Visible = true;
            //this.layoutControlQuestionnaire.Update();
            //this.layoutControlQuestionnaire.Size = new Size(this.layoutControlQuestionnaire.Size.Width + 1, this.layoutControlQuestionnaire.Size.Height);
            IsInitializingDialogComponents = false;
            m_AnswerBindingOnProgress = false;

            if (bbiDialogStatus.EditValue != null)
                m_CurrentStatus = bbiDialogStatus.EditValue.ToString();

            bbiEditDialog.Enabled = true;
            if (m_BrightSalesProperty.CommonProperty.CompanyLocked)
                bbiDeleteDialog.Enabled = false;
        }
Пример #2
0
        /// <summary>
        /// View dialog
        /// </summary>
        private void ViewDialog()
        {
            m_oContactView.gvContact.OptionsFind.AlwaysVisible = true;
            WaitDialog.CreateWaitDialog("Loading dialog questionnaires...");

            #region Populate each JSON questionnaire from dialog text to list object type
            var selectedContact = m_oContactView.SelectedContact;
            groupControlDialog.Text = string.Format("Dialog with: {0} {1}, {2}", selectedContact.first_name, selectedContact.last_name, SelectedCompany);

            m_oDialog = BPContext.dialogs.FirstOrDefault(p =>
                p.subcampaign_id == oAppointment.SubCampaignId &&
                    //p.customers_id == oAppointment.CustomerId &&
                p.is_active == true);
            if (m_oDialog == null) {
                MessageBox.Show("There is no current dialog created for this customer's subcampaign.");
                WaitDialog.CloseWaitDialog();
                return;
                //prompt message saying that no dialog for current subcampaign and customer.
            }
            var CQList = new List<CampaignQuestionnaire>();
            CampaignQuestionnaire oQuestionnaire = null;
            List<string> cbdList = new List<string>();
            DataBindings oBindings = null;
            if (!string.IsNullOrEmpty(m_oDialog.dialog_text_json)) {
                var jaDiag = JArray.Parse(m_oDialog.dialog_text_json);
                jaDiag.ForEach(delegate(JToken jt) {
                    oQuestionnaire = CampaignQuestionnaire.InstanciateWith(jt.ToString(Formatting.None).Unescape());
                    if (oQuestionnaire != null) {
                        CQList.Add(oQuestionnaire);
                        oBindings = oQuestionnaire.Form.Settings.DataBindings;
                        if (oBindings != null) {
                            if (!string.IsNullOrEmpty(oBindings.questionlayout_id)) {
                                cbdList.Add(oBindings.questionlayout_id);
                            }
                        }
                    }
                });
            }
            #endregion

            #region Populate Answers to each questionnaire

            int? campaign_id = oAppointment.CampaignId;
            int? account_id = oAppointment.AccountId;
            int? contact_id = m_oContactView.SelectedContact.id;
            int? dialog_id = m_oDialog.id;

            //get all dialog answers based on questionlayout_ids and other params
            var listDialogAnswers = BPContext.FIGetDialogAnswers(
                string.Join(",", cbdList.Distinct().ToArray()),
                campaign_id,
                account_id,
                contact_id,
                dialog_id).ToList().Clone();

            layoutControlGroupQuestionnaire.BeginUpdate();
            layoutControlGroupQuestionnaire.BeginInit();
            DisposeGroupControls(layoutControlGroupQuestionnaire);
            int rowcount = CQList.Count;

            CTDialogAnswers dlgAnswer = null;
            for (int i = 0; i < rowcount; ++i) {
                oQuestionnaire = CQList[i];
                oBindings = oQuestionnaire.Form.Settings.DataBindings;
                dlgAnswer = listDialogAnswers.FirstOrDefault(p =>
                            p.questionlayout_id == int.Parse(oBindings.questionlayout_id) &&
                            p.campaign_id == campaign_id &&
                            p.account_id == account_id &&
                            p.contact_id == contact_id &&
                            p.dialog_id == dialog_id);

                if (dlgAnswer != null) {
                    oBindings.answer_id = dlgAnswer.id.ToString();
                } else {
                    oBindings.account_id = account_id.ToString();
                    oBindings.campaign_id = campaign_id.ToString();
                    oBindings.contact_id = contact_id.ToString();
                    oBindings.dialog_id = dialog_id.ToString();
                    oBindings.created_by = UserSession.CurrentUser.UserId.ToString();
                }

                switch (oQuestionnaire.Type.ToLower()) {
                    case QuestionTypeConstants.Dropbox:
                        Dropbox oDropbox = new Dropbox(this.layoutControlQuestionnaire);
                        oDropbox.DisableSelection = true;
                        oDropbox.ToolTipController = defaultToolTipController1;

                        //load answers for this questionnaire
                        if (dlgAnswer != null) {
                            oDropbox.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire);
                        } else {
                            oDropbox.Questionnaire = oQuestionnaire;
                        }

                        oDropbox.BindControls();
                        this.layoutControlGroupQuestionnaire.Add(oDropbox.ControlGroup);
                        break;
                    case QuestionTypeConstants.MultipleChoice:
                        Multiplechoice oMultipleChoice = new Multiplechoice(this.layoutControlQuestionnaire);
                        oMultipleChoice.DisableSelection = true;
                        oMultipleChoice.ToolTipController = defaultToolTipController1;

                        //load answers for this questionnaire
                        if (dlgAnswer != null) {
                            oMultipleChoice.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire);
                        } else {
                            oMultipleChoice.Questionnaire = oQuestionnaire;
                        }

                        oMultipleChoice.BindControls();
                        this.layoutControlGroupQuestionnaire.Add(oMultipleChoice.ControlGroup);
                        break;
                    case QuestionTypeConstants.Textbox:
                        Textbox oTextbox = new Textbox(this.layoutControlQuestionnaire);
                        oTextbox.DisableSelection = true;
                        oTextbox.ToolTipController = defaultToolTipController1;

                        //load answers for this questionnaire
                        if (dlgAnswer != null) {
                            oTextbox.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire);
                        } else {
                            oTextbox.Questionnaire = oQuestionnaire;
                        }

                        oTextbox.BindControls();
                        this.layoutControlGroupQuestionnaire.Add(oTextbox.ControlGroup);
                        break;
                    case QuestionTypeConstants.Schedule:
                        Schedule oSchedule = new Schedule(this.layoutControlQuestionnaire);
                        var result = m_oContactView.gcContact.DataSource as List<CTScSubCampaignContactList>;
                        if (result != null)
                            oSchedule.SubCampaignContactList = result;
                        oSchedule.SubcampaignID = oAppointment.SubCampaignId;
                        oSchedule.DisableSelection = true;
                        oSchedule.ToolTipController = defaultToolTipController1;
                        if (m_oContactView.SelectedContact != null) {
                            oSchedule.SetCurrentCaller(m_oContactView.SelectedContact, oAppointment.AccountId);
                        }

                        //load answers for this questionnaire
                        if (dlgAnswer != null) {
                            oSchedule.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire);
                        } else {
                            oSchedule.Questionnaire = oQuestionnaire;
                        }

                        oSchedule.BindControls();
                        oSchedule.ShowCalendarBookingClick += new EventHandler(oSchedule_ShowCalendarBookingClick);
                        this.layoutControlGroupQuestionnaire.Add(oSchedule.ControlGroup);
                        break;
                    //case QuestionTypeConstants.Seminar:
                    //    Seminar oSeminar = new Seminar(this.layoutControlQuestionnaire);
                    //    oSeminar.DisableSelection = true;
                    //    oSeminar.ToolTipController = defaultToolTipController1;

                    //    //load answers for this questionnaire
                    //    if (dlgAnswer != null) {
                    //        oSeminar.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire);
                    //    } else {
                    //        oSeminar.Questionnaire = oQuestionnaire;
                    //    }

                    //    oSeminar.BindControls();
                    //    this.layoutControlGroupQuestionnaire.Add(oSeminar.ControlGroup);
                    //    break;
                }
            }
            EmptySpaceItem emptySpaceItem1 = new EmptySpaceItem();
            emptySpaceItem1.CustomizationFormText = "emptySpaceItemBottom";
            emptySpaceItem1.Name = "emptySpaceItemBottom";
            emptySpaceItem1.ShowInCustomizationForm = false;
            emptySpaceItem1.Size = new System.Drawing.Size(0, 0);
            emptySpaceItem1.Text = "emptySpaceItemBottom";
            emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);

            //add bottom spacer
            this.layoutControlGroupQuestionnaire.AddItem(emptySpaceItem1);

            //set readonly and disabled controls -> for viewing only
            //this.layoutControlQuestionnaire.OptionsView.IsReadOnly = DevExpress.Utils.DefaultBoolean.True;
            SetEditableComponent(false);
            ValidateDialog();

            this.layoutControlGroupQuestionnaire.EndInit();
            this.layoutControlGroupQuestionnaire.EndUpdate();
            this.layoutControlQuestionnaire.BestFit();
            #endregion
            WaitDialog.CloseWaitDialog();
        }