// GET: Producto/NuevaPresentacion public JsonResult NuevaPresentacion(tbPresentacion presentacion) { presentacion.estado = true; db.tbPresentacion.InsertOnSubmit(presentacion); db.SubmitChanges(); return(Json(presentacion)); }
public void insertarPresentacion() { String pre = textBox2.Text.Trim(); if (pre.Length > 0) { tbPresentacion tbpresentacion = new tbPresentacion() { // codPresentacion =incremetal, presentacion = pre, descripcion = textBox1.Text.Trim() }; bd.tbPresentacion.InsertOnSubmit(tbpresentacion); try { bd.SubmitChanges(); padre.llenarComboPresentacion(); MessageBox.Show("Se ha agregado una nueva presentacion"); this.Close(); } catch (Exception ec) { MessageBox.Show("Error al ingresar registro" + ec.Message); } } else { MessageBox.Show("No se ha especificado una presentacion"); } }
public ActionResult CambiarEstado(int id) { dbHeredadesEntities db = new dbHeredadesEntities(); tbPresentacion presentacion = db.tbPresentacion.Find(id); return(View(presentacion)); }
public ActionResult CambiarEstado(int id, FormCollection collection) { dbHeredadesEntities db = new dbHeredadesEntities(); tbPresentacion presentacion = db.tbPresentacion.Find(id); presentacion.estado = !(presentacion.estado); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(int id, FormCollection collection) { try { // TODO: Add update logic here tbPresentacion editar = (from t in dt.tbPresentacion where t.codPresentacion == id select t).SingleOrDefault(); editar.presentacion = collection["presentacion"]; dt.SubmitChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult CambiarEstado(int codPresentacion, bool estado, FormCollection collection) { try { // TODO: Add delete logic here tbPresentacion cambio = (from t in db.tbPresentacion where t.codPresentacion == codPresentacion select t).SingleOrDefault(); cambio.estado = estado; db.SubmitChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Editar(tbPresentacion editada) { dbHeredadesEntities db = new dbHeredadesEntities(); if (!(db.tbPresentacion.Any(t => t.presentacion == editada.presentacion && t.codPresentacion != editada.codPresentacion))) { db.Entry(editada).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError(string.Empty, "¡Ya existe esta presentación!"); return(View(editada)); } }
public ActionResult Crear(tbPresentacion nueva) { dbHeredadesEntities db = new dbHeredadesEntities(); if (!(db.tbPresentacion.Any(t => t.presentacion == nueva.presentacion))) { nueva.estado = true; db.tbPresentacion.Add(nueva); db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError(string.Empty, "¡Ya existe esta presentación!"); return(View(nueva)); } }
public ActionResult Create(FormCollection collection) { try { // TODO: Add insert logic here tbPresentacion nueva = new tbPresentacion { presentacion = collection["presentacion"] }; dt.tbPresentacion.InsertOnSubmit(nueva); dt.SubmitChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Editar(tbPresentacion pre) { try { //TODO: Add update logic here tbPresentacion editar = (from t in db.tbPresentacion where t.codPresentacion == pre.codPresentacion select t).SingleOrDefault(); if (db.tbPresentacion.Where(x => x.presentacion == pre.presentacion).Any()) { ModelState.AddModelError("presentacion", "La presentacion ya existe"); return(View(pre)); } editar.presentacion = pre.presentacion; db.SubmitChanges(); return(RedirectToAction("Index")); } catch { ViewBag.errores = "No se pudo completar la operacion"; return(View("VistaDeErrores")); } }
public ActionResult Crear(tbPresentacion pre) { try { if (db.tbPresentacion.Where(x => x.presentacion == pre.presentacion).Any()) { ModelState.AddModelError("presentacion", "La presentacion ya existe"); return(View(pre)); } tbPresentacion nueva = new tbPresentacion { presentacion = pre.presentacion, estado = true }; db.tbPresentacion.InsertOnSubmit(nueva); db.SubmitChanges(); return(RedirectToAction("Index")); } catch { ViewBag.errores = "No se pudo completar la operacion"; return(View("VistaDeErrores")); } }
// GET: Presentacion/Edit/5 public ActionResult Edit(int id) { tbPresentacion editar = (from t in dt.tbPresentacion where t.codPresentacion == id select t).SingleOrDefault(); return(View(editar)); }
// GET: Presentacion/CambiarEstado/5 public ActionResult CambiarEstado(int codPresentacion, bool estado) { tbPresentacion cambio = (from t in db.tbPresentacion where t.codPresentacion == codPresentacion select t).SingleOrDefault(); return(View(cambio)); }