예제 #1
0
        public ActionResult DeleteMovimientoInv(int id)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            if (getCurrentUser().IdRol == 4) { return RedirectToAction("MovimientoInvs", "Admin"); }

            MovimientoInvDTO dto;
            try
            {
                MovimientoInvBL objBL = new MovimientoInvBL();
                dto = objBL.getMovimientoInvEnEmpresa(getCurrentUser().IdEmpresa, id);
                if (objBL.delete(id))
                {
                    createResponseMessage(CONSTANTES.SUCCESS, CONSTANTES.SUCCESS_DELETE);
                }
                else
                {
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_DELETE);
                }
            }
            catch (Exception e)
            {
                createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_NO_DELETE);
                throw;
            }
            string cadena = "Ingreso";
            if (dto != null) { cadena = dto.IdTipoMovimientoInv == 1 ? "Ingreso" : "Egreso"; }
            return RedirectToAction("Inventarios" + cadena, "Admin");
        }
예제 #2
0
        public ActionResult MovimientoInv(int? id = null, int? idTipo = null)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            ViewBag.Title = "Movimiento de Inventario";

            int tipo = 1;
            if (idTipo != null) { tipo = idTipo.GetValueOrDefault(); }
            MenuNavBarSelected(9, tipo - 1);

            UsuarioDTO user = getCurrentUser();

            MovimientoInvBL objBL = new MovimientoInvBL();

            ViewBag.lstTipoMovimientoInv = objBL.getTipoMovimientoInv();
            ViewBag.lstFormaMovimiento = objBL.getFormaMovimientoInvPorTipo(tipo);
            //ViewBag.lstItems = objBL.getItemsEnEmpresa(user.IdEmpresa);
            ViewBag.lstItems = objBL.getItemsEnEmpresa_PorTipoMov(user.IdEmpresa, (int)idTipo);
            ViewBag.lstProveedores = objBL.getProveedoresEnEmpresa(user.IdEmpresa);
            //Lotes de salida Lista
            ViewBag.lstLotes = objBL.getLotesEnEmpresa(user.IdEmpresa);
            //Ubicaciones
            ViewBag.lstUbicaciones = objBL.getUbicacionesEnEmpresa(user.IdEmpresa);

            var objSent = TempData["MovimientoInv"];
            if (objSent != null) { TempData["MovimientoInv"] = null; return View(objSent); }

            MovimientoInvDTO obj;
            if (id != null && id != 0)
            {
                obj = objBL.getMovimientoInvEnEmpresa((int)user.IdEmpresa, (int)id);
                if (obj == null) return RedirectToAction("MovimientoInvs");
                if (obj.IdEmpresa != user.IdEmpresa) return RedirectToAction("MovimientoInvs");
                obj.UsuarioCreacion = user.IdUsuario;

                //lstLotes.Add(new Select2DTO_B() { text = obj.SerieLote });
                ViewBag.lstLotes = objBL.getLotesEnEmpresa(user.IdEmpresa, obj.IdItem, obj.SerieLote);
                
                if (idTipo.GetValueOrDefault() == 1) { ViewBag.lstUbicaciones = objBL.getUbicacionesEnEmpresa(user.IdEmpresa); }
                else if (idTipo.GetValueOrDefault() == 2) { ViewBag.lstUbicaciones = objBL.getUbicacionesEnEmpresa(user.IdEmpresa, obj.SerieLote); }

                return View(obj);
            }
            obj = new MovimientoInvDTO();
            obj.IdTipoMovimientoInv = tipo;
            obj.IdEmpresa = user.IdEmpresa;
            obj.UsuarioCreacion = user.IdUsuario;
            obj.FechaInicial = DateTime.Now;

            //if (idTipo.GetValueOrDefault() == 1) { ViewBag.lstUbicaciones = objBL.getUbicacionesEnEmpresa(user.IdEmpresa); }
            //else if (idTipo.GetValueOrDefault() == 2) { ViewBag.lstUbicaciones = new List<Select2DTO_B>(); }

            return View(obj);
        }