Esempio n. 1
0
        public async Task <IActionResult> PutLivreur([FromRoute] int id, [FromBody] Livreur livreur)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != livreur.IdLivreur)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Livreur livreur = db.Livreurs.Find(id);

            db.Livreurs.Remove(livreur);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public LivController()
 {
     livreur          = new Livreur();
     livraison        = new Livraison();
     serviceLivreur   = new LivreurService();
     serviceLivraison = new LivraisonService();
     serviceProduct   = new ProductService();
 }
        public ActionResult CreateLivreur([FromBody] Livreur livreur)
        {
            _livreurRepository.CreateLivreur(livreur);

            return(CreatedAtRoute("GetLivreur", new
            {
                LivreurId = livreur.LivreurId
            }, livreur));
        }
 public ActionResult Edit([Bind(Include = "id,Mail,Nom,Prenom,Password")] Livreur livreur)
 {
     if (ModelState.IsValid)
     {
         db.Entry(livreur).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(livreur));
 }
Esempio n. 6
0
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Salary,Address,Age")] Livreur livreur)
 {
     if (ModelState.IsValid)
     {
         db.Entry(livreur).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(livreur));
 }
        public async Task <ActionResult> UpdateLivreurById(int id, [FromBody] LivreurForUpdateDto livreurDto)
        {
            Livreur livreur = await _livreurRepository.GetLivreurById(id);

            _mapper.Map(livreurDto, livreur);

            await _livreurRepository.UpdateLivreur();

            return(NoContent());
        }
        public ActionResult Create([Bind(Include = "id,Mail,Nom,Prenom,Password")] Livreur livreur)
        {
            if (ModelState.IsValid)
            {
                db.Livreur.Add(livreur);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(livreur));
        }
Esempio n. 9
0
 public LivraisonController(ApplicationUserManager userManager, ApplicationSignInManager signInManager)
 {
     livraison        = new Livraison();
     user             = new ApplicationUser();
     l                = new Livreur();
     livreur          = new Livreur();
     serviceLivraison = new LivraisonService();
     serviceLivreur   = new LivreurService();
     serviceCart      = new CartService();
     serviceCartLine  = new CartLineService();
 }
        public async Task <ActionResult> CreateLivreur(LivreurForCreateDto livreurDto)
        {
            Livreur livreurToCreate = _mapper.Map <Livreur>(livreurDto);

            await _livreurRepository.CreateLivreur(livreurToCreate);

            return(CreatedAtRoute("GetLivreur", new
            {
                id = livreurToCreate.Num_Liv
            }, livreurToCreate));
        }
Esempio n. 11
0
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Salary,Address,Age")] Livreur livreur)
        {
            if (ModelState.IsValid)
            {
                db.Livreurs.Add(livreur);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(livreur));
        }
Esempio n. 12
0
        public async Task <IActionResult> PostLivreur([FromBody] Livreur livreur)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Livreurs.Add(livreur);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLivreur", new { id = livreur.IdLivreur }, livreur));
        }
Esempio n. 13
0
        // GET: Livreurs/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Livreur livreur = db.Livreurs.Find(id);

            if (livreur == null)
            {
                return(HttpNotFound());
            }
            return(View(livreur));
        }
Esempio n. 14
0
 public LivraisonController()
 {
     t.T       = new Livreur();
     livraison = new Livraison();
     user      = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>()
                 .FindById(System.Web.HttpContext.Current.User.Identity.GetUserId <int>());
     l                = new Livreur();
     livreur          = new Livreur();
     serviceLivraison = new LivraisonService();
     serviceLivreur   = new LivreurService();
     serviceCart      = new CartService();
     serviceCartLine  = new CartLineService();
     //id = user.Id;
     userr = new ApplicationUser();
 }
