Beispiel #1
0
        public async Task <IActionResult> Create([Bind("EmpleadosID,Sueldo,Area,CantidadTrabajo,Nombre,Apellido,Edad,Direccion")] Empleados empleados)
        {
            if (ModelState.IsValid)
            {
                _context.Add(empleados);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(empleados));
        }
        public async Task <IActionResult> Create([Bind("ProductosID,Nombre,PaisOrigen,Marca,Precio")] Productos productos)
        {
            if (ModelState.IsValid)
            {
                _context.Add(productos);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(productos));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("CLientesID,Telefono,Empresa,Nombre,Apellido,Edad,Direccion")] Clientes clientes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clientes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(clientes));
        }
Beispiel #4
0
        public async Task <IActionResult> AgregarCliente([Bind("IDCliente,Nombre,Apellido,Sexo,Direccion,Email,FechaNacimiento,FechaRegistro")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                cliente.FechaRegistro = DateTime.Now;
                _context.Add(cliente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
Beispiel #5
0
        public async Task <IActionResult> AgregarProducto([Bind("IDProducto,Nombre,Descripcion,Unidad,Precio")] Producto producto)
        {
            if (ModelState.IsValid)
            {
                producto.FechaRegistro = DateTime.Now;
                _context.Add(producto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(producto));
        }
Beispiel #6
0
        public async Task <IActionResult> AgregarEmpleado([Bind("IDEmpleado,Nombre,Apellido,Sexo,Direccion,Email,FechaNacimiento,FechaIngreso,Cedula,Sueldo,Posicion")] Empleado empleado)
        {
            if (ModelState.IsValid)
            {
                empleado.FechaIngreso = DateTime.Now;
                _context.Add(empleado);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(empleado));
        }
        public async Task <IActionResult> Create([Bind("VentasID,EmpleadoID,ClientesID,ProductosID,DateTime")] Ventas ventas)
        {
            if (ModelState.IsValid)
            {
                ventas.DateTime = DateTime.Now;
                _context.Add(ventas);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClientesID"]  = new SelectList(_context.Clientes, "CLientesID", "Nombre", ventas.ClientesID);
            ViewData["EmpleadoID"]  = new SelectList(_context.Empleados, "EmpleadosID", "Nombre", ventas.EmpleadoID);
            ViewData["ProductosID"] = new SelectList(_context.Productos, "ProductosID", "PaisOrigen", ventas.ProductosID);
            return(View(ventas));
        }
Beispiel #8
0
        public async Task <IActionResult> AgregarVenta([Bind("IDVenta,IDProducto,IDCliente,FechaVenta")] VentaProductos ventaProductos)
        {
            if (ModelState.IsValid)
            {
                ventaProductos.FechaVenta = DateTime.Now;
                var prod = getProducto(ventaProductos.IDProducto);
                if (prod.Unidad == 0)
                {
                    ModelState.AddModelError("outOf", "Ya no quedan unidades disponibles de este producto.");
                }
                else
                {
                    prod.Unidad -= 1;
                    _context.Add(ventaProductos);
                    _context.Update(prod);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            ViewData["IDCliente"]  = new SelectList(_context.Clientes, "IDCliente", "Nombre", ventaProductos.IDCliente);
            ViewData["IDProducto"] = new SelectList(_context.Productos, "IDProducto", "Nombre", ventaProductos.IDProducto);
            return(View(ventaProductos));
        }