// Use this for initialization
 void Start()
 {
     mPanel          = FindObjectOfType <PanelScores>();
     choixAffichDiff = GameObject.FindGameObjectWithTag("ContentDropDownDifficulte").GetComponent <Text>();
     if (choixAffichDiff != null)
     {
         choixAffichDiff.text = Options.Instance.Difficulte;
     }
 }
Пример #2
0
    protected void ButtonAjouterScore_Click(object sender, EventArgs e)
    {
        LabelValidationMessage.Text = "";
        for (int i = Scores.Count + 1; i <= Scores.Count + NombreScores; i++)
        {
            string tableScoresID = "TableScore" + i.ToString();
            // BUG29112009
            //string userControlID = "Score" + i.ToString();
            string userControlID = "ScoreToAdd" + i.ToString();
            System.Web.UI.UserControl control = (System.Web.UI.UserControl)PanelScores.FindControl(userControlID);
            Table tableScores = ( Table )control.FindControl(tableScoresID);

            // Petite precaution toujours aussi dur d'ecrire ce code
            if (tableScores == null)
            {
                break;
            }

            TextBox textBoxScoreMin = ( TextBox )tableScores.FindControl("TextBoxScoreMin");
            int     scoreMin        = 0;
            if (string.IsNullOrEmpty(textBoxScoreMin.Text.Trim()) == false)
            {
                try
                {
                    scoreMin = int.Parse(textBoxScoreMin.Text.Trim());
                }
                catch
                {
                    LabelValidationMessage.Visible = true;
                    LabelValidationMessage.Text   += "Score mininum est un entier<br/>";
                    continue;
                }
            }

            TextBox textBoxScoreMax = ( TextBox )tableScores.FindControl("TextBoxScoreMax");
            int     scoreMax        = 0;
            if (string.IsNullOrEmpty(textBoxScoreMax.Text.Trim()) == false)
            {
                try
                {
                    scoreMax = int.Parse(textBoxScoreMax.Text.Trim());
                }
                catch
                {
                    LabelValidationMessage.Visible = true;
                    LabelValidationMessage.Text   += "Score maximum est un entier<br/>";
                    continue;
                }
            }

            if (scoreMin > scoreMax)
            {
                LabelValidationMessage.Visible = true;
                LabelValidationMessage.Text   += "Score minimum est supérieur au Score maximum<br/>";
                continue;
            }

            TextBox textBoxScoreTexte = ( TextBox )tableScores.FindControl("TextBoxScoreTexte");
            if (string.IsNullOrEmpty(textBoxScoreTexte.Text.Trim()))
            {
                LabelValidationMessage.Visible = true;
                LabelValidationMessage.Text   += "Donnez un texte de validation pour le Score<br/>";
                continue;
            }

            Score score = new Score();
            score.ScoreQuestionnaireID = SessionState.Questionnaire.QuestionnaireID;
            score.ScoreMin             = scoreMin;
            score.ScoreMax             = scoreMax;
            score.ScoreTexte           = textBoxScoreTexte.Text.Trim();
            int status = Score.Create(score);
            if (status != 1)
            {
                LabelValidationMessage.Visible = true;
                LabelValidationMessage.Text   += "Erreur à la création du Score .<br/>";
            }
            else
            {
                LabelValidationMessage.Visible = true;
                LabelValidationMessage.Text   += "Score crée correctement : " + score.ScoreTexte + "<br/>";
            }
        } // fin du for ( int i = 1;i <= NombreScores;i++ )

        Scores = ScoreCollection.GetScoreQuestionnaire(SessionState.Questionnaire.QuestionnaireID);
        CreateControlPanelScores();
    }