예제 #1
0
        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);
        }
예제 #2
0
        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"));
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
 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));
 }
예제 #5
0
        // 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));
        }
예제 #6
0
        // 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));
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }