public ActionResult DevolverHerramienta(DevolucionHerramientaDetalleModels Models) { try { _PrestamoHerramienta_Datos Datos = new _PrestamoHerramienta_Datos(); DevolucionHerramientaDetalleModels ModelD = new DevolucionHerramientaDetalleModels { IDPrestamo = Models.IDPrestamo, IDPrestamoDetalle = Models.IDPrestamoDetalle, CantDevolver = Models.CantDevolver, Usuario = User.Identity.Name, Conexion = Conexion }; RespuestaAjax respuesta = new RespuestaAjax(); string usuario = User.Identity.Name; respuesta = Datos.ACDevolucionHerramientasAlmacenDetalle(ModelD); return(Content(respuesta.ToJSON(), "application/json")); } catch (Exception ex) { throw ex; } }
// GET: Admin/Prestamos/EditDetails/IDPrestamosDetalle public ActionResult EditDetails(int id) { try { if (id != 0) { Token.SaveToken(); _PrestamoHerramienta_Datos Datos = new _PrestamoHerramienta_Datos(); PrestamosHerramientasDetalleViewModels Model = Datos.ObtenerDatosSalidaDetalle(Conexion, id); _Combos_Datos CDatos = new _Combos_Datos(); Model.ListaProductos = CDatos.ObtenerComboProductosAlmacenXIDPrestamo(Conexion, Model.IDPrestamo); Model.ListaUnidades = CDatos.ObtenerComboUnidadesXIDProducto(Conexion, Model.IDProductoAlmacen); Model.Existencia = Datos.ObtenerExistenciaXIDProductoIDUnidadIDPrestamo(Conexion, Model.IDPrestamo, Model.IDProductoAlmacen, Model.IDUnidadProducto); return(View(Model)); } else { TempData["typemessage"] = "2"; TempData["message"] = "No se puede cargar la vista"; return(RedirectToAction("Index")); } } catch (Exception) { TempData["typemessage"] = "2"; TempData["message"] = "No se puede cargar la vista"; return(RedirectToAction("Index")); } }
// GET: Admin/Prestamos/Edit/5 public ActionResult Edit(int id) { try { Token.SaveToken(); PrestamoHerramientaViewModels Model = new PrestamoHerramientaViewModels(); _Combos_Datos CDatos = new _Combos_Datos(); _PrestamoHerramienta_Datos Datos = new _PrestamoHerramienta_Datos(); Model = Datos.ObtenerDetallePrestamosHerramienta(Conexion, id); if (Model.IDPrestamo != 0) { Model.ListaSucursales = CDatos.ObtenerComboSucursales(Conexion); Model.ListaAlmacenes = CDatos.ObtenerAlmacenesXIDSucursal(Conexion, Model.IDSucursal); Model.ListaEmpleados = CDatos.ObtenerComboEmpleadosSalidaAlmacen(Conexion, Model.IDSucursal); return(View(Model)); } else { TempData["typemessage"] = "2"; TempData["message"] = "No se puede cargar la vista"; return(RedirectToAction("Index")); } } catch (Exception) { TempData["typemessage"] = "2"; TempData["message"] = "No se puede cargar la vista"; return(RedirectToAction("Index")); } }
public ActionResult ObtenerExistenciaXIDProducto(string IDProducto, int IDPrestamo, string IDUnidad) { try { _PrestamoHerramienta_Datos Datos = new _PrestamoHerramienta_Datos(); string result = string.Format("{0:F3}", Datos.ObtenerExistenciaXIDProductoIDUnidadIDPrestamo(Conexion, IDPrestamo, IDProducto, IDUnidad)); return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ex.Message.ToString(); return(Json("", JsonRequestBehavior.AllowGet)); } }
// GET: Admin/Prestamos/Details/5 public ActionResult Details(int id) { try { List <PrestamoHerramientaDetalleModels> Model = new List <PrestamoHerramientaDetalleModels>(); _PrestamoHerramienta_Datos Datos = new _PrestamoHerramienta_Datos(); ViewBag.IdPrestamos = id; Model = Datos.ObtenerListaDetallePrestamosHerramientas(Conexion, id); return(View(Model)); } catch (Exception) { return(View(new List <SalidaAlmacenDetalleModels>())); } }
// GET: Admin/Prestamos public ActionResult Index() { try { List <PrestamoHerramientaModels> Model = new List <PrestamoHerramientaModels>(); _PrestamoHerramienta_Datos Datos = new _PrestamoHerramienta_Datos(); Model = Datos.ObtenerPrestamoHerramienta(Conexion); return(View(Model)); } catch (Exception) { TempData["typemessage"] = "2"; TempData["message"] = "No se puede cargar la vista"; return(View(new List <SalidaAlmacenModels>())); } }
public ActionResult Procesar(int id) { try { _PrestamoHerramienta_Datos Datos = new _PrestamoHerramienta_Datos(); PrestamoHerramientaModels Prestamo = Datos.ProcesarPrestamoHerramientasAlmacen(Conexion, id, User.Identity.Name); return(Json(Prestamo.Resultado)); //if (Prestamo.Resultado == 1) // return Json(1); //else if (Prestamo.Resultado == -3) // return Json(-3); //else // return Json(""); } catch (Exception) { return(Json("")); } }
public ActionResult DeleteDetails(int id) { try { _PrestamoHerramienta_Datos Datos = new _PrestamoHerramienta_Datos(); PrestamoHerramientaDetalleModels PrestamoD = Datos.EliminarPrestamoDetalle(Conexion, id, User.Identity.Name); if (PrestamoD.Completado) { return(Json("true")); } else { return(Json("")); } } catch (Exception) { return(Json("")); } }
public ActionResult Finalizar(int id4) { try { _PrestamoHerramienta_Datos Datos = new _PrestamoHerramienta_Datos(); DevolucionHerramientaDetalleModels Prestamo = Datos.FinalizarDevolucionHerramientasAlmacen(Conexion, id4, User.Identity.Name); if (Prestamo.Completado) { return(Json("true")); } else { return(Json("")); } } catch (Exception) { return(Json("")); } }
public ActionResult Devolucion(int id) { try { List <DevolucionHerramientaDetalleModels> Model = new List <DevolucionHerramientaDetalleModels>(); _PrestamoHerramienta_Datos Datos = new _PrestamoHerramienta_Datos(); ViewBag.IdPrestamos = id; Model = Datos.ObtenerListaDetalleDevolucionHerramientas(Conexion, id); if (Model.Count > 0) { ViewBag.Estatus = Model[0].Estatus; } else { ViewBag.Estatus = 2; } return(View(Model)); } catch (Exception) { return(View(new List <SalidaAlmacenDetalleModels>())); } }
public ActionResult Create(PrestamoHerramientaViewModels Model) { _PrestamoHerramienta_Datos Datos = new _PrestamoHerramienta_Datos(); _Combos_Datos CDatos = new _Combos_Datos(); try { if (Token.IsTokenValid()) { if (ModelState.IsValid) { PrestamoHerramientaModels ModelP = new PrestamoHerramientaModels { NuevoRegistro = true, IDPrestamo = 0, Almacen = new CatAlmacenModels { IDAlmacen = Model.IDAlmacen }, Sucursal = new CatSucursalesModels { IDSucursal = Model.IDSucursal }, Empleado = new CatEmpleadoModels { IDEmpleado = Model.IDEmpleado }, FechaPrestamo = Model.FechaPrestamo, Observacion = Model.Comentario, Conexion = Conexion, Usuario = User.Identity.Name }; Datos.ACPrestamosHerramientasAlmacen(ModelP); if (ModelP.Completado == true) { TempData["typemessage"] = "1"; TempData["message"] = "Los datos se guardaron correctamente."; Token.ResetToken(); return(RedirectToAction("CreateDetails", new { id = ModelP.IDPrestamo })); } else { Model.ListaSucursales = CDatos.ObtenerComboSucursales(Conexion); Model.ListaAlmacenes = CDatos.ObtenerAlmacenesXIDSucursal(Conexion, Model.IDSucursal); Model.ListaEmpleados = CDatos.ObtenerComboEmpleadosSalidaAlmacen(Conexion, Model.IDSucursal); TempData["typemessage"] = "2"; TempData["message"] = "Ocurrió un error al intentar guardar los datos. Intente más tarde."; return(View(Model)); } } else { Model.ListaSucursales = CDatos.ObtenerComboSucursales(Conexion); Model.ListaAlmacenes = CDatos.ObtenerAlmacenesXIDSucursal(Conexion, Model.IDSucursal); Model.ListaEmpleados = CDatos.ObtenerComboEmpleadosSalidaAlmacen(Conexion, Model.IDSucursal); return(View(Model)); } } else { return(RedirectToAction("Index")); } } catch { Model.ListaSucursales = CDatos.ObtenerComboSucursales(Conexion); Model.ListaAlmacenes = CDatos.ObtenerAlmacenesXIDSucursal(Conexion, Model.IDSucursal); Model.ListaEmpleados = CDatos.ObtenerComboEmpleadosSalidaAlmacen(Conexion, Model.IDSucursal); TempData["typemessage"] = "2"; TempData["message"] = "Ocurrió un error al intentar guardar los datos. Contacte a soporte técnico."; return(View(Model)); } }
public ActionResult EditDetails(PrestamosHerramientasDetalleViewModels Model) { _PrestamoHerramienta_Datos Datos = new _PrestamoHerramienta_Datos(); _Combos_Datos CDatos = new _Combos_Datos(); try { if (Token.IsTokenValid()) { if (ModelState.IsValid) { PrestamoHerramientaDetalleModels ModelP = new PrestamoHerramientaDetalleModels { NuevoRegistro = false, IDPrestamoDetalle = Model.IDPrestamoDetalle, IDPrestamo = Model.IDPrestamo, Producto = new CatProductosAlmacenModels { IDProductoAlmacen = Model.IDProductoAlmacen }, UnidadMedida = new UnidadesProductosAlmacenModels { id_unidadProducto = Model.IDUnidadProducto }, Cantidad = Model.Cantidad, Conexion = Conexion, Usuario = User.Identity.Name }; Datos.ACPrestamosHerramientasAlmacenDetalle(ModelP); if (ModelP.Completado == true) { TempData["typemessage"] = "1"; TempData["message"] = "Los datos se guardaron correctamente."; Token.ResetToken(); return(RedirectToAction("Details", new { id = Model.IDPrestamo })); } else { if (ModelP.Resultado == -3) { Model.ListaProductos = CDatos.ObtenerComboProductosAlmacenXIDPrestamo(Conexion, Model.IDPrestamo); Model.ListaUnidades = CDatos.ObtenerComboUnidadesXIDProducto(Conexion, Model.IDProductoAlmacen); Model.Existencia = Datos.ObtenerExistenciaXIDProductoIDUnidadIDPrestamo(Conexion, Model.IDPrestamo, Model.IDProductoAlmacen, Model.IDUnidadProducto); TempData["typemessage"] = "2"; TempData["message"] = "El estatus del prestamos no permite guardar o modificar."; return(View(Model)); } else { Model.ListaProductos = CDatos.ObtenerComboProductosAlmacenXIDPrestamo(Conexion, Model.IDPrestamo); Model.ListaUnidades = CDatos.ObtenerComboUnidadesXIDProducto(Conexion, Model.IDProductoAlmacen); Model.Existencia = Datos.ObtenerExistenciaXIDProductoIDUnidadIDPrestamo(Conexion, Model.IDPrestamo, Model.IDProductoAlmacen, Model.IDUnidadProducto); TempData["typemessage"] = "2"; TempData["message"] = "Ocurrió un error al intentar guardar los datos. Intente más tarde."; return(View(Model)); } } } else { Model.ListaProductos = CDatos.ObtenerComboProductosAlmacenXIDPrestamo(Conexion, Model.IDPrestamo); Model.ListaUnidades = CDatos.ObtenerComboUnidadesXIDProducto(Conexion, Model.IDProductoAlmacen); Model.Existencia = Datos.ObtenerExistenciaXIDProductoIDUnidadIDPrestamo(Conexion, Model.IDPrestamo, Model.IDProductoAlmacen, Model.IDUnidadProducto); return(View(Model)); } } else { return(RedirectToAction("Details", new { id = Model.IDPrestamo })); } } catch { Model.ListaProductos = CDatos.ObtenerComboProductosAlmacenXIDPrestamo(Conexion, Model.IDPrestamo); Model.ListaUnidades = CDatos.ObtenerComboUnidadesXIDProducto(Conexion, Model.IDProductoAlmacen); Model.Existencia = Datos.ObtenerExistenciaXIDProductoIDUnidadIDPrestamo(Conexion, Model.IDPrestamo, Model.IDProductoAlmacen, Model.IDUnidadProducto); TempData["typemessage"] = "2"; TempData["message"] = "Ocurrió un error al intentar guardar los datos. Contacte a soporte técnico."; return(View(Model)); } }