Beispiel #1
0
        /// <summary>
        /// Returns only specific section number answers
        /// </summary>
        private GridAnswerDataCollection GetSectionAnswers(int sectionNumber)
        {
            GridAnswerDataCollection datas = new GridAnswerDataCollection();

            foreach (GridAnswerData data in this.GridVoterAnswers)
            {
                if (data.SectionNumber == sectionNumber)
                {
                    datas.Add(data);
                }
            }
            return(datas);
        }
Beispiel #2
0
        /// <summary>
        /// Builds a answer's overview datagrid and
        /// if required show an "add new" section
        /// </summary>
        private void BuildSingleSection()
        {
            _sectionGrid                                        = GetSectionAnswersGrid();
            _sectionGrid.ID                                     = "SectionGrid" + QuestionId;
            _sectionGrid.QuestionId                             = QuestionId;
            _sectionGrid.AddSection                            += new SectionAnswersEventHandler(AnswersGrid_AddSection);
            _sectionGrid.DeleteSection                         += new SectionAnswersEventHandler(AnswersGrid_DeleteSection);
            _sectionGrid.EditSection                           += new SectionAnswersEventHandler(AnswersGrid_EditSection);
            _sectionGrid.AddSectionLinkText                     = AddSectionLinkText;
            _sectionGrid.DeleteSectionLinkText                  = DeleteSectionLinkText;
            _sectionGrid.SectionGridAnswersHeaderStyle          = SectionGridAnswersHeaderStyle;
            _sectionGrid.SectionGridAnswersItemStyle            = SectionGridAnswersItemStyle;
            _sectionGrid.SectionGridAnswersAlternatingItemStyle = SectionGridAnswersAlternatingItemStyle;
            _sectionGrid.SectionGridAnswersStyle                = SectionGridAnswersStyle;
            _sectionGrid.EditSectionLinkText                    = EditSectionLinkText;
            _sectionGrid.RenderMode                             = RenderMode;
            _sectionGrid.MaxSections                            = MaxSections;
            _sectionGrid.GridAnswers                            = _gridAnswers;

            if (_sectionGrid != null)
            {
                QuestionTable.Rows.Add(BuildRow(_sectionGrid, null));
            }

            // Assign any previous posted answers to the grid
            GridAnswerDataCollection gridAnswers = GetGridVoterAnswers();

            if (gridAnswers != null)
            {
                _sectionGrid.GridVoterAnswers = gridAnswers;
            }

            bool firstAddNewSection = TargetSection == -1 && _sectionGrid.GridVoterAnswers.Count == 0,
                 nextAddNewSection  =
                TargetSection > -1 && _sectionGrid.GridVoterAnswers.Count > 0 ||
                TargetSection == 0 && _sectionGrid.GridVoterAnswers.Count == 0;

            // Do we need to show a new section space
            if (firstAddNewSection || nextAddNewSection)
            {
                // Is this the first time ever that we show an add new section space
                if (_sectionGrid.GridVoterAnswers.Count == 0)
                {
                    GridMode = SectionGridMode.AddNew;
                }

                AddSection(-1, 0);
                AddSubmitSectionButtons(GridMode == SectionGridMode.Edit);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Parse the answer state and returns the
        /// answers of this question
        /// </summary>
        /// <returns></returns>
        protected virtual GridAnswerDataCollection GetGridVoterAnswers()
        {
            GridAnswerDataCollection gridAnswers = null;

            if (VoterAnswersState != null)
            {
                VoterAnswersData.VotersAnswersRow[] answerState =
                    (VoterAnswersData.VotersAnswersRow[])VoterAnswersState.Select("QuestionId = " + QuestionId);
                if (answerState != null && answerState.Length > 0)
                {
                    gridAnswers = new GridAnswerDataCollection();
                    for (int i = 0; i < answerState.Length; i++)
                    {
                        gridAnswers.Add(new GridAnswerData(answerState[i].QuestionId, answerState[i].AnswerId, answerState[i].SectionNumber, answerState[i].AnswerText, (AnswerTypeMode)answerState[i].TypeMode));
                    }
                }
            }

            return(gridAnswers);
        }
Beispiel #4
0
 public SectionAnswersItemEventArgs(int sectionNumber, GridAnswerDataCollection sectionAnswers)
 {
     this.SectionNumber  = sectionNumber;
     this.SectionAnswers = sectionAnswers;
 }