private void listarProductosXCompra(Compra compra) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); ProductoNegocio negocioP = new ProductoNegocio(); DetalleCompra detalle; try { accesoDatos.setearConsulta("SELECT * FROM PRODUCTOS_X_COMPRA WHERE IDCOMPRA = " + compra.ID); accesoDatos.abrirConexion(); accesoDatos.ejecutarConsulta(); while (accesoDatos.Lector.Read()) { detalle = new DetalleCompra(); detalle.Producto = new Producto(); detalle.Producto = negocioP.listarProducto(accesoDatos.Lector.GetInt32(2)); detalle.Cantidad = accesoDatos.Lector.GetInt32(3); detalle.PrecioUnitario = Math.Round(detalle.Producto.PrecioUnitario, 3); detalle.PrecioParcial = Math.Round((detalle.Cantidad * detalle.PrecioUnitario), 3); compra.Detalle.Add(detalle); } } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
private void listarProductosXVenta(Venta venta) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); ProductoNegocio negocioP = new ProductoNegocio(); DetalleVenta detalle; try { accesoDatos.setearConsulta("SELECT * FROM PRODUCTOS_X_VENTA WHERE IDVENTA = " + venta.ID); accesoDatos.abrirConexion(); accesoDatos.ejecutarConsulta(); while (accesoDatos.Lector.Read()) { detalle = new DetalleVenta(); detalle.Producto = new Producto(); detalle.Producto = negocioP.listarProducto(accesoDatos.Lector.GetInt32(2)); if (!Convert.IsDBNull(accesoDatos.Lector["CANTIDAD"])) { detalle.Cantidad = accesoDatos.Lector.GetInt32(3); } if (!Convert.IsDBNull(accesoDatos.Lector["KILOS"])) { detalle.Kilos = accesoDatos.Lector.GetDecimal(4); } detalle.PrecioUnitario = Math.Round(detalle.Producto.PrecioUnitario, 3); detalle.PrecioParcial = Math.Round((detalle.Cantidad * detalle.PrecioUnitario) + (detalle.PrecioUnitario * detalle.Kilos), 3); venta.Detalle.Add(detalle); } } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
private void listarProductosXCombo(Combo cmb) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); ProductoNegocio negocioP = new ProductoNegocio(); try { accesoDatos.setearConsulta("SELECT PC.* FROM PRODUCTOS AS P INNER JOIN PRODUCTOS_X_COMBO AS PC ON PC.IDPRODUCTO = P.ID WHERE PC.IDCOMBO = " + cmb.ID); accesoDatos.abrirConexion(); accesoDatos.ejecutarConsulta(); DetalleCombo nuevo; while (accesoDatos.Lector.Read()) { nuevo = new DetalleCombo(); nuevo.Producto = new Producto(); nuevo.Producto = negocioP.listarProducto(accesoDatos.Lector.GetInt32(1)); if (!Convert.IsDBNull(accesoDatos.Lector["UNIDADES"])) { nuevo.Unidades = accesoDatos.Lector.GetInt32(2); } if (!Convert.IsDBNull(accesoDatos.Lector["KILOS"])) { nuevo.Kilos = accesoDatos.Lector.GetDecimal(3); } cmb.Productos.Add(nuevo); } } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }