public ActionResult UpdateDevolucionDetalle(tbDevolucionDetalle EditDevolucionDetalle) { try { var MensajeError = ""; IEnumerable <object> list = null; list = db.UDP_Vent_tbDevolucionDetalle_Update(EditDevolucionDetalle.devd_Id, EditDevolucionDetalle.dev_Id, EditDevolucionDetalle.prod_Codigo, EditDevolucionDetalle.devd_CantidadProducto, EditDevolucionDetalle.devd_Descripcion, EditDevolucionDetalle.devd_Monto, EditDevolucionDetalle.devd_UsuarioCrea, EditDevolucionDetalle.devd_FechaCrea); foreach (UDP_Vent_tbDevolucionDetalle_Update_Result DevolucionDetalle in list) { MensajeError = DevolucionDetalle.MensajeError; } if (MensajeError == "-1") { ModelState.AddModelError("", "No se pudo actualizar el registro, favor contacte al administrador."); return(PartialView("_EditarDetalleDevolucion")); } else { return(RedirectToAction("Index")); } } catch (Exception Ex) { Ex.Message.ToString(); ModelState.AddModelError("", "No se pudo actualizar el registro, favor contacte al administrador."); return(PartialView("_EditarDetalleDevolucion", EditDevolucionDetalle)); } }
// POST: /Devolucion/Create // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see http://go.microsoft.com/fwlink/?LinkId=317598. //[HttpPost] //[ValidateAntiForgeryToken] //public ActionResult Create([Bind(Include="dev_Id,fact_Id,cja_Id,dev_Fecha,dev_UsuarioCrea,dev_FechaCrea,dev_UsuarioModifica,dev_FechaModifica")] tbDevolucion tbDevolucion) //{ // if (ModelState.IsValid) // { // db.tbDevolucion.Add(tbDevolucion); // db.SaveChanges(); // return RedirectToAction("Index"); // } // ViewBag.dev_UsuarioCrea = new SelectList(db.tbUsuario, "usu_Id", "usu_NombreUsuario", tbDevolucion.dev_UsuarioCrea); // ViewBag.dev_UsuarioModifica = new SelectList(db.tbUsuario, "usu_Id", "usu_NombreUsuario", tbDevolucion.dev_UsuarioModifica); // ViewBag.cja_Id = new SelectList(db.tbCaja, "cja_Id", "cja_Descripcion", tbDevolucion.cja_Id); // ViewBag.fact_Id = new SelectList(db.tbFactura, "fact_Id", "fact_Codigo", tbDevolucion.fact_Id); // return View(tbDevolucion); //} // GET: /Devolucion/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbDevolucion tbDevolucion = db.tbDevolucion.Find(id); tbDevolucionDetalle tbDevolucionDetalle = db.tbDevolucionDetalle.Find(id); if (tbDevolucion == null) { return(HttpNotFound()); } ViewBag.dev_UsuarioCrea = new SelectList(db.tbUsuario, "usu_Id", "usu_NombreUsuario", tbDevolucion.dev_UsuarioCrea); ViewBag.dev_UsuarioModifica = new SelectList(db.tbUsuario, "usu_Id", "usu_NombreUsuario", tbDevolucion.dev_UsuarioModifica); ViewBag.cja_Id = new SelectList(db.tbCaja, "cja_Id", "cja_Descripcion", tbDevolucion.cja_Id); ViewBag.fact_Id = new SelectList(db.tbFactura, "fact_Id", "fact_Codigo", tbDevolucion.fact_Id); ViewBag.FacturaDetalle = db.tbFacturaDetalle.ToList(); Session["ID"] = tbDevolucion.dev_Id; Session["FECHA"] = tbDevolucion.dev_Fecha; Session["RTNCLIENTE"] = tbDevolucion.tbFactura.clte_Identificacion; Session["NOMBRE"] = tbDevolucion.tbFactura.clte_Nombres; //Session["Devolucion"] = null; //Session["MONTO"] = tbDevolucionDetalle.devd_Monto; return(View(tbDevolucion)); }
public ActionResult Details(int?id) { if (id == null) { return(RedirectToAction("Index")); } tbDevolucionDetalle tbDevolucionDetalle = new tbDevolucionDetalle(); tbDevolucion tbDevolucion = db.tbDevolucion.Find(id); if (tbDevolucion == null) { return(RedirectToAction("NotFound", "Login")); } Session["ID"] = tbDevolucion.dev_Id; Session["FECHA"] = tbDevolucion.dev_Fecha; Session["IDCAJA"] = tbDevolucion.cja_Id; Session["CAJA"] = tbDevolucion.tbCaja.cja_Descripcion; Session["IDSUCURSAL"] = tbDevolucion.tbCaja.suc_Id; Session["SUCURSAL"] = tbDevolucion.tbCaja.tbSucursales.suc_Descripcion; Session["RTNCLIENTE"] = tbDevolucion.tbFactura.clte_Identificacion; Session["IDCLIENTE"] = tbDevolucion.tbFactura.clte_Id; Session["NOMBRE"] = tbDevolucion.tbFactura.clte_Nombres; var ExiteNotaCredito = db.tbNotaCredito.Where(x => x.dev_Id == tbDevolucion.dev_Id).ToList(); if (ExiteNotaCredito.Count() > 0) { ViewBag.NotaCredito = "1"; } return(View(tbDevolucion)); }
public ActionResult DeleteConfirmed(int id) { tbDevolucionDetalle tbDevolucionDetalle = db.tbDevolucionDetalle.Find(id); db.tbDevolucionDetalle.Remove(tbDevolucionDetalle); db.SaveChanges(); return(RedirectToAction("Index")); }
public JsonResult RemoveDevolucionDetalle(tbDevolucionDetalle DetalleDevolucioncont) { var list = (List <tbDevolucionDetalle>)Session["Devolucion"]; if (list != null) { var itemToRemove = list.Single(r => r.devd_Id == DetalleDevolucioncont.devd_Id); list.Remove(itemToRemove); Session["Devolucion"] = list; } return(Json("", JsonRequestBehavior.AllowGet)); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbDevolucionDetalle tbDevolucionDetalle = db.tbDevolucionDetalle.Find(id); if (tbDevolucionDetalle == null) { return(HttpNotFound()); } return(View(tbDevolucionDetalle)); }
public ActionResult Edit([Bind(Include = "devd_Id,dev_Id,prod_Id,prod_Precio,devd_Cantidad,devd_Impuesto,devd_Descuento,devd_UsuarioCrea,devd_FechaCrea,devd_UsuarioModifica,devd_FechaModifica")] tbDevolucionDetalle tbDevolucionDetalle) { //tbDevolucionDetalle.devd_UsuarioCrea = 3; //tbDevolucionDetalle.devd_FechaCrea = DateTime.Now; tbDevolucionDetalle.devd_UsuarioModifica = 3; tbDevolucionDetalle.devd_FechaModifica = DateTime.Now; IEnumerable <object> listDevolucionDet = null; string MensajeError = ""; if (ModelState.IsValid) { try { listDevolucionDet = db.UDP_Vent_tbDevolucionDetalle_Update(tbDevolucionDetalle.devd_Id, tbDevolucionDetalle.dev_Id, tbDevolucionDetalle.prod_Id, tbDevolucionDetalle.prod_Precio, tbDevolucionDetalle.devd_Cantidad, tbDevolucionDetalle.devd_Impuesto, tbDevolucionDetalle.devd_Descuento, tbDevolucionDetalle.devd_UsuarioCrea, tbDevolucionDetalle.devd_FechaCrea, tbDevolucionDetalle.devd_UsuarioModifica, tbDevolucionDetalle.devd_FechaModifica); foreach (UDP_Vent_tbDevolucionDetalle_Update_Result Resultado in listDevolucionDet) { MensajeError = Resultado.MensajeError; } if (MensajeError.StartsWith("-1")) { ModelState.AddModelError("", "No se pudo ingresar el registro, contacte al administrador"); return(View(tbDevolucionDetalle)); } } catch (Exception ex) { ex.Message.ToString(); } return(RedirectToAction("Index")); } ViewBag.devd_UsuarioCrea = new SelectList(db.tbUsuarios, "usu_Id", "usu_NombreUsuario", tbDevolucionDetalle.devd_UsuarioCrea); ViewBag.devd_UsuarioModifica = new SelectList(db.tbUsuarios, "usu_Id", "usu_NombreUsuario", tbDevolucionDetalle.devd_UsuarioModifica); ViewBag.dev_Id = new SelectList(db.tbDevolucion, "dev_Id", "dev_Razon", tbDevolucionDetalle.dev_Id); return(View(tbDevolucionDetalle)); }
public JsonResult InsertDevolucion(tbDevolucionDetalle DetalleDevolucioncont) { List <tbDevolucionDetalle> sessionDevolucionDetalle = new List <tbDevolucionDetalle>(); var list = (List <tbDevolucionDetalle>)Session["Devolucion"]; if (list == null) { sessionDevolucionDetalle.Add(DetalleDevolucioncont); Session["Devolucion"] = sessionDevolucionDetalle; } else { list.Add(DetalleDevolucioncont); Session["Devolucion"] = list; } return(Json("Exito", JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbDevolucionDetalle tbDevolucionDetalle = db.tbDevolucionDetalle.Find(id); if (tbDevolucionDetalle == null) { return(HttpNotFound()); } ViewBag.devd_UsuarioCrea = new SelectList(db.tbUsuarios, "usu_Id", "usu_NombreUsuario", tbDevolucionDetalle.devd_UsuarioCrea); ViewBag.devd_UsuarioModifica = new SelectList(db.tbUsuarios, "usu_Id", "usu_NombreUsuario", tbDevolucionDetalle.devd_UsuarioModifica); ViewBag.dev_Id = new SelectList(db.tbDevolucion, "dev_Id", "dev_Razon", tbDevolucionDetalle.dev_Id); return(View(tbDevolucionDetalle)); }
public JsonResult RemoveDevolucionDetalle(tbDevolucionDetalle DetalleDevolucioncont) { try { var list = (List <tbDevolucionDetalle>)Session["Devolucion"]; if (list != null) { var itemToRemove = list.Single(r => r.devd_Id == DetalleDevolucioncont.devd_Id); list.Remove(itemToRemove); Session["Devolucion"] = list; } return(Json("", JsonRequestBehavior.AllowGet)); } catch (Exception Ex) { ModelState.AddModelError("", "Error al Acceder" + Ex.Message.ToString()); return(Json("", JsonRequestBehavior.AllowGet)); } }
public ActionResult _DetalleDevAnulada(int?id) { if (id == null) { return(RedirectToAction("Index")); } tbDevolucionDetalle tbDevolucionDetalle = new tbDevolucionDetalle(); tbDevolucion tbDevolucion = db.tbDevolucion.Find(id); if (tbDevolucion == null) { return(RedirectToAction("NotFound", "Login")); } var ExiteNotaCredito = db.tbNotaCredito.Where(x => x.dev_Id == tbDevolucion.dev_Id).ToList(); if (ExiteNotaCredito.Count() > 0) { ViewBag.NotaCredito = "1"; } return(View(tbDevolucion)); }
public ActionResult Edit(int?id) { if (id == null) { return(RedirectToAction("Index")); } tbDevolucion tbDevolucion = db.tbDevolucion.Find(id); tbDevolucionDetalle tbDevolucionDetalle = new tbDevolucionDetalle(); if (tbDevolucion == null) { return(RedirectToAction("NotFound", "Login")); } ViewBag.dev_UsuarioCrea = new SelectList(db.tbUsuario, "usu_Id", "usu_NombreUsuario", tbDevolucion.dev_UsuarioCrea); ViewBag.dev_UsuarioModifica = new SelectList(db.tbUsuario, "usu_Id", "usu_NombreUsuario", tbDevolucion.dev_UsuarioModifica); ViewBag.cja_Id = new SelectList(db.tbCaja, "cja_Id", "cja_Descripcion", tbDevolucion.cja_Id); ViewBag.fact_Id = new SelectList(db.tbFactura, "fact_Id", "fact_Codigo", tbDevolucion.fact_Id); ViewBag.FacturaDetalle = db.tbFacturaDetalle.ToList(); Session["ID"] = tbDevolucion.dev_Id; Session["FECHA"] = tbDevolucion.dev_Fecha; Session["IDCAJA"] = tbDevolucion.cja_Id; Session["CAJA"] = tbDevolucion.tbCaja.cja_Descripcion; Session["IDSUCURSAL"] = tbDevolucion.tbCaja.suc_Id; Session["SUCURSAL"] = tbDevolucion.tbCaja.tbSucursales.suc_Descripcion; Session["RTNCLIENTE"] = tbDevolucion.tbFactura.clte_Identificacion; Session["IDCLIENTE"] = tbDevolucion.tbFactura.clte_Id; Session["NOMBRE"] = tbDevolucion.tbFactura.clte_Nombres; var ExiteNotaCredito = db.tbNotaCredito.Where(x => x.dev_Id == tbDevolucion.dev_Id).ToList(); if (ExiteNotaCredito.Count() > 0) { var NotaCredito = db.tbNotaCredito.Where(l => l.dev_Id == tbDevolucion.dev_Id).Select(l => l.nocre_Codigo); ViewBag.NotaC = NotaCredito; ViewBag.NotaCredito = "1"; } return(View(tbDevolucion)); }
public ActionResult UpdateDevolucionDetalle(tbDevolucionDetalle EditDevolucionDetalle) { try { var MensajeError = ""; IEnumerable <object> list = null; list = db.UDP_Vent_tbDevolucionDetalle_Update(EditDevolucionDetalle.devd_Id, EditDevolucionDetalle.dev_Id, EditDevolucionDetalle.prod_Codigo, EditDevolucionDetalle.devd_CantidadProducto, EditDevolucionDetalle.devd_Descripcion, EditDevolucionDetalle.devd_Monto, EditDevolucionDetalle.devd_UsuarioCrea, EditDevolucionDetalle.devd_FechaCrea, Function.GetUser(), Function.DatetimeNow()); foreach (UDP_Vent_tbDevolucionDetalle_Update_Result DevDetalle in list) { MensajeError = DevDetalle.MensajeError; } if (MensajeError.StartsWith("-1")) { Function.InsertBitacoraErrores("Devolucion/UpdateDevolucionDetalle", MensajeError, "UpdateDevolucionDetalle"); ModelState.AddModelError("", "No se pudo actualizar el registro, favor contacte al administrador."); return(RedirectToAction("Edit", "Devolucion")); } else { return(RedirectToAction("Index")); } } catch (Exception Ex) { Function.InsertBitacoraErrores("Devolucion/UpdateDevolucionDetalle", Ex.Message.ToString(), "UpdateDevolucionDetalle"); ModelState.AddModelError("", "No se pudo actualizar el registro, favor contacte al administrador."); return(RedirectToAction("Edit", "Devolucion")); } }
public JsonResult InsertDevolucion(tbDevolucionDetalle DetalleDevolucioncont) { try { List <tbDevolucionDetalle> sessionDevolucionDetalle = new List <tbDevolucionDetalle>(); var list = (List <tbDevolucionDetalle>)Session["Devolucion"]; if (list == null) { sessionDevolucionDetalle.Add(DetalleDevolucioncont); Session["Devolucion"] = sessionDevolucionDetalle; } else { list.Add(DetalleDevolucioncont); Session["Devolucion"] = list; } return(Json("Exito", JsonRequestBehavior.AllowGet)); } catch (Exception Ex) { ModelState.AddModelError("", "Error al Acceder" + Ex.Message.ToString()); return(Json("", JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit([Bind(Include = "dev_Id,fact_Id,cja_Id,dev_Fecha,dev_Estado,dev_UsuarioCrea,dev_FechaCrea,dev_UsuarioModifica,dev_FechaModifica")] tbDevolucion tbDevolucion) { if (ModelState.IsValid) { try { var list = (List <tbDevolucionDetalle>)Session["Devolucion"]; var MensajeError = ""; var MensajeErrorDetalle = ""; IEnumerable <object> listDevolucion = null; IEnumerable <object> listDevolucionDetalle = null; tbDevolucionDetalle cDevolucionDetalle = new tbDevolucionDetalle(); using (TransactionScope Tran = new TransactionScope()) { listDevolucion = db.UDP_Vent_tbDevolucion_Update( tbDevolucion.dev_Id, tbDevolucion.fact_Id, tbDevolucion.cja_Id, tbDevolucion.dev_Fecha, tbDevolucion.dev_Estado, tbDevolucion.dev_UsuarioCrea, tbDevolucion.dev_FechaCrea); foreach (UDP_Vent_tbDevolucion_Update_Result DevolucionL in listDevolucion) { MensajeError = DevolucionL.MensajeError; } if (MensajeError == "-1") { ModelState.AddModelError("", "No se pudo Modificar el registro"); return(View(tbDevolucion)); } else { if (MensajeError != "-1") { if (list != null) { if (list.Count != 0) { foreach (tbDevolucionDetalle Detalle in list) { Detalle.dev_Id = Convert.ToInt32(MensajeError); listDevolucionDetalle = db.UDP_Vent_tbDevolucionDetalle_Insert( Detalle.dev_Id, Detalle.prod_Codigo, Detalle.devd_CantidadProducto, Detalle.devd_Descripcion, Detalle.devd_Monto); foreach (UDP_Vent_tbDevolucionDetalle_Insert_Result SPDevolucionDetalleDet in listDevolucionDetalle) { MensajeErrorDetalle = SPDevolucionDetalleDet.MensajeError; if (MensajeError == "-1") { ModelState.AddModelError("", "No se pudo agregar el registro detalle"); return(View(tbDevolucion)); } } } } } } else { ModelState.AddModelError("", "No se pudo Modificar el registro"); return(View(tbDevolucion)); } } Tran.Complete(); return(RedirectToAction("Index")); } } catch (Exception Ex) { ViewBag.FacturaDetalle = db.tbFacturaDetalle.ToList(); ViewBag.Factura = db.tbFactura.ToList(); ViewBag.Cliente = db.tbCliente.ToList(); ModelState.AddModelError("", "No se pudo Modificar el registro" + Ex.Message.ToString()); return(View(tbDevolucion)); } } ViewBag.FacturaDetalle = db.tbFacturaDetalle.ToList(); ViewBag.Factura = db.tbFactura.ToList(); ViewBag.Cliente = db.tbCliente.ToList(); return(View(tbDevolucion)); }
public ActionResult Edit([Bind(Include = "dev_Id,fact_Id,cja_Id,dev_Fecha,dev_Estado,dev_UsuarioCrea,dev_FechaCrea,dev_UsuarioModifica,dev_FechaModifica")] tbDevolucion tbDevolucion) { var list = (List <tbDevolucionDetalle>)Session["Devolucion"]; var MensajeError = ""; var MensajeErrorDetalle = ""; IEnumerable <object> listDevolucion = null; IEnumerable <object> listDevolucionDetalle = null; tbDevolucionDetalle cDevolucionDetalle = new tbDevolucionDetalle(); var ExiteNotaCredito = db.tbNotaCredito.Where(x => x.dev_Id == tbDevolucion.dev_Id).ToList(); if (ExiteNotaCredito.Count() > 0) { ViewBag.Validacion = "1"; } if (ModelState.IsValid) { try { using (TransactionScope Tran = new TransactionScope()) { listDevolucion = db.UDP_Vent_tbDevolucion_Update( tbDevolucion.dev_Id, tbDevolucion.fact_Id, tbDevolucion.cja_Id, tbDevolucion.dev_Fecha, tbDevolucion.dev_Estado, tbDevolucion.dev_UsuarioCrea, tbDevolucion.dev_FechaCrea, Function.GetUser(), Function.DatetimeNow()); foreach (UDP_Vent_tbDevolucion_Update_Result DevolucionL in listDevolucion) { MensajeError = DevolucionL.MensajeError; } if (MensajeError.StartsWith("-1")) { Function.InsertBitacoraErrores("Devolucion/Edit", MensajeError, "Edit"); ModelState.AddModelError("", "No se pudo actualizar el registro, favor contacte al administrador."); return(View(tbDevolucion)); } else { if (!MensajeError.StartsWith("-1")) { if (list != null) { if (list.Count != 0) { foreach (tbDevolucionDetalle Detalle in list) { Detalle.dev_Id = Convert.ToInt32(MensajeError); listDevolucionDetalle = db.UDP_Vent_tbDevolucionDetalle_Insert( Detalle.dev_Id, Detalle.prod_Codigo, Detalle.devd_CantidadProducto, Detalle.devd_Descripcion, Detalle.devd_Monto, Function.GetUser(), Function.DatetimeNow()); foreach (UDP_Vent_tbDevolucionDetalle_Insert_Result SPDevolucionDetalleDet in listDevolucionDetalle) { MensajeErrorDetalle = SPDevolucionDetalleDet.MensajeError; if (MensajeError.StartsWith("-1")) { Function.InsertBitacoraErrores("Devolucion/Edit", MensajeError, "Edit"); ModelState.AddModelError("", "No se pudo actualizar el registro detalle, favor contacte al administrador."); return(View(tbDevolucion)); } } } } } } else { Function.InsertBitacoraErrores("Devolucion/Edit", MensajeError, "Edit"); ModelState.AddModelError("", "No se pudo actualizar el registro, favor contacte al administrador."); return(View(tbDevolucion)); } } Tran.Complete(); return(RedirectToAction("Index")); } } catch (Exception Ex) { ViewBag.FacturaDetalle = db.tbFacturaDetalle.ToList(); ViewBag.Factura = db.tbFactura.ToList(); ViewBag.Cliente = db.tbCliente.ToList(); Function.InsertBitacoraErrores("Devolucion/Edit", Ex.Message.ToString(), "Edit"); ModelState.AddModelError("", "No se pudo actualizar el registro, favor contacte al administrador."); return(View(tbDevolucion)); } } ViewBag.FacturaDetalle = db.tbFacturaDetalle.ToList(); ViewBag.Factura = db.tbFactura.ToList(); ViewBag.Cliente = db.tbCliente.ToList(); return(View(tbDevolucion)); }
public ActionResult UpdateDevolucionDetalleTest([PexAssumeUnderTest] DevolucionController target, tbDevolucionDetalle EditDevolucionDetalle) { ActionResult result = target.UpdateDevolucionDetalle(EditDevolucionDetalle); return(result); // TODO: agregar aserciones a método DevolucionControllerTest.UpdateDevolucionDetalleTest(DevolucionController, tbDevolucionDetalle) }
public JsonResult RemoveDevolucionDetalleTest([PexAssumeUnderTest] DevolucionController target, tbDevolucionDetalle DetalleDevolucioncont) { JsonResult result = target.RemoveDevolucionDetalle(DetalleDevolucioncont); return(result); // TODO: agregar aserciones a método DevolucionControllerTest.RemoveDevolucionDetalleTest(DevolucionController, tbDevolucionDetalle) }