示例#1
0
        /// <summary>
        /// Creates and adds a new section
        /// to the question
        /// </summary>
        private void RemoveSection(int sectionNumber)
        {
            // Deletes any answer left by the user
            DeleteStateAnswersForSection(sectionNumber);

            // Decrement all user answers section numbers
            for (int i = sectionNumber + 1; i < SectionCount; i++)
            {
                ChangeStateAnswersSection(i, i - 1);
            }

            // Update local section count and remove the Guid
            // of the unwated question
            SectionCount = SectionCount - 1;
            SectionUids.RemoveAt(sectionNumber);

            // Remove unwanted section
            _sectionTable.Rows.RemoveAt((sectionNumber * 2));
            _sectionTable.Rows.RemoveAt((sectionNumber * 2));

            // Update web control's sections number
            for (int i = sectionNumber; i < _sections.Count; i++)
            {
                _sections[i].SectionNumber = _sections[i].SectionNumber - 1;
            }
        }
示例#2
0
        /// <summary>
        /// Returns the exsiting Uid of the section
        /// if it doesnt exists creates a random
        /// UId and store it in the viewstate collection
        /// for futur postbacks
        /// </summary>
        virtual protected int GetSectionUid(int sectionNumber)
        {
            int sectionUid = -1;

            if (SectionUids.Count <= sectionNumber)
            {
                for (int i = SectionUids.Count; i <= sectionNumber; i++)
                {
                    sectionUid = GetUidForSection();
                    SectionUids.Add(sectionUid);
                }
            }
            else
            {
                sectionUid = int.Parse(SectionUids[sectionNumber].ToString());
            }

            return(sectionUid);
        }
示例#3
0
        /// <summary>
        /// Inserts a new section at the given
        /// section number
        /// </summary>
        virtual protected void InsertSection(int sectionNumber)
        {
            // increment all user answers section numbers
            for (int i = SectionCount; i >= sectionNumber; i--)
            {
                ChangeStateAnswersSection(i, i + 1);
            }

            // Update web control's sections number
            for (int i = sectionNumber; i < _sections.Count; i++)
            {
                _sections[i].SectionNumber = _sections[i].SectionNumber + 1;
            }

            // Insert a new Uid for the section
            SectionUids.Insert(sectionNumber, GetUidForSection());

            // Creates a new section
            Section section = CreateSection(sectionNumber, GetSectionUid(sectionNumber));

            _sections.Insert(sectionNumber, section);
            _sectionTable.Rows.AddAt((sectionNumber) * 2, BuildRow(section, null));
            _sectionTable.Rows.AddAt((sectionNumber) * 2, BuildRow(GetSectionOptions(sectionNumber, section.SectionUid), SectionOptionStyle));
        }