コード例 #1
0
 public ProductoBuscarViewModel(IWindowManager windowmanager, Ventas.VentaRegistrarViewModel ventaRegistrarViewModel, int ventanaAccion)
     : this(windowmanager)
 {
     this.ventaRegistrarViewModel = ventaRegistrarViewModel;
     this.ventanaAccion = ventanaAccion;
     AlmacenSQL almSQL = new AlmacenSQL();
     idAlmacen = almSQL.obtenerDeposito(ventaRegistrarViewModel.idTienda);
     SelectedTienda = ventaRegistrarViewModel.idTienda;
     Index = CmbTiendas.FindIndex(x => x.IdTienda == SelectedTienda);
 }
コード例 #2
0
        public List<AbastecimientoProducto> buscarProductosAbastecimiento(int idSolicitud, int idTienda = -1)
        {
            List<AbastecimientoProducto> lstAux = null;
            List<ProductoxTienda> prod;
            ProductoSQL pSQL = new ProductoSQL();
            AlmacenSQL almSQL = new AlmacenSQL();
            AbastecimientoProducto abTemp;
            int posProd, posNomProd, posCant, posAtent;
            int idAlmacen = idTienda;
            if (idTienda == 0)
                idAlmacen = almSQL.obtenerDeposito(idTienda);

            db.cmd.CommandText = "SELECT * FROM ProductoxSolicitudAb ps, Producto p WHERE ps.idProducto = p.idProducto AND ps.idSolicitudAB = @idSolicitudAB ";
            db.cmd.Parameters.Add(new SqlParameter("idSolicitudAB", idSolicitud));

            if (db.cmd.Transaction == null) db.conn.Open();
            SqlDataReader reader = db.cmd.ExecuteReader();

            while (reader.Read())
            {
                if (lstAux == null) lstAux = new List<AbastecimientoProducto>();
                abTemp = new AbastecimientoProducto();
                posProd = reader.GetOrdinal("idProducto");
                posNomProd = reader.GetOrdinal("nombre");
                posCant = reader.GetOrdinal("cantidad");
                posAtent = reader.GetOrdinal("cantidadAtendida");
                abTemp.idProducto = reader.IsDBNull(posProd) ? -1 : reader.GetInt32(posProd);
                abTemp.nombre = reader.IsDBNull(posNomProd) ? null : reader.GetString(posNomProd);
                abTemp.pedido = reader.IsDBNull(posCant) ? -1 : reader.GetInt32(posCant);
                abTemp.atendido = reader.IsDBNull(posAtent) ? -1 : reader.GetInt32(posAtent);
                abTemp.atendidoReal = reader.IsDBNull(posAtent) ? -1 : reader.GetInt32(posAtent);
                if (idTienda == 0)
                    prod = pSQL.BuscarProductoxCentral(idAlmacen, abTemp.idProducto);
                else
                    prod = pSQL.BuscarProductoxTienda(idAlmacen, abTemp.idProducto);
                abTemp.stock = prod == null? -1 : prod.ElementAt(0).StockActual;
                abTemp.stockPendiente = prod == null ? -1 : prod.ElementAt(0).StockPendiente;
                abTemp.sugerido = prod == null ? -1 : ((prod.ElementAt(0).StockMin - prod.ElementAt(0).StockActual) > 0 ? (prod.ElementAt(0).StockMin - prod.ElementAt(0).StockActual) : 0);
                lstAux.Add(abTemp);
            }

            db.cmd.Parameters.Clear();
            reader.Close();
            if (db.cmd.Transaction == null) db.conn.Close();

            return lstAux;
        }