Esempio n. 15
0
        public ActionResult Edit(int id, Livreur liv)
        {
            try
            {
                Livreur l = Service.GetById(id);
                l.LastName  = liv.LastName;
                l.FirstName = liv.FirstName;
                Service.Update(l);
                Service.Commit();
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 16
0
        public ActionResult Edit1(int id, Livreur liv)
        {
            try
            {
                Livreur l = Service.GetById(id);
                l.Disponibilité = liv.Disponibilité;
                l.Distance      = liv.Distance;
                l.Affectation   = liv.Affectation;
                Service.Update(l);
                Service.Commit();
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 17
0
        public ActionResult Delete(int id, Livreur livreur)
        {
            try
            {
                //Service.Delete(client);
                //Service.Commit();
                //Service.Dispose();
                Livreur c = Service.GetById(id);
                Service.Delete(c);
                Service.Commit();

                //Service.Delete(Service.Get(x=>x.ClientId.Equals(c)));
                // TODO: Add delete logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 18
0
 public ActionResult UpdateLivreur([FromBody] Livreur livreur)
 {
     _livreurRepository.UpdateLivreur(livreur);
     return(NoContent());
 }
        public async Task <int> CreateLivreur(Livreur livreur)
        {
            await _pizzaDbContext.AddAsync(livreur);

            return(await _pizzaDbContext.SaveChangesAsync());
        }
Esempio n. 20
0
 public AccountController()
 {
     livreur = new Livreur();
 }
Esempio n. 21
0
        static void Main()
        {
            Ville v1 = new Ville(1, "Lannion", 22300);
            Ville v2 = new Ville(2, "Quimper", 29000);
            Ville v3 = new Ville(3, "Rennes", 35000);
            Ville v4 = new Ville(4, "Paris", 75000);
            Ville v5 = new Ville(5, "Plugufan", 2970);
            Box   b1 = new Box(1, "3 rue des potiers0", 15, 45, v1);
            Box   b2 = new Box(2, "35 rue Charles DeGaulle", 45, 85, v1);
            Box   b3 = new Box(3, "130 route de bénodet", 16, 23, v1);
            Box   b4 = new Box(4, "11 rue des chateuax", 96, 45, v1);
            Box   b5 = new Box(5, "13 rue du Vendrdi", 135, 15, v1);

            Colis        c1  = new Colis(1, "15", "Non Affecte");
            Colis        c2  = new Colis(2, "23", "Non Affecte");
            Colis        c3  = new Colis(3, "54", "Non Affecte");
            Colis        c4  = new Colis(4, "95", "Non Affecte");
            Colis        c5  = new Colis(5, "250", "Non Affecte");
            Colis        c6  = new Colis(6, "145", "Non Affecte");
            Colis        c7  = new Colis(7, "159", "Non Affecte");
            Colis        c8  = new Colis(8, "155", "Non Affecte");
            Colis        c9  = new Colis(9, "1", "Non Affecte");
            Colis        c10 = new Colis(10, "26", "Non Affecte");
            Colis        c11 = new Colis(11, "45", "Non Affecte");
            Colis        c12 = new Colis(12, "12", "Non Affecte");
            Colis        c13 = new Colis(13, "56", "Non Affecte");
            Colis        c14 = new Colis(14, "5", "Non Affecte");
            Colis        c15 = new Colis(15, "19", "Non Affecte");
            Compartiment co1 = new Compartiment(1, 15, 65, b1);
            Compartiment co2 = new Compartiment(2, 14, 65, b1);
            Compartiment co3 = new Compartiment(3, 13, 45, b2);
            Compartiment co4 = new Compartiment(4, 12, 45, b2);
            Compartiment co5 = new Compartiment(5, 11, 65, b3);
            Compartiment co6 = new Compartiment(6, 10, 45, b3);
            Compartiment co7 = new Compartiment(7, 9, 65, b4);
            Client       p1  = new Professionnel(15, 18, "Lusven", 1, "Galaad", "impasse du pommier blanc", v2, 15, 48);
            Client       p2  = new Individuel(15, "Trottmann", 3, "Florent", "CharlesDeGaule", v5, 15, 46);
            Client       p3  = new Professionnel(85, 15, "Garnier", 2, "Malo", "VersRennes", v3, 48, 85);
            Client       p4  = new Individuel(55, "Herve", 4, "Quentin", "AuLycée", v1, 74, 12);
            Client       p5  = new Professionnel(52, 15, "Besnard", 5, "Damien", "AuLycée", v1, 45, 62);
            Livreur      l1  = new Livreur(1, "Corson", "Kylian");
            Livreur      l2  = new Livreur(2, "Henaff", "Melvin");
            Livreur      l3  = new Livreur(3, "Marmonnier", "Adrien");
            Livreur      l4  = new Livreur(4, "Girardin", "Raoul");


            co1.LesColis.Add(c1);
            co1.LesColis.Add(c2);
            co2.LesColis.Add(c3);
            co2.LesColis.Add(c4);
            co3.LesColis.Add(c5);
            co3.LesColis.Add(c6);
            co4.LesColis.Add(c7);
            co4.LesColis.Add(c8);
            co5.LesColis.Add(c9);
            co5.LesColis.Add(c10);
            co6.LesColis.Add(c11);
            co6.LesColis.Add(c12);
            co7.LesColis.Add(c13);
            co7.LesColis.Add(c14);

            b1.LesCompartiments.Add(co1);
            b1.LesCompartiments.Add(co2);
            b2.LesCompartiments.Add(co3);
            b2.LesCompartiments.Add(co4);
            b3.LesCompartiments.Add(co5);
            b3.LesCompartiments.Add(co6);
            b4.LesCompartiments.Add(co7);

            b1.LesLivreurs.Add(l1);
            b1.LesLivreurs.Add(l2);
            b2.LesLivreurs.Add(l3);
            b2.LesLivreurs.Add(l3);
            b3.LesLivreurs.Add(l2);
            b3.LesLivreurs.Add(l1);
            b4.LesLivreurs.Add(l4);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
Esempio n. 22
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            int    codeParametrage = Convert.ToInt32(textcode.Text.Trim());
            string libelle         = textlibelle.Text.Trim();

            //
            //Save Livreur
            //

            if (LibelleForm.libelle == "Livreur")
            {
                Livreur liv = db.Livreurs.ToList <DAL.Livreur>().Where(w => w.CodeLivreur == codeParametrage).FirstOrDefault();
                if (liv == null)
                {
                    liv = new Livreur {
                        CodeLivreur = codeParametrage, Libelle = libelle
                    };
                    GenericRepository <Livreur> livr = new GenericRepository <Livreur>(db);
                    livr.Insert(liv);
                }
                else
                {
                    MessageBox.Show("Enregistrement existe déjà", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Save Moyen de Transport
            //
            if (LibelleForm.libelle == "Moyen de Transport")
            {
                EasyPlant.DAL.MoyenTransport moyenTransport = new EasyPlant.DAL.MoyenTransport {
                    CodeMoyenTransport = codeParametrage, Libelle = libelle
                };
                GenericRepository <MoyenTransport> GenmoyenTransp = new GenericRepository <MoyenTransport>(db);
                GenmoyenTransp.Insert(moyenTransport);
            }
            //
            //Save Banque
            //
            if (LibelleForm.libelle == "Banque")
            {
                EasyPlant.DAL.Banque banque = new EasyPlant.DAL.Banque {
                    CodeBanque = codeParametrage, Libelle = libelle
                };
                GenericRepository <Banque> GeneBanque = new GenericRepository <Banque>(db);
                GeneBanque.Insert(banque);
            }
            //
            //Save Mode de Réglement
            //
            if (LibelleForm.libelle == "Mode de Réglement")
            {
                EasyPlant.DAL.ModeReglement modeReglement = new EasyPlant.DAL.ModeReglement {
                    CodeModeReg = codeParametrage, Libelle = libelle
                };
                GenericRepository <ModeReglement> GenmoyenTransp = new GenericRepository <ModeReglement>(db);
                GenmoyenTransp.Insert(modeReglement);
            }
            //
            //Save Type Client
            //
            if (LibelleForm.libelle == "Type Client")
            {
                EasyPlant.DAL.TypeClient typeclient = new EasyPlant.DAL.TypeClient {
                    CodeTypeClient = codeParametrage, Libelle = libelle
                };
                GenericRepository <TypeClient> GenmoyenTransp = new GenericRepository <TypeClient>(db);
                GenmoyenTransp.Insert(typeclient);
            }
            //
            //Save Familles
            //
            if (LibelleForm.libelle == "Liste Familles")
            {
                EasyPlant.DAL.Famille famille = new EasyPlant.DAL.Famille {
                    CodeFamille = codeParametrage, LibelleFamille = libelle
                };
                GenericRepository <EasyPlant.DAL.Famille> fam = new GenericRepository <EasyPlant.DAL.Famille>(db);
                fam.Insert(famille);
            }
            //
            //Save Type production
            //
            if (LibelleForm.libelle == "Type de Production")
            {
                EasyPlant.DAL.TypeProduction prod = new EasyPlant.DAL.TypeProduction {
                    CodeTypeProd = codeParametrage, Libelle = libelle
                };
                GenericRepository <EasyPlant.DAL.TypeProduction> prods = new GenericRepository <EasyPlant.DAL.TypeProduction>(db);
                prods.Insert(prod);
            }
            //
            //Save Type Comptage
            //
            if (LibelleForm.libelle == "Type de Comptage")
            {
                EasyPlant.DAL.TypeComptage typecomp = new EasyPlant.DAL.TypeComptage {
                    CodeTypeCom = codeParametrage, Libelle = libelle
                };
                GenericRepository <EasyPlant.DAL.TypeComptage> typecomps = new GenericRepository <EasyPlant.DAL.TypeComptage>(db);
                typecomps.Insert(typecomp);
            }
            //
            //Save Colisage
            //
            if (LibelleForm.libelle == "Colisage")
            {
                EasyPlant.DAL.Colisage col = new EasyPlant.DAL.Colisage {
                    CodeColisage = codeParametrage, Libelle = libelle
                };
                GenericRepository <EasyPlant.DAL.Colisage> cols = new GenericRepository <EasyPlant.DAL.Colisage>(db);
                cols.Insert(col);
            }
            //
            //Save Unité
            //
            if (LibelleForm.libelle == "Unité")
            {
                EasyPlant.DAL.Unite uni = new EasyPlant.DAL.Unite {
                    CodeUnite = codeParametrage, Libelle = libelle
                };
                GenericRepository <EasyPlant.DAL.Unite> unis = new GenericRepository <EasyPlant.DAL.Unite>(db);
                unis.Insert(uni);
            }
            MessageBox.Show("Enregistrement avec succées");
            Clear();
            frmCodeLibelle_Load(sender, e);
        }
Esempio n. 23
0
        private void btndelete_Click(object sender, EventArgs e)
        {
            int    codeParametrage = Convert.ToInt32(textcode.Text.Trim());
            string libelle         = textlibelle.Text.Trim();

            if (MessageBox.Show("Etes-vous sûr de vouloir supprimer ce type?", "Supprimer?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (LibelleForm.libelle == "Livreur")
                {
                    Livreur liv = db.Livreurs.ToList <DAL.Livreur>().Where(w => w.CodeLivreur == codeParametrage).FirstOrDefault();
                    GenericRepository <Livreur> livr = new GenericRepository <Livreur>(db);
                    livr.Delete(liv);
                }


                if (LibelleForm.libelle == "Moyen de Transport")
                {
                    MoyenTransport moy = db.MoyenTransports.ToList <DAL.MoyenTransport>().Where(w => w.CodeMoyenTransport == codeParametrage).FirstOrDefault();
                    GenericRepository <MoyenTransport> moys = new GenericRepository <MoyenTransport>(db);
                    moys.Delete(moy);
                }
                if (LibelleForm.libelle == "Banque")
                {
                    Banque ban = db.Banques.ToList <DAL.Banque>().Where(w => w.CodeBanque == codeParametrage).FirstOrDefault();
                    GenericRepository <Banque> bans = new GenericRepository <Banque>(db);
                    bans.Delete(ban);
                }
                if (LibelleForm.libelle == "Mode de Réglement")
                {
                    ModeReglement mode = db.ModeReglements.ToList <DAL.ModeReglement>().Where(w => w.CodeModeReg == codeParametrage).FirstOrDefault();
                    GenericRepository <ModeReglement> modes = new GenericRepository <ModeReglement>(db);
                    modes.Delete(mode);
                }
                if (LibelleForm.libelle == "Type Client")
                {
                    Client cl = db.Clients.ToList <DAL.Client>().Where(w => w.CodeClient == codeParametrage).FirstOrDefault();
                    GenericRepository <Client> cls = new GenericRepository <Client>(db);
                    cls.Delete(cl);
                }
                if (LibelleForm.libelle == "Liste Familles")
                {
                    Famille famille = db.Familles.ToList <Famille>().Where(w => w.CodeFamille == codeParametrage).FirstOrDefault();
                    GenericRepository <Famille> fam = new GenericRepository <Famille>(db);
                    fam.Insert(famille);
                }
                if (LibelleForm.libelle == "Type de Production")
                {
                    EasyPlant.DAL.TypeProduction prod = db.TypeProductions.ToList <DAL.TypeProduction>().Where(w => w.CodeTypeProd == codeParametrage).FirstOrDefault();
                    GenericRepository <EasyPlant.DAL.TypeProduction> prods = new GenericRepository <EasyPlant.DAL.TypeProduction>(db);
                    prods.Insert(prod);
                }
                if (LibelleForm.libelle == "Type de Comptage")
                {
                    EasyPlant.DAL.TypeComptage typecomp = db.TypeComptages.ToList <DAL.TypeComptage>().Where(w => w.CodeTypeCom == codeParametrage).FirstOrDefault();
                    GenericRepository <EasyPlant.DAL.TypeComptage> typecomps = new GenericRepository <EasyPlant.DAL.TypeComptage>(db);
                    typecomps.Insert(typecomp);
                }

                if (LibelleForm.libelle == "Colisage")
                {
                    EasyPlant.DAL.Colisage col = db.Colisages.ToList <DAL.Colisage>().Where(w => w.CodeColisage == codeParametrage).FirstOrDefault();
                    GenericRepository <EasyPlant.DAL.Colisage> cols = new GenericRepository <EasyPlant.DAL.Colisage>(db);
                    cols.Insert(col);
                }
                if (LibelleForm.libelle == "Unité")
                {
                    EasyPlant.DAL.Unite uni = db.Unites.ToList <DAL.Unite>().Where(w => w.CodeUnite == codeParametrage).FirstOrDefault();
                    GenericRepository <EasyPlant.DAL.Unite> unis = new GenericRepository <EasyPlant.DAL.Unite>(db);
                    unis.Insert(uni);
                }

                db.SaveChanges();
                Clear();
                frmCodeLibelle_Load(sender, e);
                MessageBox.Show("Suppresion avec succées");
            }
        }
Esempio n. 24
0
 public ActionResult Create(Livreur livreur)
 {
     Service.Add(livreur);
     Service.Commit();
     return(RedirectToAction("Index"));
 }
Esempio n. 25
0
        private void btnModifier_Click(object sender, EventArgs e)
        {
            int    codeParametrage = Convert.ToInt32(textcode.Text.Trim());
            string libelle         = textlibelle.Text.Trim();

            //
            // Modifier Livreur
            //
            if (LibelleForm.libelle == "Livreur")
            {
                Livreur liv = db.Livreurs.ToList <DAL.Livreur>().Where(w => w.CodeLivreur == codeParametrage).FirstOrDefault();
                if (liv == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    liv.Libelle = libelle;
                    GenericRepository <Livreur> livr = new GenericRepository <Livreur>(db);
                    livr.Update(liv);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Moyen de Transport
            //
            if (LibelleForm.libelle == "Moyen de Transport")
            {
                MoyenTransport moy = db.MoyenTransports.ToList <DAL.MoyenTransport>().Where(w => w.CodeMoyenTransport == codeParametrage).FirstOrDefault();
                if (moy == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    moy.Libelle = libelle;
                    GenericRepository <MoyenTransport> Moys = new GenericRepository <MoyenTransport>(db);
                    Moys.Update(moy);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Banque
            //

            if (LibelleForm.libelle == "Banque")
            {
                Banque ban = db.Banques.ToList <DAL.Banque>().Where(w => w.CodeBanque == codeParametrage).FirstOrDefault();
                if (ban == null)
                {
                    MessageBox.Show("Enregistrementn'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    ban.Libelle = libelle;
                    GenericRepository <Banque> banques = new GenericRepository <Banque>(db);
                    banques.Update(ban);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Mode de Réglements
            //
            if (LibelleForm.libelle == "Mode de Réglement")
            {
                ModeReglement mode = db.ModeReglements.ToList <DAL.ModeReglement>().Where(w => w.CodeModeReg == codeParametrage).FirstOrDefault();
                if (mode == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    mode.Libelle = libelle;
                    GenericRepository <ModeReglement> modeReg = new GenericRepository <ModeReglement>(db);
                    modeReg.Update(mode);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Type Client
            //
            if (LibelleForm.libelle == "Type Client")
            {
                TypeClient typeCL = db.TypeClients.ToList <DAL.TypeClient>().Where(w => w.CodeTypeClient == codeParametrage).FirstOrDefault();
                if (typeCL == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    typeCL.Libelle = libelle;
                    GenericRepository <TypeClient> typeClient = new GenericRepository <TypeClient>(db);
                    typeClient.Update(typeCL);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Familles
            //
            if (LibelleForm.libelle == "Liste Familles")
            {
                Famille fam = db.Familles.ToList <DAL.Famille>().Where(w => w.CodeFamille == codeParametrage).FirstOrDefault();
                if (fam == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    fam.LibelleFamille = libelle;
                    GenericRepository <Famille> fams = new GenericRepository <Famille>(db);
                    fams.Update(fam);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Type production
            //
            if (LibelleForm.libelle == "Type de Production")
            {
                TypeProduction pro = db.TypeProductions.ToList <DAL.TypeProduction>().Where(w => w.CodeTypeProd == codeParametrage).FirstOrDefault();
                if (pro == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    pro.Libelle = libelle;
                    GenericRepository <TypeProduction> typeprod = new GenericRepository <TypeProduction>(db);
                    typeprod.Update(pro);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Type Comptage
            //
            if (LibelleForm.libelle == "Type de Comptage")
            {
                TypeComptage com = db.TypeComptages.ToList <DAL.TypeComptage>().Where(w => w.CodeTypeCom == codeParametrage).FirstOrDefault();
                if (com == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    com.Libelle = libelle;
                    GenericRepository <TypeComptage> typecom = new GenericRepository <TypeComptage>(db);
                    typecom.Update(com);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Colisage
            //
            if (LibelleForm.libelle == "Colisage")
            {
                Colisage col = db.Colisages.ToList <DAL.Colisage>().Where(w => w.CodeColisage == codeParametrage).FirstOrDefault();
                if (col == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    col.Libelle = libelle;
                    GenericRepository <Colisage> cols = new GenericRepository <Colisage>(db);
                    cols.Update(col);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Unité
            //
            if (LibelleForm.libelle == "Unité")
            {
                Unite uni = db.Unites.ToList <DAL.Unite>().Where(w => w.CodeUnite == codeParametrage).FirstOrDefault();
                if (uni == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    uni.Libelle = libelle;
                    GenericRepository <Unite> unis = new GenericRepository <Unite>(db);
                    unis.Update(uni);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            Clear();
            frmCodeLibelle_Load(sender, e);
        }
Esempio n. 26
0
 /// <summary>
 /// Bouton de validation des modifications faites sur un livreur
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ValiderLivreur(object sender, RoutedEventArgs e)
 {
     if (ComboBox_LivreurModif.SelectedItem != null)
     {
         if (this.pizzeria.Effectifs_pizzeria.Employes_livreurs.Contains((Livreur)ComboBox_LivreurModif.SelectedItem))
         {
             Livreur modif = (Livreur)ComboBox_LivreurModif.SelectedItem;
             if (ComboBox_LivreurEtat.SelectedItem != null)
             {
                 foreach (Livreur l in this.pizzeria.Effectifs_pizzeria.Employes_livreurs)
                 {
                     if (l.Nom.Equals(modif.Nom))
                     {
                         l.Etat = (string)ComboBox_LivreurEtat.SelectedItem;
                     }
                 }
             }
             if (NomBoxL.Text.Equals("") == false && NomBoxL.Text.Equals(modif.Nom) == false)
             {
                 foreach (Livreur l in this.pizzeria.Effectifs_pizzeria.Employes_livreurs)
                 {
                     if (l.Nom.Equals(modif.Nom))
                     {
                         l.Nom     = NomBoxL.Text;
                         modif.Nom = l.Nom;
                     }
                 }
             }
             if (PrenomBoxL.Text.Equals("") == false && PrenomBoxL.Text.Equals(modif.Prenom) == false)
             {
                 foreach (Livreur l in this.pizzeria.Effectifs_pizzeria.Employes_livreurs)
                 {
                     if (l.Nom.Equals(modif.Nom))
                     {
                         l.Prenom = PrenomBoxL.Text;
                     }
                 }
             }
             if (AdresseBoxL.Text.Equals("") == false && AdresseBoxL.Text.Equals(modif.Adresse) == false)
             {
                 foreach (Livreur l in this.pizzeria.Effectifs_pizzeria.Employes_livreurs)
                 {
                     if (l.Nom.Equals(modif.Nom))
                     {
                         l.Adresse = AdresseBoxL.Text;
                     }
                 }
             }
             if (PhoneBoxL.Text.Equals("") == false && PhoneBoxL.Text.Count() == 14 && PhoneBoxL.Text.Equals(modif.Telephone) == false)
             {
                 foreach (Livreur l in this.pizzeria.Effectifs_pizzeria.Employes_livreurs)
                 {
                     if (l.Nom.Equals(modif.Nom))
                     {
                         l.Telephone = PhoneBoxL.Text;
                     }
                 }
             }
         }
     }
     if (ComboBox_LivreurSupp.SelectedItem != null)
     {
         if (this.pizzeria.Effectifs_pizzeria.Employes_livreurs.Count > 1)
         {
             if (this.pizzeria.Effectifs_pizzeria.Employes_livreurs.Contains((Livreur)ComboBox_LivreurSupp.SelectedItem))
             {
                 this.pizzeria.Effectifs_pizzeria.Employes_livreurs.Remove((Livreur)ComboBox_LivreurSupp.SelectedItem);
             }
         }
         else
         {
             MessageBox.Show("Il ne reste plus qu'un livreur, impossible de le supprimer.");
         }
     }
     MessageBox.Show("Mise à jour effectuée.");
     this.Close();
 }
 /// <summary>
 /// Bouton pour envoyer une commande sélectionnée en livraison
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ALivrer(object sender, RoutedEventArgs e)
 {
     if (ComboBox_CommandeALivrer.SelectedItem == null)
     {
         MessageBox.Show("Veuillez sélectionner un item prêt, à livrer.");
     }
     else
     {
         Commande a_livrer = (Commande)(ComboBox_CommandeALivrer.SelectedItem);
         this.pizzeria.Commandes[a_livrer.No_commande].Etat = "en livraison";
         this.pizzeria.Cuisine.Envoyer_en_livraison(a_livrer.No_commande);
         string result = "";
         foreach (KeyValuePair <string, Commande> c in this.pizzeria.Cuisine.Pretes)
         {
             result += c.Value.ToString() + "\n";
         }
         RecapCommandePreteBlock.Text = result;
         sv_CommandePrete.Content     = RecapCommandePreteBlock.Text;
         List <Commande> CommandeALivrer = new List <Commande>();
         foreach (KeyValuePair <string, Commande> c in this.pizzeria.Cuisine.Pretes)
         {
             CommandeALivrer.Add(c.Value);
         }
         CommandeALivrer.Add(null);
         ComboBox_CommandeALivrer.ItemsSource = CommandeALivrer;
         if (this.pizzeria.Effectifs_pizzeria.Livreurs_disponible().Count != 0)
         {
             Livreur dispo = this.pizzeria.Effectifs_pizzeria.Livreurs_disponible().First().Value;
             this.pizzeria.Commandes[a_livrer.No_commande].Nom_livreur = dispo.Nom;
             Facture commande_a_facturer = new Facture(this.pizzeria.Commandes[a_livrer.No_commande], false);
             this.pizzeria.Effectifs_pizzeria.Employes_livreurs.Find(X => X.Nom.Equals(dispo.Nom)).FactureLivraison(this.pizzeria.Commandes[a_livrer.No_commande]);
             this.pizzeria.Effectifs_pizzeria.Employes_livreurs.Find(X => X.Nom.Equals(dispo.Nom)).Etat = "en livraison";
             MessageBox.Show("La commande numéro " + a_livrer.No_commande + " est partie en livraison !");
             Livraison l        = new Livraison(this.pizzeria, commande_a_facturer);
             string    commande = "";
             foreach (Pizza p in this.pizzeria.Commandes[a_livrer.No_commande].Pizzas)
             {
                 commande += p.ToString() + "\n";
             }
             foreach (Boisson b in this.pizzeria.Commandes[a_livrer.No_commande].Boissons)
             {
                 commande += b.ToString() + "\n";
             }
             l.InformationLivraisonBlock.Text = this.pizzeria.Commandes[a_livrer.No_commande].No_commande + "\n" + this.pizzeria.Commandes[a_livrer.No_commande].Date + "\n\n" + commande + "\n" + "Total Commande : " + this.pizzeria.Commandes[a_livrer.No_commande].PrixCommande() + "€";
             string num_client = this.pizzeria.Commandes[a_livrer.No_commande].Telephone_client;
             l.ClientBlock.Text = this.pizzeria.FindCustomerbyPhone(num_client).Nom + " " + this.pizzeria.FindCustomerbyPhone(num_client).Prenom + "\n" + this.pizzeria.FindCustomerbyPhone(num_client).Adresse + "\n" + this.pizzeria.FindCustomerbyPhone(num_client).Telephone;
             l.Show();
             this.Close();
         }
         else
         {
             MessageBox.Show("Il n'y a pas de livreurs disponibles en pizzeria.");
             this.pizzeria.AnnulerLivraison(this.pizzeria.Commandes[a_livrer.No_commande], this.pizzeria.Commandes[a_livrer.No_commande].Nom_livreur);
             result = "";
             foreach (KeyValuePair <string, Commande> c in this.pizzeria.Cuisine.Pretes)
             {
                 result += c.Value.ToString() + "\n";
             }
             RecapCommandePreteBlock.Text = result;
             sv_CommandePrete.Content     = RecapCommandePreteBlock.Text;
             List <Commande> CommandeALivrer2 = new List <Commande>();
             foreach (KeyValuePair <string, Commande> c in this.pizzeria.Cuisine.Pretes)
             {
                 CommandeALivrer2.Add(c.Value);
             }
             CommandeALivrer2.Add(null);
             ComboBox_CommandeALivrer.ItemsSource = CommandeALivrer2;
         }
     }
 }