Пример #1
0
        public ActionResult Create()
        {
            try { ViewBag.smserror = TempData["smserror"].ToString(); } catch { }
            string           UserName = "";
            int              idUser   = 0;
            List <tbUsuario> User     = Function.getUserInformation();
            tbBodega         tbBod    = new tbBodega();

            foreach (tbUsuario Usuario in User)
            {
                UserName = Usuario.usu_Nombres + " " + Usuario.usu_Apellidos;
                idUser   = Convert.ToInt32(Usuario.emp_Id);
            }

            ViewBag.bod_Id              = new SelectList(db.tbBodega.Where(x => x.bod_ResponsableBodega == idUser).ToList(), "bod_Id", "bod_Nombre");
            ViewBag.tdev_Id             = new SelectList(db.tbTipoDevolucion, "tdev_Id", "tdev_Descripcion");
            ViewBag.estm_Id             = new SelectList(db.tbEstadoMovimiento, "estm_Id", "estm_Descripcion");
            ViewBag.prov_Id             = new SelectList(db.tbProveedor, "prov_Id", "prov_Nombre");
            ViewBag.tent_Id             = new SelectList(db.tbTipoEntrada, "tent_Id", "tent_Descripcion");
            ViewBag.ent_RazonDevolucion = new SelectList(db.tbTipoDevolucion, "tdev_Id", "tdev_Descripcion");

            //vista parcial de entrada detalle
            ViewBag.ent_Id                  = new SelectList(db.tbEntrada, "ent_Id", "ent_Id");
            ViewBag.prod_Codigo             = new SelectList(db.tbProducto, "prod_Codigo", "prod_Descripcion");
            ViewBag.uni_Id                  = new SelectList(db.tbUnidadMedida, "uni_Id", "uni_Descripcion");
            ViewBag.bod_Idd                 = new SelectList(db.tbBodega, "bod_Id", "bod_Nombre");
            ViewBag.Producto                = db.SDP_Inv_tbProducto_Select().ToList();
            ViewBag.BoxD                    = db.tbBox.Where(s => db.tbSalidaDetalle.Where(es => es.box_Codigo == s.box_Codigo && db.tbSalida.Where(sd => sd.sal_Id == es.sal_Id && sd.estm_Id == Helpers.sal_Aplicada).Any()).Any()).ToList();
            Session["_CrearDetalleEntrada"] = null;
            return(View());
        }
Пример #2
0
        //para que cambie estado a inactivar
        //[SessionManager("Bodega/ActivarEstado")]
        public ActionResult Estadoactivar(int?id)
        {
            try
            {
                tbBodega             obj  = db.tbBodega.Find(id);
                IEnumerable <object> list = null;
                var MsjError = "";
                list = db.UDP_Inv_tbBodega_Update_Estado_Validacion(id, EstadoBodega.Activo, Function.GetUser(), Function.DatetimeNow());
                foreach (UDP_Inv_tbBodega_Update_Estado_Validacion_Result obje in list)
                {
                    MsjError = obje.MensajeError;
                }

                if (MsjError == "-1")
                {
                    ModelState.AddModelError("", "No se Actualizo el registro");
                    return(RedirectToAction("Edit/" + id));
                }
                else
                {
                    return(RedirectToAction("Edit/" + id));
                }
            }
            catch (Exception Ex)
            {
                Ex.Message.ToString();
                ModelState.AddModelError("", "No se Actualizo el registro");
                return(RedirectToAction("Edit/" + id));
            }
        }
