Exemple #1
0
        public NonAdherent ReadNA(string telNA, int idEvent)
        {
            NonAdherent ThisNA = null;

            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                connection.Open();
                string query = "SELECT * FROM non_adherents where telephone = @tel";
                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, connection);
                cmd.Parameters.AddWithValue("@tel", telNA);
                //Create a data reader and Execute the command
                using (MySqlDataReader dataReader = cmd.ExecuteReader())
                {
                    //Read the data and store them in the list
                    while (dataReader.Read())
                    {
                        ThisNA = new NonAdherent(
                            (int)dataReader["id"],
                            (string)dataReader["nomNA"],
                            (string)dataReader["prenomNA"],
                            (string)dataReader["telephone"],
                            (int)dataReader["id_event"]);
                    }
                }
            }
            return(ThisNA);
        }
Exemple #2
0
        public List <NonAdherent> SelectAllEventNonAdherent(int idEvent)
        {
            NonAdherent        LeNonAdherent   = null;
            List <NonAdherent> ListNonAdherent = new List <NonAdherent>();

            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                connection.Open();
                string query = "SELECT * FROM non_adherents Where id_event = @event  ORDER BY id ASC";

                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, connection);

                cmd.Parameters.AddWithValue("@event", idEvent);


                //Create a data reader and Execute the command
                using (MySqlDataReader dataReader = cmd.ExecuteReader())
                {
                    //Read the data and store them in the list
                    while (dataReader.Read())
                    {
                        LeNonAdherent = new NonAdherent(
                            (int)dataReader["id"],
                            (string)dataReader["nomNA"],
                            (string)dataReader["prenomNA"],
                            (string)dataReader["telephone"],
                            (int)dataReader["id_event"]);
                        ListNonAdherent.Add(LeNonAdherent);
                    }
                }
            }

            return(ListNonAdherent);
        }
        private void buttonConfirmAjoutNA_Click(object sender, EventArgs e)
        {
            BDD UnEvent = new BDD();

            UnEvent.InsertNA(nomNA, prenomNA, telNA, idEvent);
            NonAdherent NA = UnEvent.ReadNA(telNA, idEvent);

            UnEvent.InsertParticipant(0, idEvent, NA.id);
            Close();
        }