Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ClienteId,Nombre,Apellido,Direccion,Emeil,Telefono")] Cliente cliente)
        {
            if (id != cliente.ClienteId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cliente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClienteExists(cliente.ClienteId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("IdUsuario,Nombre,Apellido,Telefono,IdProveedor")] Usuario usuario)
        {
            if (id != usuario.IdUsuario)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(usuario);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsuarioExists(usuario.IdUsuario))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdProveedor"] = new SelectList(_context.Proveedor, "IdProveedor", "IdProveedor", usuario.IdProveedor);
            return(View(usuario));
        }
        public async Task <IActionResult> Edit(int id, [Bind("idFactura,NumeroFactura,Fecha,TipodePago,DocumentoCliente,NombreCliente,SubTotal,Descuento,IVA,TotalDescuento,TotalImpuesto,Total")] Facturas facturas)
        {
            if (id != facturas.idFactura)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(facturas);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FacturasExists(facturas.idFactura))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(facturas));
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("FacturaId,Fecha,Precio,Cantidad,Subtotal,Iva,Total,ClienteId")] Factura factura)
        {
            if (id != factura.FacturaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(factura);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FacturaExists(factura.FacturaId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClienteId"] = new SelectList(_context.Cliente, "ClienteId", "ClienteId", factura.ClienteId);
            return(View(factura));
        }
Example #5
0
        public async Task <IActionResult> Edit(int id, [Bind("ProveedorId,Nombre,Apellido,Telefono")] Proveedor proveedor)
        {
            if (id != proveedor.ProveedorId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(proveedor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProveedorExists(proveedor.ProveedorId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(proveedor));
        }
Example #6
0
        public async Task <IActionResult> Edit(int id, [Bind("idDetalle,idFactura,idProducto,Cantidad,PrecioUnitario")] Detalles detalles)
        {
            if (id != detalles.idDetalle)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(detalles);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DetallesExists(detalles.idDetalle))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["idFactura"]  = new SelectList(_context.Facturas, "idFactura", "NombreCliente", detalles.idFactura);
            ViewData["idProducto"] = new SelectList(_context.Productos, "idProducto", "Producto", detalles.idProducto);
            return(View(detalles));
        }
Example #7
0
        public async Task <IActionResult> Edit(int id, [Bind("ProductoId,Nombreproducto,Descripcion,Precio,ProveedorId")] Producto producto)
        {
            if (id != producto.ProductoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(producto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductoExists(producto.ProductoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProveedorId"] = new SelectList(_context.Proveedor, "ProveedorId", "ProveedorId", producto.ProveedorId);
            return(View(producto));
        }
Example #8
0
        public async Task <IActionResult> Edit(int id, [Bind("DetalleFacturaId,Precio,Cantidad,Total,Iva,Fecha,IdFactura,Nombre,Apellido,ProductoId,FacturaId")] Detallefactura detallefactura)
        {
            if (id != detallefactura.DetalleFacturaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(detallefactura);
                    _context.SaveChanges();

                    int     FacturaId = (int)detallefactura.IdFactura;
                    var     factura   = _context.Factura.FirstOrDefault(f => f.FacturaId == FacturaId);
                    decimal subtotal  = 0;
                    foreach (var item in _context.Detallefactura.Where(d => d.FacturaId == FacturaId))
                    {
                        subtotal += item.Total;
                    }
                    factura.Subtotal = subtotal;
                    factura.Iva      = subtotal * (decimal)0.15;
                    factura.Total    = subtotal - factura.Iva;
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DetallefacturaExists(detallefactura.DetalleFacturaId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FacturaId"]  = new SelectList(_context.Factura, "FacturaId", "FacturaId", detallefactura.FacturaId);
            ViewData["ProductoId"] = new SelectList(_context.Producto, "ProductoId", "ProductoId", detallefactura.ProductoId);
            return(View(detallefactura));
        }