示例#1
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;
        }
示例#2
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();
        }
示例#3
0
        private void ShowDialog(string[] sFilter = null)
        {
            int rowcount = 0;
            bool hasRows = gridViewDialog.RowCount > 0;

            bool isContactLevel = true;
            bool isAccountLevel = true;

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

            DataTable dtDialog = null;

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

            DataRow row;
            CampaignQuestionnaire oQuestionnaire = null;

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

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

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

                switch (oQuestionnaire.Type.ToLower()) {
                    case QuestionTypeConstants.Dropbox:
                        Dropbox oDropbox = new Dropbox(this.layoutControlQuestionnaire);
                        oDropbox.DisableSelection = true;
                        oDropbox.ToolTipController = defaultToolTipController1;
                        oDropbox.Questionnaire = oQuestionnaire;
                        oDropbox.BindControls();
                        this.layoutControlGroupQuestionnaire.Add(oDropbox.ControlGroup);
                        break;
                    case QuestionTypeConstants.MultipleChoice:
                        Multiplechoice oMultipleChoice = new Multiplechoice(this.layoutControlQuestionnaire);
                        oMultipleChoice.DisableSelection = true;
                        oMultipleChoice.ToolTipController = defaultToolTipController1;
                        oMultipleChoice.Questionnaire = oQuestionnaire;
                        oMultipleChoice.BindControls();
                        this.layoutControlGroupQuestionnaire.Add(oMultipleChoice.ControlGroup);
                        break;
                    case QuestionTypeConstants.Textbox:
                        Textbox oTextbox = new Textbox(this.layoutControlQuestionnaire);
                        oTextbox.DisableSelection = true;
                        oTextbox.ToolTipController = defaultToolTipController1;
                        oTextbox.Questionnaire = oQuestionnaire;
                        oTextbox.BindControls();
                        this.layoutControlGroupQuestionnaire.Add(oTextbox.ControlGroup);
                        break;
                    case QuestionTypeConstants.Schedule:
                        Schedule oSchedule = new Schedule(this.layoutControlQuestionnaire);
                        oSchedule.DisableSelection = true;
                        oSchedule.ToolTipController = defaultToolTipController1;
                        oSchedule.Questionnaire = oQuestionnaire;
                        oSchedule.BindControls();
                        this.layoutControlGroupQuestionnaire.Add(oSchedule.ControlGroup);
                        break;
                    case QuestionTypeConstants.SmartText:
                        SmartText oSmartText = new SmartText(this.layoutControlQuestionnaire);
                        oSmartText.DisableSelection = true;
                        oSmartText.ToolTipController = defaultToolTipController1;
                        oSmartText.Questionnaire = oQuestionnaire;
                        oSmartText.BindControls();
                        oSmartText.BindPropertyGrid();
                        oSmartText.BindSampleDataTable();
                        this.layoutControlGroupQuestionnaire.Add(oSmartText.ControlGroup);
                        break;

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

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

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