示例#1
0
        public void SetearDemandaPDiaria(Producto p, decimal valor)
        {
            string cmdText = "update Producto set demandapromediodiaria=" + valor.ToString("F3", new System.Globalization.CultureInfo("en-US")) + " where idproducto=" + p.IdProducto;

            Cn.ActualizarBD(cmdText);
        }
示例#2
0
        public static List <DetalleFactura> GetDetalleFactura(int idFactura)
        {
            Acceso ac = new Acceso();

            List <DetalleFactura> detalles = new List <DetalleFactura>();

            string     sql = "SELECT * from CONSULTAR_DETALLE_FACTURA where idFactura = @id";
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.AddWithValue("@id", idFactura);
            SqlConnection conexion = new SqlConnection(ac.getCadenaConexion());

            try
            {
                conexion.Open();

                cmd.Connection  = conexion;
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;

                SqlDataReader dr = cmd.ExecuteReader();

                DetalleFactura detalle;
                Producto       producto;
                Producto       productoPedido;
                UnidadMedida   unidad;
                UnidadMedida   unidadPedido;

                while (dr.Read())
                {
                    unidad       = new UnidadMedida();
                    unidadPedido = new UnidadMedida();

                    unidad.Nombre       = dr["unidadProducto"].ToString();
                    unidadPedido.Nombre = dr["unidadProdPedido"].ToString();

                    producto       = new Producto();
                    productoPedido = new Producto();

                    producto.Unidad     = unidad;
                    producto.Nombre     = dr["nombreProd"].ToString();
                    producto.idProducto = Convert.ToInt32(dr["idProducto"]);

                    productoPedido.Unidad     = unidadPedido;
                    productoPedido.Nombre     = dr["nombreProdPedido"].ToString();
                    productoPedido.idProducto = Convert.ToInt32(dr["idProductoPedido"]);


                    detalle = new DetalleFactura();

                    detalle.cantidad  = Convert.ToDouble(dr["cantidad"]);
                    detalle.producto  = producto;
                    detalle.detPedido = new DetallePedido()
                    {
                        producto = productoPedido
                    };
                    detalle.subTotal  = Convert.ToDouble(dr["subtotal"]);
                    detalle.iva       = Convert.ToDouble(dr["iva"]);
                    detalle.idDetalle = Convert.ToInt32(dr["idDetalleFactura"]);



                    detalles.Add(detalle);
                }
            }
            catch (InvalidOperationException ex)
            {
                throw new ApplicationException(ex.Message);
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("Error en BD: " + ex.Message);
            }
            finally
            {
                conexion.Close();
            }


            return(detalles);
        }
示例#3
0
        public void SetearZona(Producto p, int idzona)
        {
            string cmdText = "update Producto set zona_id=" + idzona + " where idproducto=" + p.IdProducto;

            Cn.ActualizarBD(cmdText);
        }
示例#4
0
        public void AptualizarPrecioProducto(Producto oNuevo)
        {
            string cmdText = "update Producto set precio=" + oNuevo.Precio.ToString("F3", new System.Globalization.CultureInfo("en-US")) + " where idproducto=" + oNuevo.IdProducto;

            Cn.ActualizarBD(cmdText);
        }
示例#5
0
 public void EliminarProducto(Producto UnProducto)
 {
     ListaProductos.Remove(UnProducto);
 }
示例#6
0
 public void Agregar_producto(Producto product)
 {
     ListaProductos.Add(product);
 }
        public static List <DetalleOrdenCompra> GetDetalleXOrdenDeCompra(int oc)
        {
            Acceso ac = new Acceso();

            List <DetalleOrdenCompra> detalles = new List <DetalleOrdenCompra>();

            string     sql = "SELECT * from CONSULTAR_DETALLE_ORDEN_COMPRA where idOrdenCompra = @oc";
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.AddWithValue("@oc", oc);
            SqlConnection conexion = new SqlConnection(ac.getCadenaConexion());

            try
            {
                conexion.Open();

                cmd.Connection  = conexion;
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;

                SqlDataReader dr = cmd.ExecuteReader();

                DetalleOrdenCompra d;
                Producto           p;
                UnidadMedida       u;
                OrdenDeCompra      o;

                while (dr.Read())
                {
                    o = new OrdenDeCompra();
                    o.idOrdenCompra = Convert.ToInt32(dr["idOrdenCompra"]);


                    u = new UnidadMedida();

                    u.IDUnidad = Convert.ToInt32(dr["idUnidadMedida"]);
                    u.Nombre   = dr["Unidad"].ToString();

                    p = new Producto();


                    p.Nombre          = dr["nombre"].ToString();
                    p.Unidad          = u;
                    p.idProducto      = Convert.ToInt16(dr["idProducto"]);
                    p.StockDisponible = Convert.ToDouble(dr["stockDisponible"]);
                    p.StockRiesgo     = Convert.ToDouble(dr["stockdeRiesgo"]);
                    p.StockActual     = Convert.ToDouble(dr["stockactual"]);
                    p.StockReservado  = Convert.ToDouble(dr["stockreservado"]);

                    d = new DetalleOrdenCompra();

                    d.cantidad = Convert.ToDouble(dr["cantidad"]);
                    d.producto = p;
                    d.precio   = Convert.ToDouble(dr["precio"]);
                    d.subTotal = Convert.ToDouble(dr["subTotal"]);
                    d.cantidadRealIngresada = Convert.ToDouble(dr["cantidadRealIngresada"]);
                    d.ordenCompra           = o;

                    detalles.Add(d);
                }
            }
            catch (InvalidOperationException ex)
            {
                throw new ApplicationException(ex.Message);
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("Error en BD: " + ex.Message);
            }
            finally
            {
                conexion.Close();
            }


            return(detalles);
        }