Ejemplo n.º 1
0
        /*   public List<M_Plane> Verif(string Name)
         * {
         *     connection.Open();
         *     List<M_Plane> liste = new List<M_Plane>();
         *     MySqlCommand command = connection.CreateCommand();
         *     command.CommandText = "select * from Pilot where name=@ln"; // exemple de requete bien-sur !
         *     command.Parameters.AddWithValue("@ln", Name);
         *     MySqlDataReader reader1;
         *     reader1 = command.ExecuteReader();
         *     //parcours deux fois la ligne donc va au resultat de la deuxieme ligne de la colonne 0
         *     while (reader1.Read())                           // parcours ligne par ligne
         *     {
         *         int id = reader1.GetInt32(0);
         *         string name = reader1.GetString(1);
         *         string plane = reader1.GetString(2);
         *         int length = reader1.GetInt32(3);
         *         int width = reader1.GetInt32(4);
         *         M_Plane avion = new M_Plane(id,name, plane, length,width);
         *         liste.Add(avion);
         *     }
         *     connection.Close();
         *     return liste;
         * }*/

        public M_Pilot Verif_name(string Name)
        {// cette methode est utilisé dans MV_Recherche pour rechercher un pilot associé à un nom dans la base de donnée
            connection.Open();

            MySqlCommand command = connection.CreateCommand();

            command.CommandText = "select * from Pilot where name=@ln"; // exemple de requete bien-sur !
            command.Parameters.AddWithValue("@ln", Name);

            MySqlDataReader reader1;

            reader1 = command.ExecuteReader();
            //parcours deux fois la ligne donc va au resultat de la deuxieme ligne de la colonne 0
            /* exemple de manipulation du resultat */
            int    id     = 0;
            string name   = "";
            string plane  = "";
            int    length = 0;
            int    width  = 0;

            while (reader1.Read())
            {
                id     = reader1.GetInt32(0);
                name   = reader1.GetString(1);
                plane  = reader1.GetString(2);
                length = reader1.GetInt32(3);
                width  = reader1.GetInt32(4);
            }
            M_Pilot avion = new M_Pilot(id, name, plane, length, width);

            connection.Close();
            return(avion);
        }
Ejemplo n.º 2
0
        public MV_Recherche(string nom)
        {//permet la recherche d'un pilot associé à un nom donné en parametre et retourne un élément Pilot grace à la methode verif_name
            this.nom = nom;

            gestion = new M_BDD();

            M_Pilot pilote = gestion.Verif_name(nom);//recherche un pilot dans la bdd associé à un nom

            this.pilot = new MV_Pilot(pilote);
        }
Ejemplo n.º 3
0
 public MV_Pilot(M_Pilot pilot)
 {
     this.pilot = pilot;
     gestion    = new M_BDD();
 }