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; }
public void LoadDialogQuestionnaires(bool pDisposeQuestionnaire = false) { this.RunAssync(() => { bool _ReloadContacts = false; if (pDisposeQuestionnaire) { m_BrightSalesProperty.CampaignBooking.Questionnaire.State = SelectionProperty.DialogEditorState.Empty; this.DisposeGroupControls(layoutControlGroupQuestionnaire); _ReloadContacts = true; } m_AnswerBindingOnProgress = true; m_HasMustSaveDefaultValues = false; this.ResetToDefaultState(); this.BindDialogManagerData(_ReloadContacts); //marker... using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection)) { /** * get and set bindings. */ 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 m_lstQuestionnaireDialog = new List<CampaignQuestionnaire>(); m_lstQuestionLayoutIds = new List<string>(); CampaignQuestionnaire _Questionnaire = null; DataBindings _BindingData = 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()); _Questionnaire = CampaignQuestionnaire.InstanciateWith(_jsonData); if (_Questionnaire != null) { m_lstQuestionnaireDialog.Add(_Questionnaire); _BindingData = _Questionnaire.Form.Settings.DataBindings; if (_BindingData != null) { if (!string.IsNullOrEmpty(_BindingData.questionlayout_id)) m_lstQuestionLayoutIds.Add(_BindingData.questionlayout_id); } } }); } #endregion int? _CampaignId = CampaignId; int? _AccountId = AccountId; int? _ContactId = SelectedContact == null || SelectedContact.id <= 0 ? (int?)null : SelectedContact.id; int? _DialogId = m_oDialog.id; /** * create dialog if not yet been initialized. * we only create dialog once, for the succeeding loads to be faster. */ if (m_BrightSalesProperty.CampaignBooking.Questionnaire.State == SelectionProperty.DialogEditorState.Empty) { this.CreateQuestionnaire(); m_BrightSalesProperty.CampaignBooking.Questionnaire.State = SelectionProperty.DialogEditorState.Loaded; } /** * get the list of answers. */ #region Code Logic var _lstAnswers = _efDbContext.FIGetDialogAnswers( string.Join(",", m_lstQuestionLayoutIds.Distinct().ToArray()), _CampaignId, _AccountId, _ContactId, _DialogId ).ToList().Clone(); IsInitializingDialogComponents = true; IsInitializedComponentsValid = false; List<int> _lstAnswerIds = new List<int>(); CTDialogAnswers _dlgAnswer = null; for (int i = 0; i < m_lstQuestionnaireDialog.Count; ++i) { _Questionnaire = m_lstQuestionnaireDialog[i]; _BindingData = _Questionnaire.Form.Settings.DataBindings; /** * if questionnaire is contact level and there are no contacts, * just by pass saving. */ if (!_BindingData.account_level && m_BrightSalesProperty.CampaignBooking.ContactCount < 1) continue; if (_BindingData.account_level) { _dlgAnswer = _lstAnswers.FirstOrDefault(p => p.questionlayout_id == int.Parse(_BindingData.questionlayout_id) && p.campaign_id == _CampaignId && p.account_id == _AccountId && p.account_level == true && p.dialog_id == _DialogId ); } else { _dlgAnswer = _lstAnswers.FirstOrDefault(p => p.questionlayout_id == int.Parse(_BindingData.questionlayout_id) && p.campaign_id == _CampaignId && p.account_id == _AccountId && p.contact_id == _ContactId && p.account_level == false && p.dialog_id == _DialogId ); } if (_dlgAnswer != null) { _BindingData.answer_id = _dlgAnswer.id.ToString(); _BindingData.account_level = _dlgAnswer.account_level; _BindingData.contact_id = _ContactId.ToString(); _lstAnswerIds.Add(_dlgAnswer.id); } else { m_HasMustSaveDefaultValues = true; _BindingData.language_code = "SE"; _BindingData.account_id = _AccountId.ToString(); _BindingData.campaign_id = _CampaignId.ToString(); _BindingData.contact_id = _ContactId.ToString(); _BindingData.dialog_id = _DialogId.ToString(); } _Questionnaire = null; } #endregion /** * assign eash answers to its respective dialog component. */ #region Code Logic int _DialogCount = 0; var _lstDialogAnswers = _efDbContext.answers.Include("sub_answers").Where(i => _lstAnswerIds.Contains(i.id)); IQuestionnaire _IQuestionnaire = null; foreach (BaseLayoutItem item in this.layoutControlGroupQuestionnaire.Items) { if (item.IsGroup) { if (item.Tag != null) { /** * initialize and set defaults. */ _IQuestionnaire = item.Tag as IQuestionnaire; _IQuestionnaire.IsInitializing = false; _IQuestionnaire.InQuestionnaire = false; _IQuestionnaire.DisableSelection = true; _IQuestionnaire.HasMustSaveDefaultValues = false; _IQuestionnaire.AccountId = 0; _IQuestionnaire.ContactId = 0; _IQuestionnaire.ContactPerson = null; _IQuestionnaire.UserId = 0; _IQuestionnaire.UserName = string.Empty; _IQuestionnaire.ContactList = new List<CTScSubCampaignContactList>(); /** * check if questionnaire exists. */ _Questionnaire = m_lstQuestionnaireDialog[_DialogCount]; _BindingData = _Questionnaire.Form.Settings.DataBindings; #region Code //if (_IQuestionnaire.DefaultQuestionnaire.Form.Settings.DataBindings.account_level) { // _Questionnaire = m_lstQuestionnaireDialog.FirstOrDefault(i => // i.Form.Settings.DataBindings.questionlayout_id == _IQuestionnaire.DefaultQuestionnaire.Form.Settings.DataBindings.questionlayout_id && // i.Form.Settings.DataBindings.campaign_id == _CampaignId.ToString() && // i.Form.Settings.DataBindings.account_id == _AccountId.ToString() && // i.Form.Settings.DataBindings.account_level == true && // i.Form.Settings.DataBindings.dialog_id == _DialogId.ToString() // ); //} //else { // _Questionnaire = m_lstQuestionnaireDialog.FirstOrDefault(i => // i.Form.Settings.DataBindings.questionlayout_id == _IQuestionnaire.DefaultQuestionnaire.Form.Settings.DataBindings.questionlayout_id && // i.Form.Settings.DataBindings.campaign_id == _CampaignId.ToString() && // i.Form.Settings.DataBindings.account_id == _AccountId.ToString() && // i.Form.Settings.DataBindings.contact_id == _ContactId.ToString() && // i.Form.Settings.DataBindings.account_level == true && // i.Form.Settings.DataBindings.dialog_id == _DialogId.ToString() // ); //} //if (_BindingData.account_level) //{ // _dlgAnswer = _lstAnswers.FirstOrDefault(p => // p.questionlayout_id == int.Parse(_BindingData.questionlayout_id) && // p.campaign_id == _CampaignId && // p.account_id == _AccountId && // p.account_level == true && // p.dialog_id == _DialogId // ); //} //else //{ // _dlgAnswer = _lstAnswers.FirstOrDefault(p => // p.questionlayout_id == int.Parse(_BindingData.questionlayout_id) && // p.campaign_id == _CampaignId && // p.account_id == _AccountId && // p.contact_id == _ContactId && // p.account_level == false && // p.dialog_id == _DialogId // ); //} //_Questionnaire = m_lstQuestionnaireDialog.FirstOrDefault(i => // i.Form.Settings.DataBindings.questionlayout_id == _IQuestionnaire.DefaultQuestionnaire.Form.Settings.DataBindings.questionlayout_id && // i.Form.Settings.DataBindings.campaign_id == _CampaignId.ToString() && // i.Form.Settings.DataBindings.account_id == _AccountId.ToString() && // i.Form.Settings.DataBindings.contact_id == _ContactId.ToString() && // i.Form.Settings.DataBindings.dialog_id == _DialogId.ToString() //); //if (_Questionnaire == null) { // _IQuestionnaire.ControlGroup.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; // _DialogCount++; // continue; //} //_BindingData = _IQuestionnaire.DefaultQuestionnaire.Form.Settings.DataBindings; // = _IQuestionnaire.DefaultQuestionnaire.Form.Settings.DataBindings; //if (!_BindingData.account_level && (_ContactId == null || _ContactId == 0)) { //_BindingData = _Questionnaire.Form.Settings.DataBindings; #endregion if (!_BindingData.account_level && m_BrightSalesProperty.CampaignBooking.ContactCount < 1) { _IQuestionnaire.ControlGroup.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; _DialogCount++; continue; } _dlgAnswer = null; if (!string.IsNullOrEmpty(_BindingData.answer_id)) _dlgAnswer = _lstAnswers.FirstOrDefault(e => e.id == int.Parse(_BindingData.answer_id)); _IQuestionnaire.IsInitializing = true; _IQuestionnaire.InQuestionnaire = true; _IQuestionnaire.DisableSelection = true; _IQuestionnaire.HasMustSaveDefaultValues = false; _IQuestionnaire.AccountId = m_BrightSalesProperty.CommonProperty.CurrentWorkedAccountId; _IQuestionnaire.ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId; _IQuestionnaire.ContactPerson = _ContactId == null ? null : (_ContactId > 0 ? SelectedContact : null); _IQuestionnaire.UserId = UserSession.CurrentUser.UserId; _IQuestionnaire.UserName = UserSession.CurrentUser.UserFullName; _IQuestionnaire.ContactList = m_BrightSalesProperty.CampaignBooking.ContactList; if (_IQuestionnaire.ControlGroup.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Never) _IQuestionnaire.ControlGroup.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; if (_dlgAnswer != null) { int _AnswerId = Convert.ToInt32(_BindingData.answer_id); var _AnswerData = _lstDialogAnswers.FirstOrDefault(i => i.id == _AnswerId); _IQuestionnaire.Questionnaire = BusinessAnswer.SetQuestionnaireData(_Questionnaire, _AnswerData); //_IQuestionnaire.Questionnaire = BusinessAnswer.SetQuestionnaireData(_IQuestionnaire.DefaultQuestionnaire, _AnswerData); } else { _IQuestionnaire.Questionnaire = _Questionnaire; // _IQuestionnaire.DefaultQuestionnaire; _IQuestionnaire.HasMustSaveDefaultValues = true; } _IQuestionnaire.Render(); if (_IQuestionnaire.ControlFooter != null && _dlgAnswer != null) _IQuestionnaire.ControlFooter.SetSourceTooltip(_dlgAnswer.source_contact, _dlgAnswer.source_last_modified_by, _dlgAnswer.source_last_modified_on.Value.ToString("yyyy-MM-dd")); _IQuestionnaire.IsInitializing = false; _DialogCount++; } } } #endregion } this.SetEditableComponent(false); IsInitializedComponentsValid = this.ValidateDialog(false); 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; }); }