Esempio n. 1
0
        public bool insert(Vehicule vehicule)
        {
            string rSQL =
                "INSERT INTO VEHICULE(Vehicule_Marque, Vehicule_Modele, Vehicule_Annee, Vehicule_Couleur, Vehicule_NbPlaces, Vehicule_societe, Vehicule_immatriculation, Carburant_Id, Utilisateur_Id, TypeVehicule_Id, Vehicule_Actif) " +
                "VALUES ('@marque', '@modele', '@annee', '@couleur', '@nbPlaces', '" + vehicule.getSociete() + "', '@immatriculation', '@carburant', '@utilisateur', '" + vehicule.getTypeVehicule() + "', 1)";

            SqlCommand ajoutCar = new SqlCommand(rSQL, Global.dataBase);

            ajoutCar.CommandText = rSQL;
            ajoutCar.Parameters.AddWithValue("@marque", vehicule.getMarque());
            ajoutCar.Parameters.AddWithValue("@modele", vehicule.getModele());
            ajoutCar.Parameters.AddWithValue("@annee", vehicule.getAnnee());
            ajoutCar.Parameters.AddWithValue("@couleur", vehicule.getCouleur());
            ajoutCar.Parameters.AddWithValue("@nbPlaces", vehicule.getNbPlaces());
            ajoutCar.Parameters.AddWithValue("@immatriculation", vehicule.getImmatriculation());
            ajoutCar.Parameters.AddWithValue("@carburant", vehicule.getCarburant());
            ajoutCar.Parameters.AddWithValue("@utilisateur", vehicule.getUtilisateur());

            int result = ajoutCar.ExecuteNonQuery();

            ajoutCar.Cancel();

            if (result >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        public async Task <ActionResult <Vehicule> > PostVehicule(Vehicule vehicule)
        {
            _context.Vehicule.Add(vehicule);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetVehicule", new { id = vehicule.VehiculeId }, vehicule));
        }
Esempio n. 3
0
        public IActionResult Update(int id, [FromBody] VehiculeUpdateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var vehicule = repository.Get(id);

            if (vehicule == null)
            {
                return(NotFound());
            }

            var updatedVehicule = new Vehicule
            {
                Id    = id,
                Make  = model.Make,
                Model = model.Model,
                Color = model.Color,
                Type  = model.Type,
                VIN   = model.VIN
            };

            repository.Update(updatedVehicule);
            return(NoContent());
        }
        public async Task <IActionResult> PostReservation(ReservationViewModel reservationVM)
        {
            Utilisateur u = _context.Utilisateur
                            .Where(ut => ut.Id == reservationVM.Utilisateur.Id)
                            .FirstOrDefault();
            Vehicule v = _context.Vehicule
                         .Where(vh => vh.Id == reservationVM.Vehicule.Id)
                         .FirstOrDefault();
            List <Personnel_Reservation> pr = new List <Personnel_Reservation>();

            foreach (var p in reservationVM.Personnels)
            {
                pr.Add(new Personnel_Reservation()
                {
                    PersonnelId   = p.Id,
                    ReservationID = reservationVM.Id
                });
            }
            var reservation = new Reservation(reservationVM, u, v, pr);

            _context.Reservation.Add(reservation);
            await _context.SaveChangesAsync();

            return(Ok());
        }
Esempio n. 5
0
        public async Task <IActionResult> PutVehicule([FromRoute] int id, [FromBody] Vehicule vehicule)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != vehicule.Id)
            {
                return(BadRequest());
            }

            _context.Entry(vehicule).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VehiculeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <Vehicule> AddAsync(Vehicule entity)
        {
            var createdEntity = await _VehiculeRepository.AddAsync(entity);

            //  await _BaseRepository.Sav();
            return(createdEntity);
        }
Esempio n. 7
0
        public async Task <ActionResult> Create([Bind(Include = "vehiculeID,senderName,senderAdress,senderEmail,senderPhoneNumber,recieverName,recieverAdress,recieverEmail,recieverPhoneNumber,destination,price,paid,alreadyPaid,paidRest,weight,height,length,depth,userID,vehiculeType,frameNumber")] Vehicule vehicule)
        {
            ViewBag.ReturnUrl = Url.Action("Vehicule");

            if (ModelState.IsValid)
            {
                vehicule.userID      = Int32.Parse(User.Identity.GetUserName().Split('|')[1]);
                vehicule.createdDate = DateTime.Now;
                vehicule.paidRest    = vehicule.price - vehicule.alreadyPaid;

                if (vehicule.senderEmail.Equals(""))
                {
                    vehicule.senderEmail = "*****@*****.**";
                }
                db.Vehicule.Add(vehicule);
                try
                {
                    await db.SaveChangesAsync();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                {
                    // Todo Log the error
                }

                return(RedirectToAction("Index", new { Message = NotificationMessage.ManageMessageId.RecordSuccess }));
            }

            return(View(vehicule));
        }
Esempio n. 8
0
 public void SoitLesReservationsSuivantes(Table table)
 {
     // Récupération des clients et véhicules pour créer les réservations
     foreach (TableRow row in table.Rows)
     {
         Client   currentClient   = null;
         Vehicule currentVehicule = null;
         foreach (Client client in this._fakeDataLayer.Clients)
         {
             if (client.NomUtilisateur == row[1])
             {
                 currentClient = client;
                 break;
             }
         }
         if (currentClient != null)
         {
             foreach (Vehicule vehicule in this._fakeDataLayer.Vehicules)
             {
                 if (vehicule.Immatriculation == row[0])
                 {
                     currentVehicule = vehicule;
                     break;
                 }
             }
             if (currentVehicule != null)
             {
                 this._fakeDataLayer.Reservations.Add(new Reservation(DateTime.Parse(row[2]), DateTime.Parse(row[3]), double.Parse(row[4]), row[5] == "null" ? (double?)null : double.Parse(row[5]), double.Parse(row[6]), row[7] == "null" ? (double?)null : double.Parse(row[7]), currentClient, currentVehicule));
             }
         }
     }
 }
Esempio n. 9
0
 public void Delete(Vehicule vehicle)
 {
     if (_VehicleList.Contains(vehicle))
     {
         _VehicleList.Remove(vehicle);
     }
 }
Esempio n. 10
0
        public ActionResult Book(FormCollection collection)
        {
            Utilisateur user = (Utilisateur)Session["user"];
            Vehicule    car  = db.vehicule.Find(int.Parse(collection["vehiculeFK"]));

            String[] startDate = collection["startDate"].Split(' ');
            String[] endDate   = collection["endDate"].Split(' ');

            DateTime dtStart = DateTime.ParseExact(startDate[0], "dd/mm/yyyy", null);
            DateTime dtEnd   = DateTime.ParseExact(endDate[0], "dd/mm/yyyy", null);

            Reservation reservation = new Reservation
            {
                reservationId   = 0,
                vehiculeFK      = car.vehiculeId,
                debutDate       = dtStart,
                finDate         = dtEnd,
                reservationDate = DateTime.UtcNow,
                status          = 0,
                utilisateurFK   = user.userId
            };

            db.reservation.Add(reservation);
            db.SaveChanges();
            return(RedirectToAction("BookedVehicles"));
        }
    public void PopTank(bool notTooMuchClose)
    {
        GameObject tank       = GameObject.Instantiate(prefabTank, ennemiParent);
        bool       positionOk = false;

        Map.Voronoi voronoi = null;
        while (!positionOk)
        {
            voronoi = Map.instance.quartiers[Random.Range(0, Map.instance.quartiers.Count - 1)];
            if (voronoi.voisins.Count == 0 || (notTooMuchClose && Vector3.SqrMagnitude(new Vector3(voronoi.position.x, 0, voronoi.position.y) - essaimMaitre.transform.position) < raidusMinimumaroundEssaim * raidusMinimumaroundEssaim))
            {
                positionOk = false;
            }
            else
            {
                positionOk = true;
                tank.transform.position = new Vector3(voronoi.position.x, 0, voronoi.position.y);
            }
        }
        Vehicule vehicule = tank.GetComponent <Vehicule>();

        vehicule.currentPoint = voronoi;
        vehicule.targetPoint  = voronoi.voisins[Random.Range(0, voronoi.voisins.Count - 1)];
        Debug.LogWarning((vehicule.currentPoint == null) + "  " + (vehicule.targetPoint == null));
        listEnnemis.Add(vehicule);
        nbTank++;
    }
Esempio n. 12
0
    //permet d'effectuer une reservation
    public static int effectuerReservation(string adresseMail, string heure, DateTime jour)
    {
        Moniteur moniteur = ControleurMoniteur.getMoniteurDisponible(heure, jour);

        if (moniteur == null)
        {
            return(-1);
        }
        else
        {
            Console.WriteLine(moniteur.AdresseMail);
            Vehicule vehicule = ControleurVehicule.getVehiculeDispo(heure, jour);
            if (vehicule == null)
            {
                return(0);
            }
            else
            {
                int idVehicule = ControleurVehicule.getVehiculeId(vehicule.Immatriculation);
                Console.WriteLine(idVehicule);
                ControleurReservation.enregistrerRerservation(adresseMail, moniteur, heure, jour);
                ControleurAgendaMoniteur.miseAjourAgenda(moniteur, heure, jour);
                return(1);
            }
        }
    }
Esempio n. 13
0
 public Reservation(Client client, Moniteur moniteur, Vehicule vehicule, DateTime date)
 {
     this.client   = client;
     this.moniteur = moniteur;
     this.vehicule = vehicule;
     this.date     = date;
 }
Esempio n. 14
0
        public Vehicule CreateVehicule(Vehicule vehicule)
        {
            context.Vehicules.Add(vehicule);
            context.SaveChanges();

            return(vehicule);
        }
Esempio n. 15
0
        static void Main(string[] args)
        {
            List <Vehicule> laListeDeVehicule = new List <Vehicule>();
            Vehicule        unVehicule        = new Vehicule();

            string path = "C:/Users/User/source/repos/ProjetVehiculesFichierTexte/ProjetVehiculesFichierTexte/ClassesEtEnum/ListeVehicules1.txt";

            string[] lines    = File.ReadAllLines(path, Encoding.UTF8);
            string[] uneLigne = new string[3];
            string   value;

            foreach (string line in lines)
            {
                uneLigne = line.Split(",");
                Vehicule nouvVehicule = new Vehicule();
                nouvVehicule.SetImmat(uneLigne[0]);
                value = uneLigne[1];
                Couleurs coul = (Couleurs)Enum.Parse(typeof(Couleurs), value);
                nouvVehicule.SetCouleur(coul);
                nouvVehicule.SetPrix(double.Parse(uneLigne[2]));
                laListeDeVehicule.Add(nouvVehicule);
            }

            foreach (Vehicule unVeh in laListeDeVehicule)
            {
                Console.WriteLine("Immat: " + unVeh.GetImmat() + " Couleur: " + unVeh.GetCouleur() + " et le prix: " + unVeh.GetPrix());
            }
        }
        public Vehicule Get(int id)
        {
            string        cmdText    = $"select * from Vehicules where id ={id}";
            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand    command    = new SqlCommand(cmdText, connection);
            Vehicule      vehicule   = new Vehicule();

            vehicule.Id = id;
            using (connection)
            {
                try
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            vehicule.Make  = (string)reader["Make"];
                            vehicule.Model = (string)reader["Model"];
                            vehicule.VIN   = (string)reader["VIN"];
                            vehicule.Type  = (VehicleTypeEnum)reader["Type"];
                            vehicule.Color = (ColorEnum)reader["Color"];
                        }
                    }
                }
                catch (SqlException e)
                {
                    throw e;
                }
            }
            return(vehicule);
        }
