Ejemplo n.º 1
0
        private void CreateQuestionnaire()
        {
            CampaignQuestionnaire _Questionnaire = null;
            DataBindings _BindingData = null;

            /**
             * initalize layout.
             */
            #region Code Logic
            /**
             * 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();
            #endregion

            for (int i = 0; i < m_lstQuestionnaireDialog.Count; ++i) {
                /**
                 * set binding data defaults.
                 */
                #region Code Logic
                _Questionnaire = m_lstQuestionnaireDialog[i];
                _BindingData = _Questionnaire.Form.Settings.DataBindings;

                _BindingData.language_code = "SE";
                _BindingData.contact_id = null;
                _BindingData.same_contact_binding = false;
                _BindingData.account_id = m_BrightSalesProperty.CommonProperty.CurrentWorkedAccountId.ToString(); //_AccountId.ToString();
                _BindingData.campaign_id = m_BrightSalesProperty.CommonProperty.CampaignId.ToString(); //_CampaignId.ToString();
                _BindingData.dialog_id = m_oDialog.id.ToString();
                #endregion

                /**
                 * set questionnaire.
                 */
                switch (_Questionnaire.Type.ToLower()) {
                    #region Drop Box
                    case QuestionTypeConstants.Dropbox:
                        Dropbox _Dropbox = new Dropbox(this.layoutControlQuestionnaire) {
                            ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId,
                            DisableSelection = true,
                            ToolTipController = defaultToolTipController1,
                            IsInitializing = true,
                            QuestionId = Convert.ToInt32(_BindingData.question_id),
                            QuestionLayoutId = Convert.ToInt32(_BindingData.questionlayout_id),
                            DefaultQuestionnaire = _Questionnaire,
                            Questionnaire = _Questionnaire,
                            InQuestionnaire = false
                        };

                        _Dropbox.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged);
                        _Dropbox.BindControls();
                        this.layoutControlGroupQuestionnaire.Add(_Dropbox.ControlGroup);
                        controlsInDialog.Add(_Dropbox);
                        _Dropbox.IsInitializing = false;
                        break;
                    #endregion
                    #region Multiple Choice
                    case QuestionTypeConstants.MultipleChoice:
                        Multiplechoice _MultipleChoice = new Multiplechoice(this.layoutControlQuestionnaire) {
                            ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId,
                            DisableSelection = true,
                            ToolTipController = defaultToolTipController1,
                            IsInitializing = true,
                            QuestionId = Convert.ToInt32(_BindingData.question_id),
                            QuestionLayoutId = Convert.ToInt32(_BindingData.questionlayout_id),
                            DefaultQuestionnaire = _Questionnaire,
                            Questionnaire = _Questionnaire,
                            InQuestionnaire = false
                        };

                        _MultipleChoice.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged);
                        _MultipleChoice.BindControls();
                        this.layoutControlGroupQuestionnaire.Add(_MultipleChoice.ControlGroup);
                        controlsInDialog.Add(_MultipleChoice);
                        _MultipleChoice.IsInitializing = false;
                        break;
                    #endregion
                    #region Text Box
                    case QuestionTypeConstants.Textbox:
                        Textbox _Textbox = new Textbox(this.layoutControlQuestionnaire) {
                            ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId,
                            DisableSelection = true,
                            ToolTipController = defaultToolTipController1,
                            IsInitializing = true,
                            QuestionId = Convert.ToInt32(_BindingData.question_id),
                            QuestionLayoutId = Convert.ToInt32(_BindingData.questionlayout_id),
                            DefaultQuestionnaire = _Questionnaire,
                            Questionnaire = _Questionnaire,
                            InQuestionnaire = false
                        };

                        _Textbox.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged);
                        _Textbox.BindControls();
                        this.layoutControlGroupQuestionnaire.Add(_Textbox.ControlGroup);
                        controlsInDialog.Add(_Textbox);
                        _Textbox.IsInitializing = false;
                        break;
                    #endregion
                    #region Schedule
                    case QuestionTypeConstants.Schedule:
                        Schedule _Schedule = new Schedule(this.layoutControlQuestionnaire) {
                            ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId,
                            IsInitializing = true,
                            QuestionId = Convert.ToInt32(_BindingData.question_id),
                            QuestionLayoutId = Convert.ToInt32(_BindingData.questionlayout_id),
                            DefaultQuestionnaire = _Questionnaire,
                            Questionnaire = _Questionnaire,
                            InQuestionnaire = false
                        };

                        _Schedule.SubcampaignID = SubCampaignId;
                        _Schedule.DisableSelection = true;
                        _Schedule.ToolTipController = defaultToolTipController1;
                        _Schedule.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged);
                        _Schedule.ShowCalendarBookingClick += new EventHandler(oSchedule_ShowCalendarBookingClick);
                        _Schedule.BindControls();
                        this.layoutControlGroupQuestionnaire.Add(_Schedule.ControlGroup);
                        controlsInDialog.Add(_Schedule);
                        _Schedule.IsInitializing = false;
                        break;
                    #endregion
                    #region Smart Text
                    case QuestionTypeConstants.SmartText:
                        SmartText _SmartText = new SmartText(this.layoutControlQuestionnaire) {
                            ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId,
                            DisableSelection = true,
                            ToolTipController = defaultToolTipController1,
                            IsInitializing = true,
                            QuestionId = Convert.ToInt32(_BindingData.question_id),
                            QuestionLayoutId = Convert.ToInt32(_BindingData.questionlayout_id),
                            DefaultQuestionnaire = _Questionnaire,
                            Questionnaire = _Questionnaire,
                            InQuestionnaire = false
                        };

                        _SmartText.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged);
                        _SmartText.BindControls();
                        _SmartText.BindPropertyGrid();
                        this.layoutControlGroupQuestionnaire.Add(_SmartText.ControlGroup);
                        controlsInDialog.Add(_SmartText);
                        _SmartText.IsInitializing = false;
                        break;
                    #endregion
                }
            }

            /**
             * resume layout.
             */
            #region Code Logic
            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);
            //this.layoutControlGroupQuestionnaire = m_BrightSalesProperty.CampaignBooking.Questionnaire.QuestionnaireLayout;

            /**
             * 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);
            #endregion
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
0
        private void ShowDialog(string[] sFilter = null)
        {
            int rowcount = 0;
            bool hasRows = gridViewDialog.RowCount > 0;

            bool isContactLevel = true;
            bool isAccountLevel = true;

            if (sFilter != null) {
                if (sFilter.Length == 1) {
                    isContactLevel = sFilter[0].Trim() == "contact";
                    isAccountLevel = sFilter[0].Trim() == "account";
                } else if (sFilter.Length > 1) {
                    isContactLevel = sFilter[0].Trim() == "contact";
                    isAccountLevel = sFilter[1].Trim() == "account";
                }
            }

            DataTable dtDialog = null;

            if (!hasRows) {
                dtDialog = gridControlDialog.DataSource as DataTable;
                if (dtDialog == null || dtDialog.Rows.Count <= 0) {
                    DisposeGroupControls(layoutControlGroupQuestionnaire);
                    return;
                }
                rowcount = dtDialog.Rows.Count;
            } else {
                rowcount = gridViewDialog.RowCount;
            }

            DataRow row;
            CampaignQuestionnaire oQuestionnaire = null;

            layoutControlGroupQuestionnaire.BeginUpdate();
            layoutControlGroupQuestionnaire.BeginInit();
            DisposeGroupControls(layoutControlGroupQuestionnaire);
            bool hasActiveRows = false;
            for (int i = 0; i < rowcount; ++i) {
                if (hasRows)
                    row = gridViewDialog.GetDataRow(i);
                else
                    row = dtDialog.Rows[i];
                if (row.RowState == DataRowState.Deleted) continue;
                hasActiveRows = true;
                if (row["content_json"] == null || string.IsNullOrEmpty(row["content_json"].ToString())) continue;
                oQuestionnaire = CampaignQuestionnaire.InstanciateWith(row["content_json"].ToString());
                if (oQuestionnaire == null) continue;

                if (isAccountLevel && !isContactLevel) {
                    if (!oQuestionnaire.Form.Settings.DataBindings.account_level) continue;
                } else if (isContactLevel && !isAccountLevel) {
                    if (oQuestionnaire.Form.Settings.DataBindings.account_level) continue;
                } else if (!isAccountLevel && !isContactLevel) continue;

                if (row["question_text"] != null)
                    oQuestionnaire.Form.Settings.QuestionText = row["question_text"].ToString();
                if (row["question_help_text"] != null)
                    oQuestionnaire.Form.Settings.QuestionHelp = row["question_help_text"].ToString();
                if (row["language_code"] != null)
                    oQuestionnaire.Form.Settings.DataBindings.language_code = row["language_code"].ToString();

                switch (oQuestionnaire.Type.ToLower()) {
                    case QuestionTypeConstants.Dropbox:
                        Dropbox oDropbox = new Dropbox(this.layoutControlQuestionnaire);
                        oDropbox.DisableSelection = true;
                        oDropbox.ToolTipController = defaultToolTipController1;
                        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;
                        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;
                        oTextbox.Questionnaire = oQuestionnaire;
                        oTextbox.BindControls();
                        this.layoutControlGroupQuestionnaire.Add(oTextbox.ControlGroup);
                        break;
                    case QuestionTypeConstants.Schedule:
                        Schedule oSchedule = new Schedule(this.layoutControlQuestionnaire);
                        oSchedule.DisableSelection = true;
                        oSchedule.ToolTipController = defaultToolTipController1;
                        oSchedule.Questionnaire = oQuestionnaire;
                        oSchedule.BindControls();
                        this.layoutControlGroupQuestionnaire.Add(oSchedule.ControlGroup);
                        break;
                    case QuestionTypeConstants.SmartText:
                        SmartText oSmartText = new SmartText(this.layoutControlQuestionnaire);
                        oSmartText.DisableSelection = true;
                        oSmartText.ToolTipController = defaultToolTipController1;
                        oSmartText.Questionnaire = oQuestionnaire;
                        oSmartText.BindControls();
                        oSmartText.BindPropertyGrid();
                        oSmartText.BindSampleDataTable();
                        this.layoutControlGroupQuestionnaire.Add(oSmartText.ControlGroup);
                        break;

                    //case QuestionTypeConstants.Seminar:
                    //    Seminar oSeminar = new Seminar(this.layoutControlQuestionnaire);
                    //    oSeminar.DisableSelection = true;
                    //    oSeminar.ToolTipController = defaultToolTipController1;
                    //    oSeminar.Questionnaire = oQuestionnaire;
                    //    oSeminar.BindControls();
                    //    this.layoutControlGroupQuestionnaire.Add(oSeminar.ControlGroup);
                    //    break;
                }

               // break;
            }
            if (!hasActiveRows) DisposeGroupControls(layoutControlGroupQuestionnaire);
            DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem();
            emptySpaceItem1.CustomizationFormText = "emptySpaceItemBottom";
            emptySpaceItem1.Name = "emptySpaceItemBottom";
            emptySpaceItem1.ShowInCustomizationForm = false;
            emptySpaceItem1.Size = new System.Drawing.Size(0, 0);
            emptySpaceItem1.MaxSize = new System.Drawing.Size(0, 0);
            emptySpaceItem1.Text = "emptySpaceItemBottom";
            emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);

            //add bottom spacer
            this.layoutControlGroupQuestionnaire.AddItem(emptySpaceItem1);
            this.layoutControlGroupQuestionnaire.EndInit();
            this.layoutControlGroupQuestionnaire.EndUpdate();
            this.layoutControlQuestionnaire.BestFit();
        }