예제 #1
0
 public AddAttendies(Schedule objSchedule, List<CTScSubCampaignContactList> campaignList)
 {
     InitializeComponent();
     this.m_oSchedule = objSchedule;
     this.m_oSubCampaignContactList = campaignList;
     BindGrid();
 }
예제 #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;
        }
예제 #3
0
        private void oSchedule_ShowCalendarBookingClick(object sender, EventArgs e)
        {
            Schedule obj = sender as Schedule;
            if (obj == null)
                return;

            objScheduleComponent = obj;
            frmSchedulingPopup = new FrmSchedulingPopup();
            frmSchedulingPopup.SetBreadCrumb(BreadCrumbText);
            frmSchedulingPopup.CurrentScheduleID = obj.CurrentSelectedMeeting;

            if (SelectedContact != null)
                frmSchedulingPopup.CurrentContactID = SelectedContact.id;

            frmSchedulingPopup.CurrentAccountID = AccountId;
            frmSchedulingPopup.SubCampaignID = SubCampaignId;
            frmSchedulingPopup.ShowDialog();
            if (frmSchedulingPopup.CreatedScheduleID > 0) {
                obj.SetCreatedMeetingSchedule(frmSchedulingPopup.CreatedScheduleID);
                obj.Questionnaire.Form.Settings.DataBindings.schedule_id = frmSchedulingPopup.CreatedScheduleID.ToString();
            }
            obj.RefreshSchedMeetingList();
        }
예제 #4
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
        }
예제 #5
0
        private void propertyGridControl1_CellValueChanged(object sender, DevExpress.XtraVerticalGrid.Events.CellValueChangedEventArgs e)
        {
            CampaignQuestionnaire oQuestionnaire = propertyGridControl1.SelectedObject as CampaignQuestionnaire;
            if (oQuestionnaire == null) return;
            propertyGridControl1.SelectedObject = null;
            propertyGridControl1.SelectedObject = oQuestionnaire;

            this.layoutControlGroupPreview.BeginUpdate();
            this.layoutControlGroupPreview.BeginInit();
            //this.layoutControlGroupPreview.Clear();
            DisposeGroupControls(this.layoutControlGroupPreview);
            switch (oQuestionnaire.Type.ToLower()) {
                case QuestionTypeConstants.Dropbox:
                    Dropbox oDropbox = new Dropbox(this.layoutControlPreview);
                    oDropbox.DisableSelection = true;
                    oDropbox.ToolTipController = defaultToolTipController1;
                    oDropbox.Questionnaire = oQuestionnaire;
                    oDropbox.BindControls();
                    this.layoutControlGroupPreview.Add(oDropbox.ControlGroup);
                    break;
                case QuestionTypeConstants.MultipleChoice:
                    Multiplechoice oMultipleChoice = new Multiplechoice(this.layoutControlPreview);
                    oMultipleChoice.DisableSelection = true;
                    oMultipleChoice.Questionnaire = oQuestionnaire;
                    oMultipleChoice.BindControls();
                    this.layoutControlGroupPreview.Add(oMultipleChoice.ControlGroup);
                    break;
                case QuestionTypeConstants.Textbox:
                    Textbox oTextbox = new Textbox(this.layoutControlPreview);
                    oTextbox.DisableSelection = true;
                    oTextbox.Questionnaire = oQuestionnaire;
                    oTextbox.BindControls();
                    this.layoutControlGroupPreview.Add(oTextbox.ControlGroup);
                    break;
                case QuestionTypeConstants.Schedule:
                    Schedule oSchedule = new Schedule(this.layoutControlPreview);
                    oSchedule.DisableSelection = true;
                    oSchedule.Questionnaire = oQuestionnaire;
                    //TODO: Change this during the implementation of component user for account_id
                    oSchedule.Questionnaire.Form.Settings.DataBindings.account_id = "1";
                    oSchedule.BindControls();
                    this.layoutControlGroupPreview.Add(oSchedule.ControlGroup);
                    break;
                case QuestionTypeConstants.SmartText:
                    SmartText oSmartText = new SmartText(this.layoutControlPreview);
                    oSmartText.DisableSelection = true;
                    oSmartText.ToolTipController = defaultToolTipController1;
                    oSmartText.Questionnaire = oQuestionnaire;
                    oSmartText.BindPropertyGrid();
                    oSmartText.BindSampleDataTable();
                    this.layoutControlGroupPreview.Add(oSmartText.ControlGroup);
                    break;
                //case QuestionTypeConstants.Seminar:
                //    Seminar oSeminar = new Seminar(this.layoutControlPreview);
                //    oSeminar.DisableSelection = true;
                //    oSeminar.Questionnaire = oQuestionnaire;
                //    //TODO: Change this during the implementation of component user for account_id
                //    oSeminar.Questionnaire.Form.Settings.DataBindings.account_id = "1";
                //    oSeminar.BindControls();
                //    this.layoutControlGroupPreview.Add(oSeminar.ControlGroup);
                //    break;
            }
            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.Text = "emptySpaceItemBottom";
            emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);

            //add bottom spacer
            this.layoutControlGroupPreview.AddItem(emptySpaceItem1);
            this.layoutControlGroupPreview.EndInit();
            this.layoutControlGroupPreview.EndUpdate();
        }