Esempio n. 17
0
        /**
         * Ajouter un trajet à la liste du gestionnaire de flotte
         * @Params strNClient    string : Numero du client
         * @Params strNVehicule  string : Numero du vehicule
         * @Params strDistance   string : distance en km
         */
        public void AjoutTrajet(string strNClient, string strNVehicule, string strDistance, string date)
        {
            int distance = -1;

            if (!int.TryParse(strDistance, out distance) || distance <= 0)
            {
                throw new ErreurDistance();
            }

            Vehicule v = GetVehicule(strNVehicule);

            if (!v.IsDisponible)
            {
                throw new NotImplementedException("ERREUR : Le vehicule n'est pas disponible");
            }
            try
            {
                gestionFlotte.TrajetList.Add(new Trajet(GetClient(strNClient), v, distance, DateTime.Parse(date)));
            }
            catch (System.FormatException e)
            {
                throw new NotImplementedException("ERREUR : Le date saisie est invalide");
            }

            v.IsDisponible = false;
            v.NTrajet      = Trajet.LastNTrajet;
        }
        public void add(Vehicule vehicule)
        {
            string cmdText = "insert into Vehicules(Make, Model, VIN, Type, Color) values(@Make, @Model, @VIN, @Type, @Color) ";

            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand    command    = new SqlCommand(cmdText, connection);

            command.Parameters.AddWithValue("@Make", vehicule.Make);
            command.Parameters.AddWithValue("@Model", vehicule.Model);
            command.Parameters.AddWithValue("@VIN", vehicule.VIN);
            command.Parameters.AddWithValue("@Type", vehicule.Type);
            command.Parameters.AddWithValue("@Color", vehicule.Color);

            using (connection)
            {
                try
                {
                    connection.Open();
                    command.ExecuteNonQuery();
                }
                catch (SqlException e)
                {
                    throw e;
                }
            }
        }
