Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- PROCEDURE GérerSortieStock(IDCommande)
- sSQL est une chaîne = "SELECT * FROM LigneCommande WHERE IDCommande = " + ChaîneVersChaîneSQL(IDCommande)
- sdLigneCommande est une Source de Données
- SI HExécuteRequêteSQL(sdLigneCommande, hRequêteParDéfaut, sSQL) ALORS
- SI HLitPremier(sdLigneCommande) ALORS
- TANTQUE PasHendehors(sdLigneCommande)
- // Récupérer les infos de la ligne
- nIDProduit est un entier = sdLigneCommande.IDProduit
- nQtéCommandée est un entier = sdLigneCommande.Qté
- // Lire la fiche produit
- SI HLitRecherche(Produit, IDProduit, nIDProduit) ALORS
- SI Produit.Qté >= nQtéCommandée ALORS
- // Mise à jour de la quantité en stock
- Produit.Qté -= nQtéCommandée
- HModifie(Produit)
- // Enregistrement du mouvement de sortie
- MouvementStocks.IDProduit = nIDProduit
- MouvementStocks.QtéInitial = Produit.Qté + nQtéCommandée
- MouvementStocks.QtéReel = Produit.Qté
- MouvementStocks.DateMouvement = DateSys()
- MouvementStocks.Observation = "Sortie suite à commande n°" + IDCommande
- MouvementStocks.IDLigneEntrée = Null
- HAjoute(MouvementStocks)
- SINON
- Info("Stock insuffisant pour le produit " + Produit.Libellé)
- FIN
- SINON
- Info("Produit introuvable !")
- FIN
- // Passage au suivant
- SI PAS HLitSuivant(sdLigneCommande) ALORS
- SORTIR
- FIN
- FIN
- SINON
- Info("Aucune ligne de commande trouvée pour cette commande.")
- FIN
- SINON
- Info("Erreur lors de l'exécution de la requête.")
- FIN
Add Comment
Please, Sign In to add comment