Example #1
0
        public ActionResult Create(Genero genero)
        {
            ViewBag.MensajeInicio = "Ingrese datos del genero";

            try
            {
                Validar(genero);
                db.Genero.Add(genero);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                ViewBag.Message = e.Message;
            }
            return(View("Create"));
        }
 public ActionResult Create(Vendedor vendedor)
 {
     ViewBag.MensajeInicio = "Ingrese datos del vendedor";
     try
     {
         Validar(vendedor);
         db.Vendedor.Add(vendedor);
         db.SaveChanges();
         ViewBag.MensajeExito = "Vendedor [" + vendedor.Nombre + "] fue registrado en el sistema";
     }
     catch (Exception e)
     {
         ViewBag.Message = e.Message;
     }
     return(View("Create"));
 }
Example #3
0
        public ActionResult Create(Desarrollador desarrollador)
        {
            ViewBag.MensajeInicio = "Ingrese datos del desarrollador";

            try
            {
                Validar(desarrollador);
                db.Desarrollador.Add(desarrollador);
                db.SaveChanges();
                ViewBag.MensajeExito = "Desarrollador [" + desarrollador.NombreDesarrollador + "] fue registrado en el ristema";
            }
            catch (Exception e)
            {
                ViewBag.Message = e.Message;
            }
            return(View("Create"));
        }
 public ActionResult Create(Cliente cliente)
 {
     ViewBag.MensajeInicio = "Ingrese datos del dliente";
     try
     {
         Validar(cliente);
         db.Cliente.Add(cliente);
         db.SaveChanges();
         ViewBag.MensajeExito = "Cliente [" + cliente.Nombre + " " + cliente.Apellido + "] fue registrado en el sistema";
     }
     catch (Exception e)
     {
         ViewBag.Message = e.Message;
     }
     ModelState.Clear();
     return(View("Create"));
 }
Example #5
0
        public ActionResult GuardarFactura(string Fecha, string importe, string Total, string IdCliente, List <FacturaDetalle> detalles)
        {
            string   mensaje       = "";
            decimal  iva           = 16;
            int      codigoCliente = 0;
            decimal  imp           = 0;
            decimal  total         = 0;
            DateTime fecha         = new DateTime();

            if (string.IsNullOrEmpty(Fecha) || string.IsNullOrEmpty(importe) || string.IsNullOrEmpty(Total) || string.IsNullOrEmpty(IdCliente))
            {
                if (string.IsNullOrEmpty(Fecha))
                {
                    mensaje = "ERROR EN EL CAMPO FECHA";
                }
                if (string.IsNullOrEmpty(importe))
                {
                    mensaje = "ERROR EN EL IMPORTE";
                }
                if (string.IsNullOrEmpty(Total))
                {
                    mensaje = "ERROR EN EL CAMPO TOTAL";
                }
                if (string.IsNullOrEmpty(IdCliente))
                {
                    mensaje = "ERROR CON EL CODIGO DEL CLIENTE";
                }
            }
            else
            {
                fecha         = Convert.ToDateTime(Fecha);
                codigoCliente = Convert.ToInt32(IdCliente);
                total         = Convert.ToDecimal(Total);
                imp           = Convert.ToDecimal(importe);

                Factura factura = new Factura(fecha, imp, total, codigoCliente, iva);

                try
                {
                    db.Factura.Add(factura);
                    db.SaveChanges();
                    foreach (var data in detalles)
                    {
                        int            idJuego  = Convert.ToInt32(data.IdJuego.ToString());
                        byte           cantidad = Convert.ToByte(data.CantidadFacturada.ToString());
                        FacturaDetalle detalle  = new FacturaDetalle(getSecuencial(factura.IdFactura), factura.IdFactura, idJuego, cantidad);
                        db.FacturaDetalle.Add(detalle);
                    }
                    mensaje = "Factura guardada con éxito...";
                }
                catch (Exception e)
                {
                    mensaje = "Error al registrar la factura";
                }
            }

            return(Json(mensaje));
        }
        public ActionResult Create(Juego juego)
        {
            ViewBag.MensajeExito = "Ingrese datos del juego";
            GenerarListas();

            try
            {
                Validar(juego);
                db.Juego.Add(juego);
                db.SaveChanges();
                ViewBag.MensajeExito = "Juego [" + juego.IdJuego + "] fue registrado en el sistema con éxito";
            }
            catch (Exception e)
            {
                ViewBag.MensajeError = e.Message;
            }
            return(View("Create"));
        }