Exemplo n.º 1
0
 public ActionResult TraiterCommande(MaCommande cmd)
 {
     if (cmd.qtt > cmd.RefCat || cmd.qtt < 0)
     {
         ViewBag.qtt       = cmd.qtt;
         ViewBag.refc      = cmd.RefCat;
         ViewBag.Listcateg = dt.Categories.ToList();
         ViewBag.warn      = "La quantité ne doit pas dépasser le stock et ne peut pas etre nulle/negative !!";
         return(View("Lancercommande"));
     }
     else
     {
         Commande commande = new Commande();
         commande.DateCmd    = DateTime.Now.ToString("dd/MM/yyyy");
         commande.NumClient  = Int32.Parse(Session["IdClient"].ToString());
         commande.NumArticle = Int32.Parse(Session["numArticle"].ToString());
         commande.QteArticle = cmd.qtt;
         dt.Commandes.Add(commande);
         dt.SaveChanges();
         var y      = (from a in dt.Articles where a.NumArticle == commande.NumArticle select a).SingleOrDefault();
         int newStk = cmd.RefCat - cmd.qtt;
         y.stock = newStk.ToString();
         dt.SaveChanges();
         ViewBag.Listcateg = dt.Categories.ToList();
         ViewBag.warn      = "Votre commande a reussi";
         return(View("Lancercommande"));
     }
 }
        public ActionResult Create(Categorie categorie)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(categorie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(categorie));
        }
Exemplo n.º 3
0
        public ActionResult Create(Client client)
        {
            if (ModelState.IsValid)
            {
                db.Clients.Add(client);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(client));
        }
Exemplo n.º 4
0
        public ActionResult Create(Article article)
        {
            if (ModelState.IsValid)
            {
                db.Articles.Add(article);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RefCat = new SelectList(db.Categories, "RefCat", "NomCat", article.RefCat);
            return(View(article));
        }
Exemplo n.º 5
0
        public ActionResult Inscription(Client clt)
        {
            projetMvcEntities dt = new projetMvcEntities();
            var x = (from c in dt.Clients where c.login == clt.login select c).SingleOrDefault();

            if (Request.Form["submitform"] != null)
            {
                if (ModelState.IsValid)
                {
                    dt.Clients.Add(clt);
                    var test = dt.SaveChanges();
                    if (test != 0)
                    {
                        Session["style"] = "on";
                        return(JavaScript("window.location = '" + Url.Action("Index", "Login") + "'"));
                    }
                    else
                    {
                        ViewBag.logExist = "Erreur de base de donnée !";
                        return(PartialView("_Partial1"));
                    }
                }
                else
                {
                    return(PartialView("_Partial2"));
                }
            }
            else
            {
                if (x != null)
                {
                    ViewBag.logExist = "ce login existe déjà !";
                    return(PartialView("_Partial1"));
                }
                else
                {
                    ViewBag.logExist = "";
                    return(PartialView("_Partial1"));
                }
            }
        }