// // GET: /CatalogueManagerItems/Edit/5 public ActionResult Edit(int id) { TABusinessLayer.SellerItems ctItems = dbset.SellerItemss.Single(emp => emp.itemId == id); if (ctItems == null) { return(HttpNotFound()); } ViewBag.SellerId = new SelectList(dbset.SellerDetailss.OrderBy(x => x.sellerName), "sellerId", "sellerName", ctItems.sellerId); ViewBag.CatalogueId = new SelectList(dbset.Catalogues.OrderBy(x => x.catalogueName), "catalogueId", "catalogueName", ctItems.catalogueId); return(View(ctItems)); }
public ActionResult Edit(TABusinessLayer.SellerItems collection) { if (ModelState.IsValid) { dbset.SaveChangesSellerItemsToDB(collection); //db.Entry(fooditem).State = EntityState.Modified; //db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SellerId = new SelectList(dbset.SellerDetailss.OrderBy(x => x.sellerName), "sellerId", "sellerName", collection.sellerId); ViewBag.CatalogueId = new SelectList(dbset.Catalogues.OrderBy(x => x.catalogueName), "catalogueId", "catalogueName", collection.catalogueId); return(View(collection)); }
public ActionResult Create(TABusinessLayer.SellerItems collection) { if (ModelState.IsValid) { var picc = collection.pictureC; dbset.AddItemsToDB(collection); return(RedirectToAction("Index")); } ViewBag.SellerId = new SelectList(dbset.SellerDetailss.OrderBy(x => x.sellerName), "sellerId", "sellerName"); ViewBag.CatalogueId = new SelectList(dbset.Catalogues.OrderBy(x => x.catalogueName), "catalogueId", "catalogueName"); return(View()); }
public SellerItems GetSellerItemsToChange(int id) { SellerItems selleritem = new SellerItems(); using (SqlConnection con = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand("spGetSellerItemsToChange", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter paramitemAlternatePicName = new SqlParameter(); paramitemAlternatePicName.ParameterName = "@id"; paramitemAlternatePicName.Value = id; cmd.Parameters.Add(paramitemAlternatePicName); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { selleritem.sellerId = Convert.ToDecimal(rdr["sellerId"]); selleritem.catalogueId = Convert.ToDecimal(rdr["catalogueId"]); selleritem.itemDescription = rdr["itemDescription"].ToString(); selleritem.itemId = Convert.ToDecimal(rdr["itemId"]); selleritem.itemName = rdr["itemName"].ToString(); selleritem.itemPrice = rdr["itemPrice"].ToString(); selleritem.itemPicture = rdr["itemPicture"].ToString(); selleritem.pictureA = rdr["pictureA"].ToString(); selleritem.pictureB = rdr["pictureB"].ToString(); selleritem.pictureC = rdr["pictureC"].ToString(); selleritem.itemAlternatePicName = rdr["itemAlternatePicName"].ToString(); //sellerItems.Add(selleritem); } rdr.Dispose(); } return(selleritem); }
public void SaveChangesSellerItemsToDB(SellerItems collection) { using (SqlConnection con = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand("spSaveChangesSellerItems", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter paramitemAlternatePicName = new SqlParameter(); paramitemAlternatePicName.ParameterName = "@itemAlternatePicName"; paramitemAlternatePicName.Value = collection.itemAlternatePicName; cmd.Parameters.Add(paramitemAlternatePicName); SqlParameter paramitemDescription = new SqlParameter(); paramitemDescription.ParameterName = "@itemDescription"; paramitemDescription.Value = collection.itemDescription; cmd.Parameters.Add(paramitemDescription); SqlParameter paramitemName = new SqlParameter(); paramitemName.ParameterName = "@itemName"; paramitemName.Value = collection.itemName; cmd.Parameters.Add(paramitemName); SqlParameter paramitemPicture = new SqlParameter(); paramitemPicture.ParameterName = "@itemPicture"; paramitemPicture.Value = collection.itemPicture; cmd.Parameters.Add(paramitemPicture); SqlParameter paramitemPictureA = new SqlParameter(); paramitemPictureA.ParameterName = "@pictureA"; paramitemPictureA.Value = collection.pictureA; cmd.Parameters.Add(paramitemPictureA); SqlParameter paramitemPictureB = new SqlParameter(); paramitemPictureB.ParameterName = "@pictureB"; paramitemPictureB.Value = collection.pictureB; cmd.Parameters.Add(paramitemPictureB); SqlParameter paramitemPictureC = new SqlParameter(); paramitemPictureC.ParameterName = "@pictureC"; paramitemPictureC.Value = collection.pictureC; cmd.Parameters.Add(paramitemPictureC); SqlParameter paramitemPrice = new SqlParameter(); paramitemPrice.ParameterName = "@itemPrice"; paramitemPrice.Value = collection.itemPrice; cmd.Parameters.Add(paramitemPrice); SqlParameter paramcatalogueId = new SqlParameter(); paramcatalogueId.ParameterName = "@catalogueId"; paramcatalogueId.Value = collection.catalogueId; cmd.Parameters.Add(paramcatalogueId); SqlParameter paramsellerId = new SqlParameter(); paramsellerId.ParameterName = "@sellerId"; paramsellerId.Value = collection.sellerId; cmd.Parameters.Add(paramsellerId); SqlParameter paramItemId = new SqlParameter(); paramItemId.ParameterName = "@itemId"; paramItemId.Value = collection.itemId; cmd.Parameters.Add(paramItemId); con.Open(); cmd.ExecuteNonQuery(); } }