Esempio n. 19
0
 public ActionResult EditVehicule(int?id)
 {
     ViewBag.Title = "Edit Company";
     using (var dao = new Dao.Dao())
     {
         var companiesList = dao.CompaniesList();
         var vehiculeTypes = new SelectList(new List <Object>
         {
             new { Id = "BUS", Name = "Bus" },
             new { Id = "TRAIN", Name = "Train" },
             new { Id = "AVION", Name = "Avion" },
             new { Id = "TAXI", Name = "Taxi" },
         }, "Id", "Name");
         ViewBag.vehiculeTypes = vehiculeTypes;
         ViewBag.listCompanies = new SelectList(companiesList, "Id", "Name");
         Vehicule vehicule;
         if (id != null)
         {
             vehicule = dao.GetOneHVehicule((int)id);
             if (vehicule != null)
             {
                 return(View("editVehicule", vehicule));
             }
         }
         vehicule = new Vehicule();
         return(View("editVehicule", vehicule));
     }
 }
Esempio n. 20
0
        /// <summary>
        /// Ajoute un véhicule
        /// Vérifie si un même véhicule existe avec l'ID, dans ce cas, on lève une exception
        /// </summary>
        /// <param name="nouveauVehicule"></param>
        public void AddVehicule(Vehicule nouveauVehicule)
        {
            if (nouveauVehicule == null)
            {
                throw new NullNotAllowedException();
            }
            Vehicule memeVehiculeParID = searchByID(nouveauVehicule.ID);

            if (memeVehiculeParID != null)
            {
                throw new SameIDExistsException();
            }
            // création d'un nouvel ID
            int maxID = 1;

            foreach (Vehicule v in vehicules)
            {
                if (v.ID >= maxID)
                {
                    maxID = v.ID + 1;
                }
            }
            nouveauVehicule.ID = maxID;
            vehicules.Add(nouveauVehicule);
        }