예제 #6
0
        private void BindPropertyGrid(string questionTypeConstants, CampaignQuestionnaire Questionnaire)
        {
            CampaignQuestionnaire oQuestionnaire = null;

            if (Questionnaire != null) {
                oQuestionnaire = Questionnaire;
                if(oQuestionnaire.Form.Settings.Label == "[Sample label]")
                    oQuestionnaire.Form.Settings.Label = "";
            } else {
                oQuestionnaire = CampaignQuestionnaire.Instanciate(questionTypeConstants);
                oQuestionnaire.Form.Settings.Label = "";
            }
            int langId = 0;
            var obj = gridViewQuestion.GetFocusedRow();
            if (obj != null) {
                DataRowView drRowView = (DataRowView)obj;
                oQuestionnaire.Form.Settings.QuestionText = drRowView.Row["question"].ToString();
                oQuestionnaire.Form.Settings.QuestionHelp = drRowView.Row["helptext"].ToString();
                var langitem = lookUpEditLanguage.EditValue;
                if (langitem != null) {
                    langId = int.Parse(langitem.ToString());
                    var lang = BPContext.languages.FirstOrDefault(x => x.id == langId);
                    if (lang != null)
                        oQuestionnaire.Form.Settings.DataBindings.language_code = lang.code;
                }
            }
            var binding = oQuestionnaire.Form.Settings.DataBindings;
            if (string.IsNullOrEmpty(binding.language_code))
                binding.language_code = "SE";

            binding.account_level = (bool)rgLevel.EditValue;

            currentType = questionTypeConstants;
            this.layoutControlGroupPreview.BeginUpdate();
            //this.layoutControlGroupPreview.Clear();
            DisposeGroupControls(this.layoutControlGroupPreview);
            if (questionTypeConstants == QuestionTypeConstants.Dropbox) {
                Dropbox oDropbox = new Dropbox(this.layoutControlPreview);
                oDropbox.DisableSelection = true;
                oDropbox.ToolTipController = defaultToolTipController1;
                oDropbox.Questionnaire = oQuestionnaire;
                oDropbox.BindControls();
                this.layoutControlGroupPreview.Add(oDropbox.ControlGroup);
            } else if (questionTypeConstants == QuestionTypeConstants.Textbox) {
                Textbox oTextbox = new Textbox(this.layoutControlPreview);
                oTextbox.DisableSelection = true;
                oTextbox.ToolTipController = defaultToolTipController1;
                oTextbox.Questionnaire = oQuestionnaire;
                oTextbox.BindControls();
                this.layoutControlGroupPreview.Add(oTextbox.ControlGroup);
            } else if (questionTypeConstants == QuestionTypeConstants.MultipleChoice) {
                Multiplechoice oMultipleChoice = new Multiplechoice(this.layoutControlPreview);
                oMultipleChoice.DisableSelection = true;
                oMultipleChoice.ToolTipController = defaultToolTipController1;
                oMultipleChoice.Questionnaire = oQuestionnaire;
                oMultipleChoice.BindControls();
                this.layoutControlGroupPreview.Add(oMultipleChoice.ControlGroup);
            } else if (questionTypeConstants == QuestionTypeConstants.Schedule) {
                Schedule oSchedule = new Schedule(this.layoutControlPreview);
                oSchedule.DisableSelection = true;
                oSchedule.ToolTipController = defaultToolTipController1;
                oSchedule.Questionnaire = oQuestionnaire;
                //TODO: Change this during the implementation of component user for account_id
                //oSchedule.Questionnaire.Form.Settings.DataBindings.account_id = "1";
                oSchedule.BindControls();
                this.layoutControlGroupPreview.Add(oSchedule.ControlGroup);
            }
            else if (questionTypeConstants == QuestionTypeConstants.SmartText) {
                SmartText oSmartText = new SmartText(this.layoutControlPreview);
                oSmartText.DisableSelection = true;
                oSmartText.ToolTipController = defaultToolTipController1;
                oSmartText.Questionnaire = oQuestionnaire;
                oSmartText.BindPropertyGrid();
                oSmartText.BindSampleDataTable();
                this.layoutControlGroupPreview.Add(oSmartText.ControlGroup);
            }

            //else if (questionTypeConstants == QuestionTypeConstants.Seminar) {
            //    Seminar oSeminar = new Seminar(this.layoutControlPreview);
            //    oSeminar.DisableSelection = true;
            //    oSeminar.ToolTipController = defaultToolTipController1;
            //    oSeminar.Questionnaire = oQuestionnaire;
            //    //TODO: Change this during the implementation of component user for account_id
            //    oSeminar.Questionnaire.Form.Settings.DataBindings.account_id = "1";
            //    oSeminar.BindControls();
            //    this.layoutControlGroupPreview.Add(oSeminar.ControlGroup);
            //}
            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.Text = "emptySpaceItemBottom";
            emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);

            //add bottom spacer
            this.layoutControlGroupPreview.AddItem(emptySpaceItem1);
            this.layoutControlGroupPreview.EndUpdate();
            this.layoutControlPreview.BestFit();
            var answerOptionList = oQuestionnaire.Form.Settings.AnswerOptions;
            propertyGridControl1.SelectedObject = oQuestionnaire;
        }
