// 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));
        }
Beispiel #2
0
        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)
        {
            tbDevolucion tbDevolucion = db.tbDevolucion.Find(id);

            db.tbDevolucion.Remove(tbDevolucion);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "dev_Id,fact_Id,cja_Id,dev_Fecha,dev_UsuarioCrea,dev_FechaCrea,dev_UsuarioModifica,dev_FechaModifica")] tbDevolucion tbDevolucion)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbDevolucion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.fact_Id = new SelectList(db.tbFactura, "fact_Id", "fact_Codigo", tbDevolucion.fact_Id);
     return(View(tbDevolucion));
 }
Beispiel #5
0
 public ActionResult EmitirNotaCredito(tbDevolucion Devolucion)
 {
     Session["IDDEVOLUCION"]   = Session["ID"];
     Session["FECHADEV"]       = Session["FECHA"];
     Session["CODIGOCAJA"]     = Session["IDCAJA"];
     Session["CAJAA"]          = Session["CAJA"];
     Session["CODIGOSUCURSAL"] = Session["IDSUCURSAL"];
     Session["SUC"]            = Session["SUCURSAL"];
     Session["IDCTL"]          = Session["IDCLIENTE"];
     Session["RTN"]            = Session["RTNCLIENTE"];
     Session["NOMBRECLIENTE"]  = Session["NOMBRE"];
     Session["MONTODEV"]       = Session["MONTO"];
     return(RedirectToAction("CreateNotaCredito", "Devolucion"));
 }
Beispiel #6
0
        public ActionResult _IndexDevolucion(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            tbDevolucion tbDevolucion = db.tbDevolucion.Find(id);

            if (tbDevolucion == null)
            {
                return(RedirectToAction("NotFound", "Login"));
            }
            return(View(tbDevolucion));
        }
        public ActionResult _IndexDevolucion(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbDevolucion tbDevolucion = db.tbDevolucion.Find(id);

            if (tbDevolucion == null)
            {
                return(HttpNotFound());
            }
            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);

            if (tbDevolucion == null)
            {
                return(HttpNotFound());
            }
            ViewBag.fact_Id = new SelectList(db.tbFactura, "fact_Id", "fact_Codigo", tbDevolucion.fact_Id);
            return(View(tbDevolucion));
        }
 public ActionResult EmitirNotaCredito(tbDevolucion Devolucion)
 {
     try
     {
         Session["IDDEVOLUCION"]  = Session["ID"];
         Session["FECHADEV"]      = Session["FECHA"];
         Session["RTN"]           = Session["RTNCLIENTE"];
         Session["NOMBRECLIENTE"] = Session["NOMBRE"];
         Session["MONTODEV"]      = Session["MONTO"];
         return(RedirectToAction("CreateNotaCredito", "Devolucion"));
     }
     catch (Exception Ex) {
         ModelState.AddModelError("", "Error al Acceder" + Ex.Message.ToString());
         return(RedirectToAction("CreateNotaCredito", "Devolucion"));
     }
 }
        public ActionResult Edit([Bind(Include = "dev_Id,fact_Id,dev_Razon,dev_Fecha,dev_UsuarioCrea,dev_FechaCrea,dev_UsuarioModifica,dev_FechaModifica")] tbDevolucion tbDevolucion)
        {
            //    tbDevolucion.dev_UsuarioCrea = 3;
            //    tbDevolucion.dev_FechaCrea = DateTime.Now;
            tbDevolucion.dev_UsuarioModifica = 3;
            tbDevolucion.dev_FechaModifica   = DateTime.Now;
            IEnumerable <object> listDevolucion = null;
            string MensajeError = "";

            if (ModelState.IsValid)
            {
                try
                {
                    listDevolucion = db.UDP_Vent_tbDevolucion_Update(tbDevolucion.dev_Id,
                                                                     tbDevolucion.fact_Id,
                                                                     tbDevolucion.dev_Razon,
                                                                     tbDevolucion.dev_Fecha,
                                                                     tbDevolucion.dev_UsuarioCrea,
                                                                     tbDevolucion.dev_FechaCrea,
                                                                     tbDevolucion.dev_UsuarioModifica,
                                                                     tbDevolucion.dev_FechaModifica);

                    foreach (UDP_Vent_tbDevolucion_Update_Result Resultado in listDevolucion)
                    {
                        MensajeError = Resultado.MensajeError;
                    }



                    if (MensajeError.StartsWith("-1"))
                    {
                        ModelState.AddModelError("", "No se pudo ingresar el registro, contacte al administrador");
                        return(View(tbDevolucion));
                    }
                }
                catch (Exception ex)
                {
                    ex.Message.ToString();
                }
                return(RedirectToAction("Index"));
            }
            ViewBag.dev_UsuarioCrea     = new SelectList(db.tbUsuarios, "usu_Id", "usu_NombreUsuario", tbDevolucion.dev_UsuarioCrea);
            ViewBag.dev_UsuarioModifica = new SelectList(db.tbUsuarios, "usu_Id", "usu_NombreUsuario", tbDevolucion.dev_UsuarioModifica);
            ViewBag.fact_Id             = new SelectList(db.tbFactura, "fact_Id", "fact_Id", tbDevolucion.fact_Id);
            return(View(tbDevolucion));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbDevolucion tbDevolucion = db.tbDevolucion.Find(id);

            if (tbDevolucion == null)
            {
                return(HttpNotFound());
            }
            ViewBag.dev_UsuarioCrea     = new SelectList(db.tbUsuarios, "usu_Id", "usu_NombreUsuario", tbDevolucion.dev_UsuarioCrea);
            ViewBag.dev_UsuarioModifica = new SelectList(db.tbUsuarios, "usu_Id", "usu_NombreUsuario", tbDevolucion.dev_UsuarioModifica);
            ViewBag.fact_Id             = new SelectList(db.tbFactura, "fact_Id", "fact_Id", tbDevolucion.fact_Id);
            return(View(tbDevolucion));
        }
        /// Post
        // GET: /Devolucion/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbDevolucion tbDevolucion = db.tbDevolucion.Find(id);

            if (tbDevolucion == null)
            {
                return(HttpNotFound());
            }


            Session["ID"]         = tbDevolucion.dev_Id;
            Session["FECHA"]      = tbDevolucion.dev_Fecha;
            Session["RTNCLIENTE"] = tbDevolucion.tbFactura.clte_Identificacion;
            Session["NOMBRE"]     = tbDevolucion.tbFactura.clte_Nombres;
            //Session["MONTO"] = tbDevolucionDetalle.devd_Monto;
            return(View(tbDevolucion));
        }
Beispiel #13
0
        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));
        }
Beispiel #14
0
        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));
        }
Beispiel #15
0
        public ActionResult CreateTest01([PexAssumeUnderTest] DevolucionController target, tbDevolucion tbDevolucion)
        {
            ActionResult result = target.Create(tbDevolucion);

            return(result);
            // TODO: agregar aserciones a método DevolucionControllerTest.CreateTest01(DevolucionController, 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)
        {
            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));
        }
Beispiel #17
0
        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));
        }
Beispiel #18
0
        public ActionResult EmitirNotaCreditoTest([PexAssumeUnderTest] DevolucionController target, tbDevolucion Devolucion)
        {
            ActionResult result = target.EmitirNotaCredito(Devolucion);

            return(result);
            // TODO: agregar aserciones a método DevolucionControllerTest.EmitirNotaCreditoTest(DevolucionController, tbDevolucion)
        }