Esempio n. 21
0
 public ActionResult SaveVehicule(Vehicule vehicule)
 {
     ViewBag.Title         = "Ajout de vehicule";
     ViewBag.postInfo      = "Company saved successfuly";
     ViewBag.postInfoClass = "alert-success";
     Console.WriteLine(vehicule.Id + ";" + vehicule.Name + ";" + vehicule.Description + ";" + vehicule.CompanyId);
     if (!ModelState.IsValid)
     {
         var errors = ModelState.Values.SelectMany(v => v.Errors);
         ViewBag.postInfo = errors;
         foreach (var v in errors)
         {
             Console.WriteLine("Error" + v.ErrorMessage);
         }
         ViewBag.postInfoClass = "alert-danger";
     }
     else
     {
         using (var dao = new Dao.Dao())
         {
             dao.InsertVehicule(vehicule);
         }
     }
     return(View("Saved"));
 }
Esempio n. 22
0
        static void Main(string[] args)
        {
            var test = new Vehicule();

            test.pouet();
            Console.WriteLine("Hello World!");
        }
Esempio n. 23
0
        /// <summary>
        /// Récupère une Vehicule à partir d'un identifiant de client
        /// </summary>
        /// <param name="Identifiant">Identifant de Vehicule</param>
        /// <returns>Un Vehicule </returns>
        public static Vehicule Get(Int32 identifiant)
        {
            //Connection
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["LaboSPPPConnectionString"];
            SqlConnection connection = new SqlConnection(connectionStringSettings.ToString());
            //Commande
            String requete = @"SELECT Identifiant, Libelle, IdentifiantConstructeur FROM Vehicule
                                WHERE Identifiant = @Identifiant";
            SqlCommand commande = new SqlCommand(requete, connection);

            //Paramètres
            commande.Parameters.AddWithValue("Identifiant", identifiant);

            //Execution
            connection.Open();
            SqlDataReader dataReader = commande.ExecuteReader();

            dataReader.Read();

            //1 - Création du Vehicule
            Vehicule vehicule = new Vehicule();

            vehicule.Identifiant = dataReader.GetInt32(0);
            vehicule.Libelle = dataReader.GetString(1);
            vehicule.constructeur.Identifiant = dataReader.GetInt32(2);

            dataReader.Close();
            connection.Close();
            return vehicule;
        }
