public FormProducto(VentaDetalleVM item) { InitializeComponent(); this.item = item; var producto = Program.Productos.Single(p => p.IdProducto == item.IdProducto); this.item.Producto = $"{producto.Categoria.Nombre} {producto.Marca.Nombre} {producto.Nombre}"; }
private void BtnCancel_Click(object sender, System.EventArgs e) { Item = null; try { this.Close(); } catch { } }
private void BtnAceptar_Click(object sender, System.EventArgs e) { ActualizarItem(); Item = item; try { this.Close(); } catch { } }
public FormProducto(int idVenta, int idProducto) { InitializeComponent(); var producto = Program.Productos.Single(p => p.IdProducto == idProducto); item = new VentaDetalleVM { IdVentaDetalle = 0, IdVenta = idVenta, IdProducto = idProducto, Precio = producto.Precio, Producto = $"{producto.Categoria.Nombre} {producto.Marca.Nombre} {producto.Nombre}", Fecha = DateTime.Now, Cantidad = 1, }; }
public void ActualizarItem(VentaDetalleVM item) { using (var context = new ChoppinEntities()) { var itemActual = context.VentasDetalles .Single(i => i.IdVentaDetalle == item.IdVentaDetalle); itemActual.IdProducto = item.IdProducto; itemActual.Cantidad = item.Cantidad; itemActual.Precio = item.Precio; itemActual.Diferencia = item.Diferencia; itemActual.DiferenciaIdAplica = (int?)item.AplicaDiferencia; itemActual.DiferenciaMotivo = item.Motivo; itemActual.Fecha = DateTime.Now; context.SaveChanges(); } }
public void AgregarItem(VentaDetalleVM item) { using (var context = new ChoppinEntities()) { context.VentasDetalles.Add(new VentaDetalle { IdVenta = item.IdVenta, IdProducto = item.IdProducto, Cantidad = item.Cantidad, Precio = item.Precio, Diferencia = item.Diferencia, DiferenciaIdAplica = (int?)item.AplicaDiferencia, DiferenciaMotivo = item.Motivo, Fecha = DateTime.Now }); context.SaveChanges(); } }