예제 #1
0
    // GridViewQuestion_RowDataBound est appellee pour chaque ligne lors de la construction
    // de la GridView
    // Attention : le fait d'utiliser une deuxieme fois la DDL, introduit un mauvais comportement
    // Valeur est à "" lors du SelectedIndexChanged !
    protected void ComputeAlignementColumn()
    {
        Trace.Warn("ComputeAlignementColumn");

        if (GridViewQuestion.Rows.Count > 0)
        {
            int indexRow = GridViewQuestion.Rows.Count - 1;

            Guid         questionGuid = new Guid(GridViewQuestion.DataKeys[indexRow].Value.ToString());
            PollQuestion question     = PollQuestion.GetQuestion(questionGuid);

            DropDownListGridView ddlQ = ( DropDownListGridView )GridViewQuestion.Rows[indexRow].FindControl("DropDownListGridViewAlignementQuestion");
            ddlQ.DataSource = PollQuestion.TypeAlignement();
            ddlQ.DataBind();
            ddlQ.Valeur = indexRow.ToString();
            if (question.AlignementQuestion != "")
            {
                ddlQ.SelectedValue = question.AlignementQuestion;
            }

            DropDownListGridView ddlR = ( DropDownListGridView )GridViewQuestion.Rows[indexRow].FindControl("DropDownListGridViewAlignementReponse");
            ddlR.DataSource = PollQuestion.TypeAlignement();
            ddlR.DataBind();
            ddlR.Valeur = indexRow.ToString();
            if (question.AlignementQuestion != "")
            {
                ddlR.SelectedValue = question.AlignementReponse;
            }
        }
    }
예제 #2
0
    protected void DropDownListAlignementReponse_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownListGridView ddl  = ( DropDownListGridView )sender;
        int          indexe       = int.Parse(ddl.Valeur);
        Guid         questionGuid = new Guid(GridViewQuestion.DataKeys[indexe].Value.ToString());
        PollQuestion question     = PollQuestion.GetQuestion(questionGuid);

        question.AlignementReponse = ddl.SelectedValue;
        PollQuestion.UpdateAlignementReponse(question);
    }
    protected void Page_Load(object sender, System.EventArgs e)
    {
        try
        {
            PollId = new Guid(Request["PollId"]);
        }
        catch
        {
            Response.Redirect("~/Poll/List.aspx", true);
        }

        if (PollId == Guid.Empty)
        {
            Response.Redirect("~/Poll/List.aspx", true);
        }

        PollQuestion q = PollQuestion.GetQuestion(PollId);

        QuestionLabel.Text = q.Question;
    }
예제 #4
0
    protected void ButtonRangMoinsUn_Click(object sender, EventArgs e)
    {
        int          indexRow = 0;
        DataKeyArray dka      = GridViewQuestion.DataKeys;

        foreach (GridViewRow r in GridViewQuestion.Rows)
        {
            CheckBox cb           = ( CheckBox )GridViewQuestion.Rows[indexRow].FindControl("CheckBoxRangPlusMoinsUn");
            Guid     questionGuid = new Guid(dka[indexRow].Value.ToString());
            if (cb.Checked)
            {
                PollQuestion question = PollQuestion.GetQuestion(questionGuid);
                question.Rank -= 1;
                PollQuestion.UpdateRank(question);
            }

            indexRow += 1;
        }
        //Response.Redirect( Request.RawUrl ); surtout pas ici !!
        HiddenFieldQuestionnaireID.Value = SessionState.Questionnaire.QuestionnaireID.ToString();
        GridViewQuestion.DataBind();
        BuildDataList();
    }
예제 #5
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();
    }
예제 #6
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        ValidationMessage.Text = "";

        if (!User.IsInRole("Administrateur") && !User.IsInRole("Client"))
        {
            GridView1.Columns[0].Visible = false;   // Edit delete column
            DetailsView1.Visible         = false;
        }

        if (Request["PollId"] == null)
        {
            if (SessionState.Questionnaire != null)
            {
                SessionState.Questions = PollQuestionCollection.GetByQuestionnaire(SessionState.Questionnaire.QuestionnaireID);
                if (SessionState.Questions.Count > 0)
                {
                    PollQuestionGUID = SessionState.Questions[0].PollQuestionId;

                    // Il faut prevenir le SqlDataSource que le parametre n'est pas dans la Query ...
                    // <asp:QueryStringParameter Name="pollId" QueryStringField="PollId" />
                    //SqlDataSource1.SelectParameters.Add( "pollId", PollQuestionGUID.ToString() );
                    //SqlDataSource1.DataBind()
                    // Cela ne fonctionne pas donc on fait :
                    Response.Redirect("~/Poll/Answers.aspx?PollId=" + PollQuestionGUID.ToString());
                }
            }
        }
        else
        {
            try
            {
                PollQuestionGUID = new Guid(Request["PollId"]);
            }
            catch
            {
                Response.Redirect("~/Poll/Manage.aspx", true);
            }
        }

        if (PollQuestionGUID == Guid.Empty)
        {
            Response.Redirect("~/Poll/Manage.aspx", true);
        }

        if (SessionState.Questionnaire != null)
        {
            HyperLinkQuestionnaire.Text = SessionState.Questionnaire.Description;
        }
        PollQuestion question = PollQuestion.GetQuestion(PollQuestionGUID);

        HyperLinkRank.Text                    = question.Rank.ToString();
        HyperLinkRank.NavigateUrl             = "~/Poll/Questionnaire.aspx?PollQuestionId=" + question.PollQuestionId.ToString() + "&t=1";
        HyperLinkModifierQuestion.NavigateUrl = "~/Wizard/Question.aspx?PollQuestionId=" + question.PollQuestionId.ToString();
        LabelQuestion.Text                    = " - " + question.Question;
        LabelObligatoire.Visible              = question.Obligatoire;
        LabelChoixMultiple.Visible            = question.ChoixMultiple;
        LabelChoixMultipleMinMax.Visible      = question.ChoixMultiple && (question.ChoixMultipleMin > 0) && (question.ChoixMultipleMax > 0);
        LabelChoixMultipleMinMax.Text         = "(" + question.ChoixMultipleMin + "/" + question.ChoixMultipleMax + ")";
        LabelChoixSimple.Visible              = (question.ChoixMultiple == false);
        LabelFin.Visible      = question.Fin;
        LabelInstruction.Text = question.Instruction;
        LabelMessage.Text     = question.Message;

        Reponses       = PollAnswerCollection.GetByPollQuestionID(PollQuestionGUID);
        ReponseRankMax = Reponses.MaxRank();
        if (Reponses.Count > 0)
        {
            Reponse0 = Reponses[0];
        }

        if (Page.IsPostBack == false)
        {
            DropDownListTextAlign.DataSource = TextAlign();
            DropDownListTextAlign.DataBind();
            if (Reponses.Count > 0)
            {
                DropDownListTextAlign.SelectedValue = Reponses[0].AlignLeft == true ? ( string )TextAlign()[1] : ( string )TextAlign()[0];
            }

            DropDownListVerticalHorizontal.DataSource = VerticalHorizontal();
            DropDownListVerticalHorizontal.DataBind();
            if (Reponses.Count > 0)
            {
                DropDownListVerticalHorizontal.SelectedValue = Reponses[0].Horizontal == true ? ( string )VerticalHorizontal()[1] : ( string )VerticalHorizontal()[0];
            }
        }
    }