public ActionResult Edit([Bind(Include = "Id,nom_article,reference,quantite,observation,FamilleID")] Article article) { if (ModelState.IsValid) { db.Entry(article).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FamilleID = new SelectList(db.Familles, "Id", "nom_famille", article.FamilleID); return(View(article)); }
public ActionResult Edit([Bind(Include = "id,reference,date,observation,OperationID,ArticleID,quantite,MachineID,EmployeeID")] Mvtarticle mvtarticle) { //génération automatique de matricule string ch = Guid.NewGuid().ToString(); string x = ch.Substring(0, 8); mvtarticle.reference = "REFM-" + x.ToString(); //MAJ Quantité Article en cas de retour d'article/ 1-> Retour article Article art = new Article(); art = db.Articles.Find(mvtarticle.ArticleID); if (mvtarticle.OperationID == 1) { art.quantite = art.quantite + mvtarticle.quantite; } db.Entry(art).State = EntityState.Modified; db.SaveChanges(); //MAJ Quantité Article en cas de sortir article Article art2 = new Article(); art2 = db.Articles.Find(mvtarticle.ArticleID); if (art2.quantite >= mvtarticle.quantite) { if (mvtarticle.OperationID == 2) { art2.quantite = art.quantite - mvtarticle.quantite; } } else { return(Content("<script language='javascript' type='text/javascript'>alert('Quantité article " + art2.nom_article + " non disponible!'); window.location.href = '/Mvtarticle/Create/'; </script> ")); } db.Entry(art2).State = EntityState.Modified; db.SaveChanges(); if (ModelState.IsValid) { db.Entry(mvtarticle).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ArticleID = new SelectList(db.Articles, "Id", "nom_article", mvtarticle.ArticleID); ViewBag.EmployeeID = new SelectList(db.Employees, "Id", "matricule", mvtarticle.EmployeeID); ViewBag.MachineID = new SelectList(db.Machines, "Id", "nom_machine", mvtarticle.MachineID); ViewBag.OperationID = new SelectList(db.Operations, "Id", "nom_operation", mvtarticle.OperationID); return(View(mvtarticle)); }
public ActionResult Edit([Bind(Include = "Id,nom_famille")] Famille famille) { if (ModelState.IsValid) { db.Entry(famille).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(famille)); }
public ActionResult Edit([Bind(Include = "Id,nom_operation")] Operation operation) { if (ModelState.IsValid) { db.Entry(operation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(operation)); }
public ActionResult Edit([Bind(Include = "Id,nom_fournisseur,matricule,adresse,email,telephone")] Fournisseur fournisseur) { if (ModelState.IsValid) { db.Entry(fournisseur).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(fournisseur)); }
public ActionResult Edit([Bind(Include = "Id,matricule,nom,prenom,email,identifiant,motdepasse,FonctionID")] Employee employee) { if (ModelState.IsValid) { db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FonctionID = new SelectList(db.Fonctions, "Id", "nom_fonction", employee.FonctionID); return(View(employee)); }
public ActionResult Edit([Bind(Include = "Id,reference_commande,date,FournisseurID,ArticleID,quantite,observation")] Commande commande) { if (ModelState.IsValid) { db.Entry(commande).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ArticleID = new SelectList(db.Articles, "Id", "nom_article", commande.ArticleID); ViewBag.FournisseurID = new SelectList(db.Fournisseurs, "Id", "nom_fournisseur", commande.FournisseurID); return(View(commande)); }
public bool Update(T e) { try { db.Entry(e).State = EntityState.Modified; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }