//creer un Stock public bool creerStock(string codeMagasin, string codeArticle, Int16 stockDebut, Int16 quantiteAchetee, Int16 quantiteVendue, DateTime dateOperation, int annee, Int16 puArticle, Int16 stockRestant) { StockerBE stock = new StockerBE(codeMagasin, codeArticle, stockDebut, quantiteAchetee, quantiteVendue, dateOperation, annee, puArticle, stockRestant); if (stockerDA.ajouter(stock)) { journalDA.journaliser("enregistrement d'un approvisionnement de " + quantiteAchetee + " articles de type " + codeArticle + " dans le magasin " + codeMagasin + " au prix unitaire de " + puArticle); return(true); } return(false); }
internal void decrementerStock(SetarticleBE setarticle, int nombre, int annee) { if (setarticle != null) { StockerBE stocker = new StockerBE(); composers = composerDA.listerSuivantCritere("codesetarticle LIKE " + "'" + setarticle.codesetarticle + "'"); foreach (ComposerBE c in composers) { stocker = new StockerBE(); stocker.annee = annee; stocker.codeArticle = c.codeArticle; StockerBE dernier_stock = new StockerBE(); dernier_stock.codeArticle = c.codeArticle; dernier_stock = stockerDA.rechercherDernierEnregistrement(stocker); if (dernier_stock != null) { if (dernier_stock.annee < stocker.annee) { stocker.stockDebut = dernier_stock.stockRestant; } else { stocker.stockDebut = dernier_stock.stockDebut; } stocker.stockRestant = dernier_stock.stockRestant - (nombre * c.quantite); stocker.quantiteVendue = (nombre * c.quantite); stocker.quantiteAchetee = 0; stocker.puArticle = dernier_stock.puArticle; stocker.dateOperation = DateTime.Today; stocker.codeMagasin = dernier_stock.codeMagasin; stockerDA.ajouter(stocker); } } } }