Пример #3
0
        public ActionResult Edit(int?id)
        {
            try
            {
                ViewBag.smserror = TempData["smserror"].ToString();
            }
            catch { }
            try
            {
                ViewBag.smserror_Estado = TempData["smserror_Estado"].ToString();
            }
            catch { }
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            tbBodega tbBodega = db.tbBodega.Find(id);

            ViewBag.IdBodegaDetalleEdit = id;
            if (tbBodega == null)
            {
                return(RedirectToAction("NotFound", "Login"));
            }
            this.AllLists();
            ResponsableBodega(tbBodega.bod_ResponsableBodega);
            ViewBag.dep_Codigo         = new SelectList(db.tbDepartamento, "dep_Codigo", "dep_Nombre", tbBodega.dep_Codigo);
            ViewBag.mun_Codigo         = new SelectList(db.tbMunicipio, "mun_Codigo", "mun_Nombre", tbBodega.mun_Codigo);
            Session["tbBodegaDetalle"] = null;
            return(View(tbBodega));
        }
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            tbBox tbBox = db.tbBox.Find(id);

            if (tbBox == null)
            {
                return(RedirectToAction("NotFound", "Login"));
            }
            string           UserName = "";
            int              idUser   = 0;
            List <tbUsuario> User     = Function.getUserInformation();
            tbBodega         tbBod    = new tbBodega();

            foreach (tbUsuario Usuario in User)
            {
                UserName = Usuario.usu_Nombres + " " + Usuario.usu_Apellidos;
                idUser   = Convert.ToInt32(Usuario.emp_Id);
            }
            Session["BoxDetalle"] = null;

            ViewBag.Cod_Box  = id;
            ViewBag.bod_Id   = new SelectList(db.tbBodega.Where(x => x.bod_ResponsableBodega == idUser).ToList(), "bod_Id", "bod_Nombre");
            ViewBag.bod_Prod = db.tbBodega.Where(x => x.bod_ResponsableBodega == idUser).Select(x => x.bod_Id).First();
            ViewBag.Producto = db.tbBodegaDetalle.ToList();
            return(View(tbBox));
        }
Пример #5
0
        //para Mostrar la cantidad en Existencia de la bodega


        //para que cambie estado a activar
        //[SessionManager("Bodega/InactivarEstado")]
        public ActionResult EstadoInactivar(int?id)
        {
            try
            {
                tbBodega             obj  = db.tbBodega.Find(id);
                IEnumerable <object> list = null;
                string MsjError           = "";
                list = db.UDP_Inv_tbBodega_Update_Estado_Validacion(id, EstadoBodega.Inactivo, Function.GetUser(), Function.DatetimeNow());
                foreach (UDP_Inv_tbBodega_Update_Estado_Validacion_Result obje in list)
                {
                    MsjError = obje.MensajeError;
                }

                if (MsjError.StartsWith("-5"))
                {
                    TempData["smserror_Estado"] = "No se puede Inactivar Bodegas Con Detalles";
                    ViewBag.smserror_Estado     = TempData["smserror_Estado"];
                    Function.InsertBitacoraErrores("Bodega/EstadoInactivar", MsjError, "EstadoInactivar");
                    ModelState.AddModelError("", "No se pudo actualizar el registro, favor contacte al administrador.");
                    return(RedirectToAction("Edit/" + id));
                }
                else if (MsjError.StartsWith("-2"))
                {
                    TempData["smserror_Estado"] = "No se puede inactivar la Bodega; El Detalle esta siendo utilizado";
                    ViewBag.smserror_Estado     = TempData["smserror_Estado"];
                    Function.InsertBitacoraErrores("Bodega/EstadoInactivar", MsjError, "EstadoInactivar");
                    ModelState.AddModelError("", "No se pudo actualizar el registro, favor contacte al administrador.");
                    return(RedirectToAction("Edit/" + id));
                }
                else if (MsjError.StartsWith("-4"))
                {
                    TempData["smserror_Estado"] = "No se puede inactivar la Bodega; El Detalle esta siendo utilizado";
                    ViewBag.smserror_Estado     = TempData["smserror_Estado"];
                    Function.InsertBitacoraErrores("Bodega/EstadoInactivar", MsjError, "EstadoInactivar");
                    ModelState.AddModelError("", "No se pudo actualizar el registro, favor contacte al administrador.");
                    return(RedirectToAction("Edit/" + id));
                }
                else if (MsjError.StartsWith("-3"))
                {
                    TempData["smserror_Estado"] = "No se puede inactivar la Bodega; El Detalle esta siendo utilizado";
                    ViewBag.smserror_Estado     = TempData["smserror_Estado"];
                    Function.InsertBitacoraErrores("Bodega/EstadoInactivar", MsjError, "EstadoInactivar");
                    ModelState.AddModelError("", "No se pudo actualizar el registro, favor contacte al administrador.");
                    return(RedirectToAction("Edit/" + id));
                }
                else
                {
                    ViewBag.smserror_Estado = "";
                    return(RedirectToAction("Edit/" + id));
                }
            }
            catch (Exception Ex)
            {
                Function.InsertBitacoraErrores("Bodega/EstadoInactivar", Ex.Message.ToString(), "EstadoInactivar");
                ModelState.AddModelError("", "No se pudo actualizar el registro, favor contacte al administrador.");
                return(RedirectToAction("Edit/" + id));
            }
        }
Пример #6
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            tbBodega tbBodega = db.tbBodega.Find(id);

            if (tbBodega == null)
            {
                return(RedirectToAction("NotFound", "Login"));
            }

            this.AllLists();
            return(View(tbBodega));
        }
Пример #7
0
        public ActionResult Create([Bind(Include = "bod_Id,bod_Nombre,bod_ResponsableBodega,bod_Direccion,bod_Correo,bod_Telefono,usu_Id,mun_Codigo,bod_EsActiva,dep_Codigo")] tbBodega tbBodega)
        {
            IEnumerable <object> BODEGA  = null;
            IEnumerable <object> DETALLE = null;
            string MsjError     = "";
            string MensajeError = "";
            var    listaDetalle = (List <tbBodegaDetalle>)Session["tbBodegaDetalle"];

            if (ModelState.IsValid)
            {
                using (TransactionScope _Tran = new TransactionScope())
                {
                    try
                    {
                        BODEGA = db.UDP_Inv_tbBodega_Insert(tbBodega.bod_Nombre,
                                                            tbBodega.bod_ResponsableBodega
                                                            , tbBodega.bod_Direccion
                                                            , tbBodega.bod_Correo
                                                            , tbBodega.bod_Telefono
                                                            , tbBodega.mun_Codigo
                                                            , Function.GetUser()
                                                            , Function.DatetimeNow());
                        foreach (UDP_Inv_tbBodega_Insert_Result bodega in BODEGA)
                        {
                            MsjError = bodega.MensajeError;
                        }
                        if (MsjError.StartsWith("-1"))
                        {
                            this.AllLists();
                            Function.InsertBitacoraErrores("Bodega/Create", MsjError, "Create");
                            ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                            return(View(tbBodega));
                        }
                        else
                        {
                            if (listaDetalle != null)
                            {
                                if (listaDetalle.Count > 0)
                                {
                                    foreach (tbBodegaDetalle bodd in listaDetalle)
                                    {
                                        DETALLE = db.UDP_Inv_tbBodegaDetalle_Insert(bodd.prod_Codigo
                                                                                    , Convert.ToInt16(MsjError)
                                                                                    , bodd.bodd_CantidadMinima
                                                                                    , bodd.bodd_CantidadMaxima
                                                                                    , bodd.bodd_PuntoReorden
                                                                                    , bodd.bodd_Costo
                                                                                    , bodd.bodd_CostoPromedio
                                                                                    , Function.GetUser()
                                                                                    , Function.DatetimeNow());
                                        foreach (UDP_Inv_tbBodegaDetalle_Insert_Result B_detalle in DETALLE)
                                        {
                                            MensajeError = B_detalle.MensajeError;
                                        }
                                        if (MensajeError.StartsWith("-1"))
                                        {
                                            this.AllLists();
                                            Function.InsertBitacoraErrores("Bodega/Create", MsjError, "Create");
                                            ModelState.AddModelError("", "No se pudo insertar el registro detalle, favor contacte al administrador.");
                                            return(View(tbBodega));
                                        }
                                    }
                                }
                            }
                            _Tran.Complete();
                        }
                    }
                    catch (Exception Ex)
                    {
                        this.AllLists();
                        Function.InsertBitacoraErrores("Bodega/Create", Ex.Message.ToString(), "Create");
                        ModelState.AddModelError("", "No se pudo insertar el registro, favor contacte al administrador.");
                        return(View(tbBodega));
                    }
                }
                return(RedirectToAction("Index"));
            }
            this.AllLists();
            return(View(tbBodega));
        }
Пример #8
0
        public ActionResult Edit(int?id, [Bind(Include = "bod_Id,bod_Nombre,bod_ResponsableBodega,bod_Direccion,bod_Correo,bod_Telefono,usu_Id,mun_Codigo,bod_EsActiva,bod_UsuarioCrea,bod_FechaCrea,bod_UsuarioModifica,bod_FechaModifica,dep_Codigo")] tbBodega tbBodega)
        {
            IEnumerable <object> BODEGA  = null;
            IEnumerable <object> DETALLE = null;
            string MsjError     = "";
            string MensajeError = "";
            var    listaDetalle = (List <tbBodegaDetalle>)Session["tbBodegaDetalle"];

            if (ModelState.IsValid)
            {
                using (TransactionScope _Tran = new TransactionScope())
                {
                    try
                    {
                        BODEGA = db.UDP_Inv_tbBodega_Update(tbBodega.bod_Id
                                                            , tbBodega.bod_Nombre
                                                            , tbBodega.bod_ResponsableBodega
                                                            , tbBodega.bod_Direccion
                                                            , tbBodega.bod_Correo
                                                            , tbBodega.bod_Telefono
                                                            , tbBodega.mun_Codigo
                                                            , tbBodega.bod_UsuarioCrea
                                                            , tbBodega.bod_FechaCrea,
                                                            Function.GetUser()
                                                            , Function.DatetimeNow());
                        foreach (UDP_Inv_tbBodega_Update_Result bodega in BODEGA)
                        {
                            MsjError = bodega.MensajeError;
                        }
                        if (MsjError.StartsWith("-1"))
                        {
                            this.AllLists();
                            ResponsableBodega((int)tbBodega.bod_ResponsableBodega);
                            Function.InsertBitacoraErrores("Bodega/Edit", MsjError, "Edit");
                            ModelState.AddModelError("", "No se pudo actualizar el registro, favor contacte al administrador.");
                            return(RedirectToAction("Edit/" + MsjError));
                        }
                        else
                        {
                            if (listaDetalle != null)
                            {
                                if (listaDetalle.Count > 0)
                                {
                                    foreach (tbBodegaDetalle bodd in listaDetalle)
                                    {
                                        DETALLE = db.UDP_Inv_tbBodegaDetalle_Insert(
                                            bodd.prod_Codigo
                                            , Convert.ToInt16(MsjError)
                                            , bodd.bodd_CantidadMinima
                                            , bodd.bodd_CantidadMaxima
                                            , bodd.bodd_PuntoReorden
                                            , bodd.bodd_Costo
                                            , bodd.bodd_CostoPromedio
                                            , Function.GetUser()
                                            , Function.DatetimeNow());
                                        foreach (UDP_Inv_tbBodegaDetalle_Insert_Result B_detalle in DETALLE)
                                        {
                                            MensajeError = B_detalle.MensajeError;
                                        }
                                        if (MensajeError.StartsWith("-1"))
                                        {
                                            this.AllLists();
                                            ResponsableBodega((int)tbBodega.bod_ResponsableBodega);
                                            ViewBag.deparatamento_Edit = new SelectList(db.tbDepartamento, "dep_Codigo", "dep_Nombre", tbBodega.dep_Codigo);
                                            ViewBag.municipio_Edit     = new SelectList(db.tbMunicipio, "mun_Codigo", "mun_Nombre", tbBodega.mun_Codigo);
                                            Function.InsertBitacoraErrores("Bodega/Edit", MsjError, "Edit");
                                            ModelState.AddModelError("", "No se pudo insertar el registro detalle, favor contacte al administrador.");
                                            return(RedirectToAction("Edit/" + MsjError));
                                        }
                                    }
                                }
                            }
                            _Tran.Complete();
                            return(RedirectToAction("Edit/" + MsjError));
                        }
                    }
                    catch (Exception Ex)
                    {
                        this.AllLists();
                        ResponsableBodega((int)tbBodega.bod_ResponsableBodega);
                        ViewBag.deparatamento_Edit = new SelectList(db.tbDepartamento, "dep_Codigo", "dep_Nombre", tbBodega.dep_Codigo);
                        ViewBag.municipio_Edit     = new SelectList(db.tbMunicipio, "mun_Codigo", "mun_Nombre", tbBodega.mun_Codigo);
                        Function.InsertBitacoraErrores("Bodega/Edit", Ex.Message.ToString(), "Edit");
                        ModelState.AddModelError("", "No se pudo actualizar el registro, favor contacte al administrador.");
                        return(RedirectToAction("Edit/" + MsjError));
                    }
                }
            }
            this.AllLists();
            ResponsableBodega((int)tbBodega.bod_ResponsableBodega);
            ViewBag.deparatamento_Edit  = new SelectList(db.tbDepartamento, "dep_Codigo", "dep_Nombre", tbBodega.dep_Codigo);
            ViewBag.municipio_Edit      = new SelectList(db.tbMunicipio, "mun_Codigo", "mun_Nombre", tbBodega.mun_Codigo);
            ViewBag.bod_UsuarioCrea     = new SelectList(db.tbUsuario, "usu_Id", "usu_NombreUsuario", tbBodega.bod_UsuarioCrea);
            ViewBag.bod_UsuarioModifica = new SelectList(db.tbUsuario, "usu_Id", "usu_NombreUsuario", tbBodega.bod_UsuarioModifica);
            return(View(tbBodega));
        }