public async Task <IActionResult> PutDetallefactura([FromRoute] int id, [FromBody] Detallefactura detallefactura) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != detallefactura.IdDetalleFactura) { return(BadRequest()); } _context.Entry(detallefactura).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DetallefacturaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Detallefactura> > PostTaskItem(Detallefactura item) { _context.Detallefacturas.Add(item); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetTaskItem), new { id = item.DETALLE_ID }, item)); }
public async Task <IActionResult> PostDetallefactura([FromBody] Detallefactura detallefactura) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Detallefactura.Add(detallefactura); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDetallefactura", new { id = detallefactura.IdDetalleFactura }, detallefactura)); }
public async Task <IActionResult> PutTaskItem(string id, Detallefactura item) { if (id != item.DETALLE_ID) { return(BadRequest()); } //var task = _context.TaskItems.FindAsync(id); _context.Entry(item).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
private void AddToListView() { ListViewItem item = null; var CollectioPrice = _precioproductohelper.Get(); var CollectionProducts = _productohelper.ConcatenarProductos(); _cantidad = int.Parse(CantidadTxt.Text); foreach (var C in CollectionProducts) { string search = C.Nombre + " - " + C.IdmarcaNavigation.Nombre; if (search.Equals(ProductosTxt.Text)) { item = ProductosLV.Items.Add(C.Idproducto.ToString()); item.SubItems.Add(C.Nombre); item.SubItems.Add(C.IdmarcaNavigation.Nombre); foreach (var I in CollectioPrice) { if (I.IdproductoNavigation.Nombre.Equals(C.Nombre)) { item.SubItems.Add(I.Precio.ToString()); item.SubItems.Add(_cantidad.ToString()); item.SubItems.Add(I.IdproductoNavigation.IdcategoriaNavigation.Nombre); item.SubItems.Add(subtotal(I.Precio, _cantidad).ToString()); _total += subtotal(I.Precio, _cantidad); UpdateQuantity(C.Nombre, 0); _detallefactura = new Detallefactura(); _detallefactura.Cantidad = _cantidad; _detallefactura.Idproducto = C.Idproducto; _detallefactura.Precioventa = I.Precio; UpdateList(0, _cantidad); break; } } break; } } BaseLab.Text = _total.ToString(); IvaLab.Text = (_total * 0.15).ToString(); NetoLab.Text = (_total + (_total * 0.15)).ToString(); _Iva = _total * 0.15; _neto = _total + (_total * 0.15); }
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)); }
public async Task <IActionResult> Create([Bind("DetalleFacturaId,Precio,Cantidad,Total,Iva,Fecha,IdFactura,Nombre,Apellido,ProductoId,FacturaId")] Detallefactura detallefactura) { if (ModelState.IsValid) { _context.Add(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(); return(RedirectToAction(nameof(Index))); } return(View(detallefactura)); }