예제 #7
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            //dummy values for question_id
            //int dropboxId = 1, textboxId = 2, multipleChoiceId = 3;
            BPContext = new BrightPlatformEntities(UserSession.EntityConnection);
            //var resourceList = BPContext.FIGetResources(3).ToList();
            //List<int?> resourceids = new List<int?>();
            //resourceList.ForEach(delegate(CTResources r) {
            //    resourceids.Add(r.resource_id);
            //});
            //var schedList = BPContext.schedules.Where(x => resourceids.Contains(x.resource_id)).ToList();

            this.layoutControlGroupQuestionnaire.BeginUpdate();

            ////add dropbox
            //Dropbox oDropbox = new Dropbox(this.layoutControlQuestionnaire);
            //oDropbox.ToolTipController = defaultToolTipController1;
            //oDropbox.Questionnaire = CampaignQuestionnaire.Instanciate(QuestionTypeConstants.Dropbox);
            ////oDropbox.Questionnaire = Business.BusinessAnswer.BindAnswer(oDropbox.Questionnaire, BPContext, dropboxId);
            //oDropbox.BindControls();
            //this.layoutControlGroupQuestionnaire.Add(oDropbox.ControlGroup);

            ////add textbox
            //Textbox oTextbox = new Textbox(this.layoutControlQuestionnaire);
            //oTextbox.Questionnaire = CampaignQuestionnaire.Instanciate(QuestionTypeConstants.Textbox);
            ////oTextbox.Questionnaire = Business.BusinessAnswer.BindAnswer(oTextbox.Questionnaire, BPContext, textboxId);
            //oTextbox.BindControls();
            //this.layoutControlGroupQuestionnaire.Add(oTextbox.ControlGroup);

            ////add multiplechoice
            Multiplechoice oMultipleChoice = new Multiplechoice(this.layoutControlQuestionnaire);
            oMultipleChoice.Questionnaire = CampaignQuestionnaire.Instanciate(QuestionTypeConstants.MultipleChoice);
            //oMultipleChoice.Questionnaire = Business.BusinessAnswer.BindAnswer(oMultipleChoice.Questionnaire, BPContext, multipleChoiceId);
            oMultipleChoice.BindControls();
            this.layoutControlGroupQuestionnaire.Add(oMultipleChoice.ControlGroup);

            //add schedule
            Schedule oSchedule = new Schedule(this.layoutControlQuestionnaire);
            oSchedule.Questionnaire = CampaignQuestionnaire.Instanciate(QuestionTypeConstants.Schedule);
            oSchedule.Questionnaire.Form.Settings.DataBindings.account_id = "1";
            //contact callerContact = BPContext.contacts.FirstOrDefault(x=>x.id == 35758);
            //if (callerContact != null)
            //    oSchedule.SetCurrentCaller(callerContact, 1);
            //oSchedule.ShowCalendarBookingClick += new EventHandler(oSchedule_ShowCalendarBookingClick);
            //oSchedule.Questionnaire = Business.BusinessAnswer.BindAnswer(oSchedule.Questionnaire, BPContext, multipleChoiceId);
            oSchedule.BindControls();
            this.layoutControlGroupQuestionnaire.Add(oSchedule.ControlGroup);

            //add seminar
            //Seminar oSeminar = new Seminar(this.layoutControlQuestionnaire);
            //oSeminar.Questionnaire = CampaignQuestionnaire.Instanciate(QuestionTypeConstants.Seminar);
            //oSeminar.Questionnaire.Form.Settings.DataBindings.account_id = "1";
            ////oSeminar.Questionnaire = Business.BusinessAnswer.BindAnswer(oSchedule.Questionnaire, BPContext, multipleChoiceId);
            //oSeminar.BindControls();
            //this.layoutControlGroupQuestionnaire.Add(oSeminar.ControlGroup);

            //add bottom spacer
            this.layoutControlGroupQuestionnaire.AddItem(emptySpaceItem1);
            this.layoutControlGroupQuestionnaire.EndUpdate();
        }