Esempio n. 24
0
        public void Create_ValidVehiculePassed_ReturnedResponseHasCreatedVehicule()
        {
            // Arrange
            var testVehiculeCreateViewModel = new VehiculeCreateViewModel()
            {
                Color = ColorEnum.Blue,
                Make  = "makeNewVehicule",
                Model = "modelNewVehicule",
                Type  = VehicleTypeEnum.Car,
                VIN   = "VINNewVehicule"
            };
            var testVehicule = new Vehicule()
            {
                Color = ColorEnum.Blue,
                Make  = "makeNewVehicule",
                Model = "modelNewVehicule",
                Type  = VehicleTypeEnum.Car,
                VIN   = "VINNewVehicule"
            };

            _mockRepo.Setup(r => r.add(It.IsAny <Vehicule>()))
            .Callback <Vehicule>(x => testVehicule = x);

            // Act
            var createdResponse = _controller.Create(testVehiculeCreateViewModel) as CreatedAtActionResult;

            Assert.IsInstanceOfType(createdResponse.Value, typeof(Vehicule));
            var vehicule = createdResponse.Value as Vehicule;

            // Assert

            Assert.AreEqual(testVehicule, vehicule);
        }
Esempio n. 25
0
        protected void Button_EnregistrerVehicule_Click(object sender, EventArgs e)
        {
            Vehicule V = new Vehicule();

            V.Matricule     = TextBox_Immatriculation.Text;
            V.Genre         = TextBox_Genre.Text;
            V.Usage         = TextBox_Usage.Text;
            V.Constructeur  = TextBox_Constructeur.Text;
            V.Marque        = TextBox_Marque.Text;
            V.Couleur       = TextBox_Couleur.Text;
            V.Constructeur  = TextBox_Constructeur.Text;
            V.NumeroDeSerie = TextBox_NumSerie.Text;
            V.DPMC          = TextBox_DPMC.Text;
            V.Carrosserie   = TextBox_Carroserie.Text;
            int i = 0;

            Int32.TryParse(TextBox_NbPlace.Text, out i);
            V.NombreDePlace = i;
            Int32.TryParse(TextBox_NbrDebout.Text, out i);
            V.NombreDebout = i;
            V.Energie      = TextBox_Energie.Text;
            Int32.TryParse(TextBox_Puissane.Text, out i);
            V.PuissanceFiscale = i;
            Int32.TryParse(TextBox_Cylindree.Text, out i);
            V.Cylindree = i;
            Int32.TryParse(TextBox_Poidvide.Text, out i);
            V.PoidVide = i;
            Int32.TryParse(TextBox_ChargeUtile.Text, out i);
            V.CHargeUtile = i;
            Int32.TryParse(TextBox_PTAC.Text, out i);
            V.PTAC = i;
            Int32.TryParse(TextBox_Remorque.Text, out i);
            V.NumeroRemorque = i;
            V.TypeRemorque   = TextBox_TypeRemorque.Text;
            Int32.TryParse(TextBox_PoidVideRemorque.Text, out i);
            V.PoidVideRemorque = i;
            Int32.TryParse(TextBox_ChargeUtileRemorque.Text, out i);
            V.ChargeUtileRemorque = i;
            V.Organisme           = TextBox_Organisme.Text;
            Int32.TryParse(TextBox_Duree.Text, out i);
            V.Duree = i;
            Int32.TryParse(TextBox_Valeurvénal.Text, out i);
            V.ValeurVenale = i;
            Int32.TryParse(TextBox_ValeuràNeuf.Text, out i);
            V.ValeurANeuf = i;
            Int32.TryParse(TextBox_Classe.Text, out i);
            V.Classe     = i;
            V.Companie   = TextBox_Compagnie.Text;
            V.DateReleve = TextBox_DateReleve.Text;
            V.Delegation = true;
            var jsonSerialiser = new JavaScriptSerializer();
            var json           = jsonSerialiser.Serialize(V);

            Javascript.ConsoleLog(json);


            u.Vehicules.Add(V);
            u.SaveChanges();
        }
        // GET: vehicules/Create
        public ActionResult Create()
        {
            ViewBag.maintenanceFK = new SelectList(db.maintenance, "PK_maintenanceId", "PK_maintenanceId");
            ViewBag.parkingFK     = new SelectList(db.parking, "parkingId", "name");
            Vehicule vehicule = new Vehicule();

            return(View(vehicule));
        }
