Exemplo n.º 1
0
 public static DetalleVenta DetalleVenta(int id)
 {
     ManejaDetalleVenta manejaDetalleVenta = new ManejaDetalleVenta();
     DetalleVenta res = new DetalleVenta();
     res = (DetalleVenta)manejaDetalleVenta.buscaPorId(id);
     return res;
 }
Exemplo n.º 2
0
 public iEntidad buscaPorId(int id)
 {
     DataRow i = manejador.ConsultarId("Select * from DetalleVentas WHERE `IdDetalleVenta`='" + id + "';");
     ManejaVenta manejaVenta = new ManejaVenta();
     ManejaProducto manejaProducto = new ManejaProducto();
     DetalleVenta auxEva = new DetalleVenta();
     auxEva.Id = Convert.ToInt32(i["IdDetalleVenta"]);
     auxEva.Venta = (Venta)manejaVenta.buscaPorId(Convert.ToInt32(i["IdVenta"].ToString()));
     auxEva.Producto = (Producto)manejaProducto.buscaPorId(Convert.ToInt32(i["IdProducto"].ToString()));
     auxEva.PrecioCosto = (float)i["PrecioCosto"];
     auxEva.CoefUrtil = (float)i["CoefUtil"];
     auxEva.Cantidad = Convert.ToInt32(i["Cantidad"]);
     return auxEva;
 }
Exemplo n.º 3
0
 public override int CompareTo(object obj)
 {
     if (obj is DetalleVenta)
     {
         DetalleVenta oVar = obj as DetalleVenta;
         return(String.Compare(this.ToString(), oVar.ToString(), true));
     }
     else if (obj is string)
     {
         return(String.Compare(this.ToString(), obj as string));
     }
     else
     {
         return(-1);
     }
 }
Exemplo n.º 4
0
 public List<iEntidad> Todo()
 {
     DataTable aux = manejador.Consultar("Select * from DetalleVentas;");
     ManejaVenta manejaVenta = new ManejaVenta();
     ManejaProducto manejaProducto = new ManejaProducto();
     List<iEntidad> res = new List<iEntidad>();
     foreach (DataRow i in aux.Rows)
     {
         DetalleVenta auxEva = new DetalleVenta();
         auxEva.Id = Convert.ToInt32(i["IdDetalleVenta"]);
         auxEva.Venta = (Venta)manejaVenta.buscaPorId(Convert.ToInt32(i["IdVenta"].ToString()));
         auxEva.Producto = (Producto)manejaProducto.buscaPorId(Convert.ToInt32(i["IdProducto"].ToString()));
         auxEva.PrecioCosto = (float)i["PrecioCosto"];
         auxEva.CoefUrtil = (float)i["CoefUtil"];
         auxEva.Cantidad = Convert.ToInt32(i["Cantidad"]);
         res.Add(auxEva);
     }
     return res;
 }
Exemplo n.º 5
0
        public bool Alta(iEntidad venta, List<Producto> listProductos,iEntidad factura,bool tipoA)
        {
            bool res = true;
            ManejaProducto manejaProducto = new ManejaProducto();

            conec.Ejecutar("start transaction");
            

            List<Producto> aux = new List<Producto>();
            bool stock = true;
            foreach(Producto pAux in listProductos)
            {
                if(manejaProducto.ModificacionStock(pAux)==0)
                {
                    stock = false;
                    break;
                }
            }
            if(!stock)
            {
                conec.Ejecutar("rollback;");
                return false;  
            }

            ManejaVenta manejaVenta = new ManejaVenta();
            ManejaDetalleVenta manejaDetalle = new ManejaDetalleVenta();
            manejaVenta.Alta(venta);
            DetalleVenta dv;
            foreach (Producto p in listProductos)
            {
                dv = new DetalleVenta();
                dv.Venta = (Venta)venta;
                dv.Producto = p;
                dv.PrecioCosto = p.PrecioCosto;
                dv.CoefUrtil = p.CoefUtil;
                dv.Cantidad = p.Stock;
                manejaDetalle.Alta(dv);
            }

            if (tipoA) 
            {
                ManejaFactura manejaFactura = new ManejaFactura();
                manejaFactura.Alta(factura);
            }
            else
            {
                ManejaFacturaB manejaFacturaB = new ManejaFacturaB();
                manejaFacturaB.Alta(factura);
            }

            conec.Ejecutar("commit;"); 
            return res;
        }
Exemplo n.º 6
0
        public static bool Venta(iEntidad venta,List<Producto> listProductos)
        {
            List<Producto> aux = Devuelve.Productos();

            foreach(Producto pAux in aux){
                foreach(Producto p in listProductos){
                    if (pAux.Id == p.Id)
                    {
                        if (pAux.Stock < p.Stock)
                        {
                            return false;
                        }
                    }
                }
            }

            ManejaVenta manejaVenta = new ManejaVenta();
            manejaVenta.Alta(venta);
            DetalleVenta dv;
            foreach (Producto p in listProductos)
            {
                dv = new DetalleVenta();
                dv.Venta = (Venta)venta;
                dv.Producto = p;
                dv.PrecioCosto = p.PrecioCosto;
                dv.CoefUrtil = p.CoefUtil;
                dv.Cantidad = p.Stock;
                Agrega.DetalleVenta(dv);
            }

            foreach (Producto pAux in aux)
            {
                foreach (Producto p in listProductos)
                {
                    if (pAux.Id == p.Id)
                    {
                        pAux.Stock -= p.Stock;
                        Actualiza.Producto(pAux);
                    }
                }
            }

            return true;
        }