예제 #8
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();
        }
예제 #9
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();
        }
예제 #10
0
 private void oSchedule_ShowCalendarBookingClick(object sender, EventArgs e)
 {
     var obj = sender as Schedule;
     if (obj != null) {
         objScheduleComponent = obj;
         //WaitDialog.CreateWaitDialog("Loading Schedule Dialog...");
         frmSchedulingPopup = new FrmSchedulingPopup();
         frmSchedulingPopup.SetBreadCrumb(simpleLabelItemBreadCrumb.Text);
         frmSchedulingPopup.CurrentScheduleID = obj.CurrentSelectedMeeting;
         if(m_oContactView.SelectedContact != null)
             frmSchedulingPopup.CurrentContactID = m_oContactView.SelectedContact.id;
         frmSchedulingPopup.CurrentAccountID = oAppointment.AccountId;
         //frmSchedulingPopup.AccountID = oAppointment.AccountId;
         //frmSchedulingPopup.ContactID = m_oContactView.SelectedContact.id;
         frmSchedulingPopup.SubCampaignID = oAppointment.SubCampaignId;
         if (frmSchedulingPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
             if (frmSchedulingPopup.CreatedScheduleID > 0) {
                 obj.SetCreatedMeetingSchedule(frmSchedulingPopup.CreatedScheduleID);
                 obj.Questionnaire.Form.Settings.DataBindings.schedule_id = frmSchedulingPopup.CreatedScheduleID.ToString();
             }
         }
     }
 }
