public void RemoverIngresDetalle(Ingres ingres, IngresDetalle ingresDetalle) { if (ingres != null && ingresDetalle != null) { ingres.IngresDetalle.Remove(ingresDetalle); } }
public void AgregarIngresDetalle(Ingres ingres) { if (ingres != null) { var nuevoDetalle = new IngresDetalle(); ingres.IngresDetalle.Add(nuevoDetalle); } }
public Resultado GuardarIngres(Ingres ingres) { var resultado = Validar(ingres); if (resultado.Exitoso == false) { return(resultado); } CalcularExistenciaIngres(ingres); _contexto.SaveChanges(); resultado.Exitoso = true; return(resultado); }
public void CalcularExistenciaIngres(Ingres ingres) { foreach (var detalle in ingres.IngresDetalle) { var producto = _contexto.Productos.Find(detalle.ProductoId); if (producto != null) { if (ingres.Activo == true) { producto.Existencia = producto.Existencia + detalle.Cantidad; } else { producto.Existencia = producto.Existencia - detalle.Cantidad; } } } }
public void CalcularFactura(Ingres ingres) { if (ingres != null) { double subtotal = 0; foreach (var detalle in ingres.IngresDetalle) { var producto = _contexto.Productos.Find(detalle.ProductoId); if (producto != null) { detalle.Precio = producto.Precio; detalle.Total = detalle.Cantidad * producto.Precio; subtotal += detalle.Total; } } ingres.Total = subtotal; } }
private Resultado Validar(Ingres ingres) { var resultado = new Resultado(); resultado.Exitoso = true; if (ingres == null) { resultado.Mensaje = "Agregue una transaccion para poderla salvar"; resultado.Exitoso = false; return(resultado); } if (ingres.Id != 0 && ingres.Activo == true) { resultado.Mensaje = "La transaccion ya fue emitida y no se pueden realizar cambios en ella"; resultado.Exitoso = false; } if (ingres.Activo == false) { resultado.Mensaje = "La transaccion esta anulada no se pueden realizar cambios en ella"; resultado.Exitoso = false; } if (ingres.IngresDetalle.Count == 0) { resultado.Mensaje = "Agregue productos a la factura"; resultado.Exitoso = false; } foreach (var detalle in ingres.IngresDetalle) { if (detalle.ProductoId == 0) { resultado.Mensaje = "Seleccione productos validos"; resultado.Exitoso = false; } } return(resultado); }
public void AgregarIngres() { var nuevaIngres = new Ingres(); ListaIngress.Add(nuevaIngres);//REVISAR PORQ NO CONTEXTO }