Esempio n. 27
0
 static void Main(string[] args)
 {
     Vahicule[] Tab = new Vehicule[4];
     Tab[0] = new Voiture("333 ABC 06", 2000, "peugeot", "360", true, false);
     Tab[1] = new Voiture("321 BBD 06", 2001, "renault", "clio", true, false);
     Tab[2] = new Voiture("333 ABC 06", 2000, "peugeot", "360", true, false);
     Tab[3] = new Voiture("333 ABC 06", 2000, "peugeot", "360", true, false);
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Vehicule vehicule = db.vehicule.Find(id);

            db.vehicule.Remove(vehicule);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 29
0
 public void add(Vehicule vehicle)
 {
     if (!_VehicleList.Contains(vehicle))
     {
         vehicle.Id = _VehicleList.Max(v => v.Id) + 1;
         _VehicleList.Add(vehicle);
     }
 }
Esempio n. 30
0
    public void InitLane(Vehicule vehiculePrefab)
    {
        sens = Random.Range(0, 2);

        gameObject.AddComponent <Spawner>();
        GetComponent <Spawner>().vehiculePrefab = vehiculePrefab;
        GetComponent <Spawner>().SetPath();
    }
Esempio n. 31
0
 // POST api/personne
 public Vehicule Post([FromBody] Vehicule value)
 {
     using (var context = new MasterDbContext())
     {
         context.Vehicules.Add(value);
         context.SaveChanges();
         return(value);
     }
 }
Esempio n. 32
0
        public static void Insert(Vehicule vehicule)
        {
            //Connexion
            SqlConnection connection = new SqlConnection();
            connection.ConnectionString = "LaboSPPPConnectionString";
            connection.Open();
            //Commande
            SqlCommand commande = new SqlCommand();
            commande.Connection = connection;
            commande.CommandText = "INSERT INTO Vehicule(Libelle) VALUES(@Libelle)";
            commande.Parameters.AddWithValue("Libelle", vehicule.Libelle);

            //Execution de la commande

            commande.ExecuteNonQuery();
            connection.Close();
        }
Esempio n. 33
0
 public void DeleteVehicule(Vehicule unVehicule)
 {
     this.dbAutoEcole.lesVehicules.Remove(unVehicule);
     End();
 }
Esempio n. 34
0
 public void CreateVehicule(Vehicule unVehicule)
 {
     this.dbAutoEcole.lesVehicules.Add(unVehicule);
     End();
 }
Esempio n. 35
0
 public static void Update( Vehicule vehicule)
 {
     SqlConnection connection = new SqlConnection();
     connection.ConnectionString = "LaboSPPPConnectionString";
     connection.Open();
     SqlCommand commande = new SqlCommand();
     commande.Connection = connection;
     string requete = "UPDATE Vehicule  SET Libelle= @Libelle  WHERE Identifiant = @Identifiant";
     commande.Parameters.AddWithValue("identifiant", vehicule.Identifiant);
     commande.Parameters.AddWithValue("Libelle", vehicule.Libelle);
     commande.CommandText = requete;
     commande.ExecuteNonQuery();
     connection.Close();
 }
Esempio n. 36
0
        /// <summary>
        /// Récupère une liste de Vehicule à partir de la base de données
        /// </summary>
        /// <returns>Une liste de client</returns>
        public static List<Vehicule> List()
        {
            //Récupération de la chaine de connexion
            //Connection
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["LaboSPPPConnectionString"];
            SqlConnection connection = new SqlConnection(connectionStringSettings.ToString());
            //Commande
            String requete = "SELECT Identifiant, Libelle, IdentifiantConstructeur FROM Vehicule";
            connection.Open();
            SqlCommand commande = new SqlCommand(requete, connection);
            //execution

            SqlDataReader dataReader = commande.ExecuteReader();

            List<Vehicule> list = new List<Vehicule>();
            while (dataReader.Read())
            {

                //1 - Créer un Vehicule à partir des donner de la ligne du dataReader
                Vehicule vehicule = new Vehicule();
                vehicule.Identifiant = dataReader.GetInt32(0);
                vehicule.Libelle = dataReader.GetString(1);
                vehicule.constructeur.Identifiant = dataReader.GetInt32(2);
                //2 - Ajouter ce Vehicule à la list de client
                list.Add(vehicule);
            }
            dataReader.Close();
            connection.Close();
            return list;
        }