예제 #11
0
        private void BindPropertyGrid(string questionTypeConstants, CampaignQuestionnaire Questionnaire)
        {
            CampaignQuestionnaire oQuestionnaire = null;
            if (Questionnaire != null) {
                oQuestionnaire = Questionnaire;
            } else {
                oQuestionnaire = CampaignQuestionnaire.Instanciate(questionTypeConstants);
            }
            currentType = questionTypeConstants;
            this.layoutControlGroupPreview.BeginUpdate();
            //this.layoutControlGroupPreview.Clear();
            DisposeGroupControls(this.layoutControlGroupPreview);
            if (questionTypeConstants == QuestionTypeConstants.Dropbox) {
                Dropbox oDropbox = new Dropbox(this.layoutControlPreview);
                oDropbox.DisableSelection = true;
                oDropbox.ToolTipController = defaultToolTipController1;
                oDropbox.Questionnaire = oQuestionnaire;
                oDropbox.BindControls();
                this.layoutControlGroupPreview.Add(oDropbox.ControlGroup);
            } else if (questionTypeConstants == QuestionTypeConstants.Textbox) {
                Textbox oTextbox = new Textbox(this.layoutControlPreview);
                oTextbox.DisableSelection = true;
                oTextbox.ToolTipController = defaultToolTipController1;
                oTextbox.Questionnaire = oQuestionnaire;
                oTextbox.BindControls();
                this.layoutControlGroupPreview.Add(oTextbox.ControlGroup);
            } else if (questionTypeConstants == QuestionTypeConstants.MultipleChoice) {
                Multiplechoice oMultipleChoice = new Multiplechoice(this.layoutControlPreview);
                oMultipleChoice.DisableSelection = true;
                oMultipleChoice.ToolTipController = defaultToolTipController1;
                oMultipleChoice.Questionnaire = oQuestionnaire;
                oMultipleChoice.BindControls();
                this.layoutControlGroupPreview.Add(oMultipleChoice.ControlGroup);
            } else if (questionTypeConstants == QuestionTypeConstants.Schedule) {
                Schedule oSchedule = new Schedule(this.layoutControlPreview);
                oSchedule.DisableSelection = true;
                oSchedule.ToolTipController = defaultToolTipController1;
                oSchedule.Questionnaire = oQuestionnaire;
                //TODO: Change this during the implementation of component user for account_id
                oSchedule.Questionnaire.Form.Settings.DataBindings.account_id = "1";
                oSchedule.BindControls();
                this.layoutControlGroupPreview.Add(oSchedule.ControlGroup);
            }
            //else if (questionTypeConstants == QuestionTypeConstants.Seminar) {
            //    Seminar oSeminar = new Seminar(this.layoutControlPreview);
            //    oSeminar.DisableSelection = true;
            //    oSeminar.ToolTipController = defaultToolTipController1;
            //    oSeminar.Questionnaire = oQuestionnaire;
            //    //TODO: Change this during the implementation of component user for account_id
            //    oSeminar.Questionnaire.Form.Settings.DataBindings.account_id = "1";
            //    oSeminar.BindControls();
            //    this.layoutControlGroupPreview.Add(oSeminar.ControlGroup);
            //}
            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.Text = "emptySpaceItemBottom";
            emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);

            //add bottom spacer
            this.layoutControlGroupPreview.AddItem(emptySpaceItem1);
            this.layoutControlGroupPreview.EndUpdate();
            this.layoutControlPreview.BestFit();
            var answerOptionList = oQuestionnaire.Form.Settings.AnswerOptions;
            repositoryItemButtonEditAnswerOptions.Click += new EventHandler(repositoryItemButtonEditAnswerOptions_ButtonClick);
            propertyGridControl1.DefaultEditors.Add(typeof(List<AnswerOption>), repositoryItemButtonEditAnswerOptions);
            propertyGridControl1.SelectedObject = oQuestionnaire;
        }
예제 #12
0
        private void simpleButtonShowDialog_Click(object sender, EventArgs e)
        {
            GridView view = gridViewDialog;
            if (view == null || view.RowCount == 0) return;

            DataRow row;
            CampaignQuestionnaire oQuestionnaire = null;

            layoutControlGroupQuestionnaire.BeginUpdate();
            layoutControlGroupQuestionnaire.BeginInit();
            DisposeGroupControls(layoutControlGroupQuestionnaire);

            for (int i = 0; i < view.RowCount; i++) {
                row = view.GetDataRow(i);
                if (row["content_json"] == null || string.IsNullOrEmpty(row["content_json"].ToString())) continue;
                oQuestionnaire = CampaignQuestionnaire.InstanciateWith(row["content_json"].ToString());
                if (oQuestionnaire == null) 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();
                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.Seminar:
                    //    Seminar oSeminar = new Seminar(this.layoutControlQuestionnaire);
                    //    oSeminar.DisableSelection = true;
                    //    oSeminar.ToolTipController = defaultToolTipController1;
                    //    oSeminar.Questionnaire = oQuestionnaire;
                    //    oSeminar.BindControls();
                    //    this.layoutControlGroupQuestionnaire.Add(oSeminar.ControlGroup);
                    //    break;
                }
            }
            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.Text = "emptySpaceItemBottom";
            emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);

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