示例#1
0
 /// <summary>
 /// Post an event to notify subscribers that a section
 /// need to be edited
 /// </summary>
 protected virtual void OnSectionEdit(SectionAnswersItemEventArgs e)
 {
     if (this.EditSection != null)
     {
         this.EditSection(this, e);
     }
 }
示例#2
0
 /// <summary>
 /// Post an event to notify subscribers that a section
 /// has been deleted
 /// </summary>
 protected virtual void OnSectionDelete(SectionAnswersItemEventArgs e)
 {
     if (this.DeleteSection != null)
     {
         this.DeleteSection(this, e);
     }
 }
示例#3
0
 /// <summary>
 /// A new section has been requested on the grid.
 /// Show a "new section" area
 /// </summary>
 protected virtual void AnswersGrid_AddSection(object sender, SectionAnswersItemEventArgs e)
 {
     _sectionTable.Controls.Clear();
     AddSection(-1, 0);
     SectionCount  = 0;
     TargetSection = int.Parse(e.SectionNumber.ToString());
     AddSubmitSectionButtons(false);
     GridMode = SectionGridMode.AddNew;
 }
示例#4
0
        /// <summary>
        /// A section has been removed on the grid.
        /// Update the target section number if any was setup or
        /// show a "new section" area if the last section has
        /// been removed on the grid
        /// </summary>
        protected virtual void AnswersGrid_DeleteSection(object sender, SectionAnswersItemEventArgs e)
        {
            int deletedSection = int.Parse(e.SectionNumber.ToString());

            // Is the deleted section being in edit mode ?
            if (GridMode == SectionGridMode.Edit && TargetSection == deletedSection)
            {
                //Removes it
                SectionCount  = -1;
                TargetSection = -1;
                GridMode      = SectionGridMode.None;
                _sectionTable.Controls.Clear();

                // Did the user delete the last section ?
                if (GetSectionCountFromAnswers(_postedAnswers) < 1)
                {
                    AddSection(-1, 0);
                    AddSubmitSectionButtons(GridMode == SectionGridMode.Edit);
                    SectionCount  = 0;
                    TargetSection = 0;
                }
            }
            else
            {
                // Is an add section is already displayed ?
                if (_sections.Count > 0)
                {
                    // Is the target section
                    if (TargetSection > 0 && TargetSection >= deletedSection)
                    {
                        TargetSection--;

                        // Updates the button arguments
                        AddSubmitSectionButtons(GridMode == SectionGridMode.Edit);
                    }
                }
                else
                {
                    // Did the user delete the last section ?
                    if (GetSectionCountFromAnswers(_postedAnswers) < 1)
                    {
                        AddSection(-1, 0);
                        AddSubmitSectionButtons(GridMode == SectionGridMode.Edit);
                        SectionCount  = 0;
                        TargetSection = 0;
                    }
                }
            }
        }
示例#5
0
        /// <summary>
        /// A new section has been requested for edit
        /// Show a "new section" area with the section's answers
        /// </summary>
        protected virtual void AnswersGrid_EditSection(object sender, SectionAnswersItemEventArgs e)
        {
            _sectionTable.Controls.Clear();

            if (e.SectionAnswers != null)
            {
                PostedAnswerDataCollection postedAnswers = new PostedAnswerDataCollection();
                foreach (GridAnswerData answer in e.SectionAnswers)
                {
                    if (VoterAnswersState == null)
                    {
                        VoterAnswersData voterAnswersData = new VoterAnswersData();
                        voterAnswersData.EnforceConstraints = false;
                        VoterAnswersState = voterAnswersData.VotersAnswers;
                    }

                    VoterAnswersData.VotersAnswersRow voterAnswer = VoterAnswersState.NewVotersAnswersRow();
                    voterAnswer.AnswerId      = answer.AnswerId;
                    voterAnswer.QuestionId    = QuestionId;
                    voterAnswer.SectionNumber = -1;
                    voterAnswer.AnswerText    = answer.FieldText;
                    voterAnswer.VoterId       = -1;
                    VoterAnswersState.AddVotersAnswersRow(voterAnswer);
                }
            }

            // Dont use any default answers as we have
            // setup an existing answer set
            EnableAnswersDefault = false;

            AddSection(-1, 0);
            SectionCount  = 0;
            TargetSection = int.Parse(e.SectionNumber.ToString());
            AddSubmitSectionButtons(true);
            GridMode = SectionGridMode.Edit;
        }
 /// <summary>
 /// Post an event to notify subscribers that a section
 /// need to be edited
 /// </summary>
 protected virtual void OnSectionEdit(SectionAnswersItemEventArgs e)
 {
     if (this.EditSection != null)
     {
         this.EditSection(this, e);
     }
 }
 /// <summary>
 /// Post an event to notify subscribers that a section
 /// has been deleted
 /// </summary>
 protected virtual void OnSectionDelete(SectionAnswersItemEventArgs e)
 {
     if (this.DeleteSection != null)
     {
         this.DeleteSection(this, e);
     }
 }
        /// <summary>
        /// A section has been removed on the grid.
        /// Update the target section number if any was setup or
        /// show a "new section" area if the last section has
        /// been removed on the grid
        /// </summary>
        protected virtual void AnswersGrid_DeleteSection(object sender, SectionAnswersItemEventArgs e)
        {
            int deletedSection = int.Parse(e.SectionNumber.ToString());

            // Is the deleted section being in edit mode ?
            if (GridMode == SectionGridMode.Edit && TargetSection == deletedSection)
            {
                //Removes it
                SectionCount = -1;
                TargetSection = -1;
                GridMode = SectionGridMode.None;
                _sectionTable.Controls.Clear();

                // Did the user delete the last section ?
                if (GetSectionCountFromAnswers(_postedAnswers) < 1)
                {
                    AddSection(-1, 0);
                    AddSubmitSectionButtons(GridMode == SectionGridMode.Edit);
                    SectionCount = 0;
                    TargetSection = 0;
                }

            }
            else
            {
                // Is an add section is already displayed ?
                if (_sections.Count > 0)
                {
                    // Is the target section 
                    if (TargetSection > 0 && TargetSection >= deletedSection)
                    {
                        TargetSection--;

                        // Updates the button arguments
                        AddSubmitSectionButtons(GridMode == SectionGridMode.Edit);
                    }
                }
                else
                {
                    // Did the user delete the last section ?
                    if (GetSectionCountFromAnswers(_postedAnswers) < 1)
                    {
                        AddSection(-1, 0);
                        AddSubmitSectionButtons(GridMode == SectionGridMode.Edit);
                        SectionCount = 0;
                        TargetSection = 0;
                    }
                }
            }
        }
        /// <summary>
        /// A new section has been requested for edit
        /// Show a "new section" area with the section's answers
        /// </summary>
        protected virtual void AnswersGrid_EditSection(object sender, SectionAnswersItemEventArgs e)
        {
            _sectionTable.Controls.Clear();

            if (e.SectionAnswers != null)
            {
                PostedAnswerDataCollection postedAnswers = new PostedAnswerDataCollection();
                foreach (GridAnswerData answer in e.SectionAnswers)
                {
                    if (VoterAnswersState == null)
                    {
                        VoterAnswersData voterAnswersData = new VoterAnswersData();
                        voterAnswersData.EnforceConstraints = false;
                        VoterAnswersState = voterAnswersData.VotersAnswers;
                    }

                    VoterAnswersData.VotersAnswersRow voterAnswer = VoterAnswersState.NewVotersAnswersRow();
                    voterAnswer.AnswerId = answer.AnswerId;
                    voterAnswer.QuestionId = QuestionId;
                    voterAnswer.SectionNumber = -1;
                    voterAnswer.AnswerText = answer.FieldText;
                    voterAnswer.VoterId = -1;
                    VoterAnswersState.AddVotersAnswersRow(voterAnswer);
                }
            }

            // Dont use any default answers as we have 
            // setup an existing answer set
            EnableAnswersDefault = false;

            AddSection(-1, 0);
            SectionCount = 0;
            TargetSection = int.Parse(e.SectionNumber.ToString());
            AddSubmitSectionButtons(true);
            GridMode = SectionGridMode.Edit;
        }
 /// <summary>
 /// A new section has been requested on the grid.
 /// Show a "new section" area
 /// </summary>
 protected virtual void AnswersGrid_AddSection(object sender, SectionAnswersItemEventArgs e)
 {
     _sectionTable.Controls.Clear();
     AddSection(-1, 0);
     SectionCount = 0;
     TargetSection = int.Parse(e.SectionNumber.ToString());
     AddSubmitSectionButtons(false);
     GridMode = SectionGridMode.AddNew;
 }