public ActionResult DeleteConfirmed(int id) { livre livre = db.livres.Find(id); db.livres.Remove(livre); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: livres/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } livre livre = db.livres.Find(id); if (livre == null) { return(HttpNotFound()); } return(View(livre)); }
private void simpleButton5_Click(object sender, EventArgs e) { try { livre rpt = new livre(); rpt.DataSource = clreport.GetInstance().livre(DateTime.Parse(txtdate1.Text), DateTime.Parse(txtdate2.Text)); using (ReportPrintTool printTool = new ReportPrintTool(rpt)) { printTool.ShowPreviewDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ActionResult Edit([Bind(Exclude = "image")] livre livre, HttpPostedFileBase image) { byte[] data = new byte[image.ContentLength]; int status = image.InputStream.Read(data, 0, image.ContentLength); livre.image = data; if (ModelState.IsValid) { db.Entry(livre).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(livre)); }
public ActionResult deletePanier(int id,int idl, int qte) { if (ModelState.IsValid) { livre livre = db.livres.Find(idl); livre.stock = livre.stock + qte; db.Entry(livre).State = EntityState.Modified; db.SaveChanges(); panier pp = db.paniers.Find(id); db.paniers.Remove(pp); db.SaveChanges(); } return RedirectToAction("panier"); }
public ActionResult panier() { List<List<Object>> mycart = new List<List<Object>>(); if (Session["user"] != null) { user u = (user)Session["user"]; List<panier> p=db.paniers.Where(en =>en.idc==u.Id).ToList(); foreach(var i in p) { livre l = db.livres.Find(i.idl); mycart.Add(new List<Object> { i, l }); } } ViewData["panier"] = mycart; return View(); }
public ActionResult addPanier(int idc,int idl,int qte) { panier p = new panier(); p.idc = idc; p.idl = idl; p.qte = qte; if (ModelState.IsValid) { db.paniers.Add(p); db.SaveChanges(); livre livre =db.livres.Find(idl); livre.stock = livre.stock - qte; db.Entry(livre).State = EntityState.Modified; db.SaveChanges(); } return RedirectToAction("panier"); }