Пример #1
0
    // C'est un peu lourd de faire un PollAnswer.Update de toute la reponse ...
    // mais j'ai la fleme d'ecrire une procedure stockee de plus !
    protected void DropDownListTypeReponse_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownListGridView ddl = ( DropDownListGridView )sender;
        int        indexe        = int.Parse(ddl.Valeur);
        Guid       reponseGuid   = new Guid(GridView1.DataKeys[indexe].Value.ToString());
        PollAnswer reponse       = Reponses.FindByPollAnswerID(reponseGuid);

        reponse.TypeReponse = ddl.SelectedValue;
        PollAnswer.Update(reponse);
    }
Пример #2
0
    protected void ButtonRangMoinsUn_Click(object sender, EventArgs e)
    {
        int          indexRow = 0;
        DataKeyArray dka      = GridView1.DataKeys;

        foreach (GridViewRow r in GridView1.Rows)
        {
            CheckBox cb          = ( CheckBox )GridView1.Rows[indexRow].FindControl("CheckBoxRangPlusMoinsUn");
            Guid     reponseGuid = new Guid(dka[indexRow].Value.ToString());
            if (cb.Checked)
            {
                PollAnswer reponse = Reponses.FindByPollAnswerID(reponseGuid);
                reponse.Rank -= 1;
                PollAnswer.Update(reponse);
            }

            indexRow += 1;
        }
        GridView1.DataBind();
    }
Пример #3
0
    protected void TextBoxScore_TextChanged(object sender, EventArgs e)
    {
        Reporter.Trace("TextBoxScore_TextChanged");

        try
        {
            TextBox textBox = ( TextBox )sender;
            int     score   = int.Parse(textBox.Text);
            if (score > 0)
            {
                HiddenField hf = new HiddenField();
                hf = ( HiddenField )textBox.Parent.FindControl("PollAnswerId");
                Guid       pollAnswerId = new Guid(hf.Value);
                PollAnswer reponse      = SessionState.Reponses.FindByPollAnswerID(pollAnswerId);
                reponse.Score = score;
                PollAnswer.Update(reponse);
            }
        }
        catch
        {
        }
    }
Пример #4
0
    protected void TestBoxReponseRank_TextChanged(object sender, EventArgs e)
    {
        Reporter.Trace("TestBoxReponseRank_TextChanged");
        BloquerQuestionnaire(SessionState.Questionnaire.Bloque);

        try
        {
            TextBox     textBoxRank = ( TextBox )sender;
            int         rank        = int.Parse(textBoxRank.Text);
            HiddenField hf          = new HiddenField();
            hf = ( HiddenField )textBoxRank.Parent.FindControl("PollAnswerId");
            Guid       pollAnswerId = new Guid(hf.Value);
            PollAnswer reponse      = SessionState.Reponses.FindByPollAnswerID(pollAnswerId);
            reponse.Rank = rank;
            PollAnswer.Update(reponse);
        }
        catch
        {
        }

        RebuildDataList();
    }
Пример #5
0
    protected void TextBoxDataListReponse_TextChanged(object sender, EventArgs e)
    {
        Reporter.Trace("TextBoxDataListReponse_TextChanged");
        BloquerQuestionnaire(SessionState.Questionnaire.Bloque);

        try
        {
            TextBox textBox = ( TextBox )sender;

            HiddenField hf = new HiddenField();
            hf = ( HiddenField )textBox.Parent.FindControl("PollAnswerId");
            Guid       pollAnswerId = new Guid(hf.Value);
            PollAnswer reponse      = SessionState.Reponses.FindByPollAnswerID(pollAnswerId);

            // Mise a jour de la Reponse
            if (textBox.Text.Trim() != string.Empty)
            {
                reponse.Answer = textBox.Text.Trim();
                PollAnswer.Update(reponse);
            }
            else // Suppression de la Reponse et des Votes associes
            {
                int status = 0;
                PollVoteCollection votes = PollVoteCollection.GetVotes(reponse.PollAnswerId);
                foreach (PollVote vote in votes)
                {
                    status += PollVote.Delete(vote.VoteId);
                }
                status += PollAnswer.Delete(reponse.PollAnswerId);
                RebuildDataList();
            }
        }
        catch
        {
        }
    }
Пример #6
0
    protected void ButtonRangPlusMoins_Click(object sender, EventArgs e)
    {
        Button button = ( Button )sender;

        string srang = TextRangMoinsPlusHaut.Text;

        if (button.ID == "ButtonRangPlusBas" || button.ID == "ButtonRangMoinsBas")
        {
            srang = TextRangMoinsPlusBas.Text;
        }

        int irang = 1;

        try
        {
            irang = int.Parse(srang);
            if (irang < 1 || irang > 1000)
            {
                irang = 1;
                if (button.ID == "ButtonRangPlusBas" || button.ID == "ButtonRangMoinsBas")
                {
                    TextRangMoinsPlusBas.Text = "1";
                }
                else
                {
                    TextRangMoinsPlusHaut.Text = "1";
                }
                return;
            }
        }
        catch
        {
            if (button.ID == "ButtonRangPlusBas" || button.ID == "ButtonRangMoinsBas")
            {
                TextRangMoinsPlusBas.Text = "1";
            }
            else
            {
                TextRangMoinsPlusHaut.Text = "1";
            }
            return;
        }

        // Si c'est un bouton Moins on inverse le rang
        if (button.ID == "ButtonRangMoinsHaut" || button.ID == "ButtonRangMoinsBas")
        {
            irang = -irang;
        }

        foreach (DataListItem dli in DataListQuestion.Items)
        {
            HiddenField hf = new HiddenField();
            hf = ( HiddenField )dli.FindControl("PollQuestionId");
            Guid pollQuestionId = new Guid(hf.Value);

            CheckBox cb = ( CheckBox )dli.FindControl("CheckBoxRangPlusMoins");
            if (cb.Checked)
            {
                PollQuestion question = PollQuestion.GetQuestion(pollQuestionId);
                question.Rank += irang;
                PollQuestion.UpdateRank(question);
            }

            DataList dlr = new DataList();
            dlr = ( DataList )dli.FindControl("DataListReponse");

            foreach (DataListItem dlir in dlr.Items)
            {
                HiddenField hfr = new HiddenField();
                hfr = ( HiddenField )dlir.FindControl("PollAnswerId");
                Guid pollAnswerId = new Guid(hfr.Value);

                CheckBox cbr = ( CheckBox )dlir.FindControl("CheckBoxRangPlusMoins");
                if (cbr.Checked)
                {
                    PollAnswer reponse = SessionState.Reponses.FindByPollAnswerID(pollAnswerId);
                    reponse.Rank += irang;
                    PollAnswer.Update(reponse);
                }
            }
        }

        RebuildDataList();
    }