TheDukeBastardo

code windev sortie produit

Jun 16th, 2025 (edited)
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. Voici un exemple vite écrit ) la volée à adapter et corriger selon ton besoin pour la sortie d'un produit suite à la commande d'un client par exemple
  2.  
  3. PROCEDURE GérerSortieStock(IDCommande)
  4.  
  5. sSQL est une chaîne = "SELECT * FROM LigneCommande WHERE IDCommande = " + ChaîneVersChaîneSQL(IDCommande)
  6. sdLigneCommande est une Source de Données
  7.  
  8. SI HExécuteRequêteSQL(sdLigneCommande, hRequêteParDéfaut, sSQL) ALORS
  9. SI HLitPremier(sdLigneCommande) ALORS
  10. TANTQUE PasHendehors(sdLigneCommande)
  11. // Récupérer les infos de la ligne
  12. nIDProduit est un entier = sdLigneCommande.IDProduit
  13. nQtéCommandée est un entier = sdLigneCommande.Qté
  14.  
  15. // Lire la fiche produit
  16. SI HLitRecherche(Produit, IDProduit, nIDProduit) ALORS
  17. SI Produit.Qté >= nQtéCommandée ALORS
  18. // Mise à jour de la quantité en stock
  19. Produit.Qté -= nQtéCommandée
  20. HModifie(Produit)
  21.  
  22. // Enregistrement du mouvement de sortie
  23. MouvementStocks.IDProduit = nIDProduit
  24. MouvementStocks.QtéInitial = Produit.Qté + nQtéCommandée
  25. MouvementStocks.QtéReel = Produit.Qté
  26. MouvementStocks.DateMouvement = DateSys()
  27. MouvementStocks.Observation = "Sortie suite à commande n°" + IDCommande
  28. MouvementStocks.IDLigneEntrée = Null
  29.  
  30. HAjoute(MouvementStocks)
  31. SINON
  32. Info("Stock insuffisant pour le produit " + Produit.Libellé)
  33. FIN
  34. SINON
  35. Info("Produit introuvable !")
  36. FIN
  37.  
  38. // Passage au suivant
  39. SI PAS HLitSuivant(sdLigneCommande) ALORS
  40. SORTIR
  41. FIN
  42. FIN
  43. SINON
  44. Info("Aucune ligne de commande trouvée pour cette commande.")
  45. FIN
  46. SINON
  47. Info("Erreur lors de l'exécution de la requête.")
  48. FIN
  49.  
Add Comment
Please, Sign In to add comment