public ActionResult Create([Bind(Include = "artikelid,artikelnaam,prijs,actief")] artikel artikel, HttpPostedFileBase file) { if (file != null) { //string pic = System.IO.Path.GetFileName(file.FileName); //Vind bestandstype extension string type = System.IO.Path.GetExtension(file.FileName); //Maak unieke filenaam string pic = string.Format(@"{0}{1}", DateTime.Now.Ticks, type); string path = System.IO.Path.Combine( Server.MapPath("~/images/artikels"), pic); // file is uploaded file.SaveAs(path); // Sla image naam op in db record artikel.image = pic; } if (ModelState.IsValid) { db.artikels.Add(artikel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(artikel)); }
public ActionResult DeleteConfirmed(int id) { artikel artikel = db.artikel.Find(id); db.artikel.Remove(artikel); db.SaveChanges(); return(RedirectToAction("Index")); }
//Hämtar artikeln om tjänster private void GetOneArtikel() { BusinessDAL bDAL = new BusinessDAL(); artikel art = new artikel(); art = bDAL.getArtikelInfo(1); lblRubrik.Text = art.rubrik; litBeskrivning.Text = art.beskrivning; }
public ActionResult Edit([Bind(Include = "artnr,bezeichnung,gruppe,vkpreis,lief,ekpreis,lieferzeit,mindbestand,hinweis,mengebestellt,mwst,aktiv,inaktivam,inaktivvon")] artikel artikel) { if (ModelState.IsValid) { db.Entry(artikel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.gruppe = new SelectList(db.artikelgruppen, "artgr", "grtext", artikel.gruppe); return(View(artikel)); }
// GET: InactiefArtikel/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } artikel artikel = db.artikels.Find(id); if (artikel == null) { return(HttpNotFound()); } return(View(artikel)); }
// GET: artikel/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } artikel artikel = db.artikel.Find(id); if (artikel == null) { return(HttpNotFound()); } ViewBag.gruppe = new SelectList(db.artikelgruppen, "artgr", "grtext", artikel.gruppe); return(View(artikel)); }
//Hämtar en artikel public artikel getArtikelInfo(int id) { DataTable dt = new DataTable(); artikel art = new artikel(); //Create a connection SqlConnection conn = new SqlConnection(connStr); //The procedure I want to call SqlCommand cmd = new SqlCommand("usp_artikel", conn); //Command type I want to execute cmd.CommandType = CommandType.StoredProcedure; try { conn.Open(); cmd.Parameters.AddWithValue("@artikelID", id); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { art.rubrik = reader["rubrik"].ToString(); art.beskrivning = reader["beskrivning"].ToString(); } return(art); } catch { throw; } finally { cmd.Dispose(); conn.Close(); conn.Dispose(); } }