예제 #1
0
    void FillDropDownListChoix()
    {
        string          ActivityName = " ";
        MySqlCommand    ActiviteCommand;
        MySqlDataReader ActiviteReader;

        Connection.Open();
        //while (QuestionReader.Read())
        if (Connection != null)
        {
            ActiviteCommand             = Connection.CreateCommand();
            ActiviteCommand.CommandText = "Select TitreActivite from activites";
            ActiviteReader = ActiviteCommand.ExecuteReader();
            while (ActiviteReader.Read())
            {
                ActivityName = ActiviteReader["TitreActivite"].ToString();
                ddl_choix_horraire.Items.Add(new ListItem(ActivityName));
                //ddl_ajout_date.Items.Add(ActivityName);
            }
            ActiviteReader.Close();
            Connection.Close();
        }
        else
        {
            //connexion non réussie
            Response.Redirect("Accueil.aspx");
        }
    }
    bool ActiviteValide(string TitreActivite)
    {
        bool            Valid = true;
        MySqlCommand    ActiviteCommand;
        MySqlDataReader ActiviteReader;

        //while (QuestionReader.Read())
        //Connection.Open();
        if (Connection != null)
        {
            ActiviteCommand             = Connection.CreateCommand();
            ActiviteCommand.CommandText = "Select TitreActivite from activites where TitreActivite ='" + TitreActivite + "'";
            ActiviteReader = ActiviteCommand.ExecuteReader();
            if (ActiviteReader.Read())
            {
                Valid = false;
            }
            ActiviteReader.Close();
        }
        else
        {
            //connexion non réussie
            Response.Redirect("default.aspx");
        }
        return(Valid);
    }