Beispiel #1
0
        public void Insert(Eleve unEleve)
        {
            cnx.Open();
            MySqlCommand cmdSql = new MySqlCommand();

            cmdSql.Connection  = cnx; cmdSql.CommandText = "insert into eleve (nom,prenom,login,passWord) values (@nom,@prenom,@login);";
            cmdSql.CommandType = CommandType.Text;

            cmdSql.Parameters.Add("@nom", MySqlDbType.String);
            cmdSql.Parameters["@nom"].Direction = ParameterDirection.Input;
            cmdSql.Parameters["@nom"].Value     = unEleve.Nom;

            cmdSql.Parameters.Add("@prenom", MySqlDbType.String);
            cmdSql.Parameters["@prenom"].Direction = ParameterDirection.Input;
            cmdSql.Parameters["@prenom"].Value     = unEleve.Prenom;

            cmdSql.Parameters.Add("@login", MySqlDbType.String);
            cmdSql.Parameters["@login"].Direction = ParameterDirection.Input;
            cmdSql.Parameters["@login"].Value     = unEleve.Login;


            cmdSql.ExecuteNonQuery();

            cnx.Close();
        }
Beispiel #2
0
        public List <Eleve> LoadCsv(PassWordType type, string chemin)
        {
            StreamReader sr;

            sr = new StreamReader(chemin);

            string s = sr.ReadLine();

            string login, prenom;

            while (s != null)
            {
                string[] lineSplit = s.Split(';');
                // construction du login
                prenom = lineSplit[0];
                login  = prenom[0] + lineSplit[1];

                Eleve unEleve = new Eleve(lineSplit[0], lineSplit[1], login + "@sio.jjr.fr", "");

                unEleve.PassWord = unEleve.GetNewPassWord(type);

                desEleves.Add(unEleve);

                s = sr.ReadLine();
            }

            sr.Close();
            return(desEleves);
        }