public String ajouterBc(bon_commande Bl) { String resultat = "Ok"; using (NewCampusEntities db = new NewCampusEntities()) { if (this.testAjouterBc(Bl) == false) { try { db.bon_commande.Add(Bl); db.SaveChanges(); } catch (Exception e) { resultat = e.Message; } } else { resultat = "BL existante, verifiez le champs num Bc"; } } return(resultat); }
public ActionResult DeleteConfirmed(int id) { bon_commande bon_commande = db.bon_commande.Find(id); db.bon_commande.Remove(bon_commande); db.SaveChanges(); return(RedirectToAction("Index")); }
public void modifierBC(bon_commande bc) { using (NewCampusEntities db = new NewCampusEntities()) { db.bon_commande.Attach(db.bon_commande.Single(x => x.id == bc.id)); db.Entry(db.bon_commande.Single(x => x.id == bc.id)).CurrentValues.SetValues(bc); db.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "id_bon_commande,id_vehicule,id_commande")] bon_commande bon_commande) { if (ModelState.IsValid) { db.Entry(bon_commande).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.id_vehicule = new SelectList(db.vehicules, "id_vehicule", "immatriculation", bon_commande.id_vehicule); ViewBag.id_commande = new SelectList(db.commandes, "id_commande", "id_commande", bon_commande.id_commande); return(View(bon_commande)); }
// GET: bon_commande/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } bon_commande bon_commande = db.bon_commande.Find(id); if (bon_commande == null) { return(HttpNotFound()); } return(View(bon_commande)); }
// GET: bon_commande/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } bon_commande bon_commande = db.bon_commande.Find(id); if (bon_commande == null) { return(HttpNotFound()); } ViewBag.id_vehicule = new SelectList(db.vehicules, "id_vehicule", "immatriculation", bon_commande.id_vehicule); ViewBag.id_commande = new SelectList(db.commandes, "id_commande", "id_commande", bon_commande.id_commande); return(View(bon_commande)); }
public bon_commande GetAllBcBynum(int num) { // NewCampusEntities db = new NewCampusEntities(); bon_commande Bc = new bon_commande(); try { using (NewCampusEntities db = new NewCampusEntities()) { return(db.bon_commande.Where(aa => aa.numero_bc == num).FirstOrDefault()); } } catch (Exception) { Bc = new bon_commande(); } return(Bc); }
public String supprimerBc(bon_commande bl) { String resultat = "Bc supprimé"; using (NewCampusEntities db = new NewCampusEntities()) { try { db.bon_commande.Attach(bl);// selectionne l'element dans la base pour le supprimer dans l'etape suivante db.bon_commande.Remove(bl); db.SaveChanges(); } catch (Exception) { resultat = resultat + "," + bl.numero_bc; db.Dispose(); } } return(resultat); }
public Boolean testAjouterBc(bon_commande b) { Boolean trouve = true; //string s = cli.code; using (NewCampusEntities db = new NewCampusEntities()) { try { var cx = db.bon_commande.Single(c => c.numero_bc.Equals(b.numero_bc)); if (cx == null) { trouve = false; } } catch (Exception) { trouve = false; } } return(trouve); }