Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "fact_Id,dev_Razon,dev_Fecha")] tbDevolucion tbDevolucion)
        {
            tbDevolucion.dev_Id          = 1;
            tbDevolucion.dev_Fecha       = DateTime.Now;
            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_Insert(tbDevolucion.fact_Id,
                                                                     tbDevolucion.dev_Razon,
                                                                     tbDevolucion.dev_Fecha,
                                                                     tbDevolucion.dev_UsuarioCrea,
                                                                     tbDevolucion.dev_FechaCrea);
                    foreach (UDP_Vent_tbDevolucion_Insert_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));
        }