public void addcumul(CumulEnt cment, List <Piece_cumulent> listcumul) { db.CumulEnt.Add(cment); foreach (Piece_cumulent cumul_piece in listcumul) { db.Piece_cumulent.Add(cumul_piece); } db.SaveChanges(); }
public void deletecumulbycode(int numerocumul) { CumulEnt cment = new CumulEnt(); cment = (CumulEnt)db.CumulEnt.Where(aa => aa.numerocumul == numerocumul).FirstOrDefault(); List <Piece_cumulent> pccms = new List <Piece_cumulent>(); pccms = db.Piece_cumulent.Where(aa => aa.Codecumul == numerocumul).ToList(); foreach (Piece_cumulent pc in pccms) { db.Piece_cumulent.Remove(pc); } db.CumulEnt.Remove(cment); db.SaveChanges(); }
public List <Cumul> getallcumulbyarticlebeforedate(string codeart, DateTime date1) { List <Piece_cumulent> entrees = db.Piece_cumulent.Where(aa => aa.Codearticle == codeart).ToList(); List <Piece_cumulsortie> sorties = db.Piece_cumulsortie.Where(aa => aa.Codearticle == codeart).ToList(); List <Piece_bonret> retours = db.Piece_bonret.Where(bb => bb.Codearticle == codeart).ToList(); List <Cumul> cums = new List <Cumul>(); foreach (Piece_cumulent pcent in entrees) { Cumul cm = new Cumul(); cm.date = (DateTime)pcent.date; cm.entree = pcent.quantite.ToString(); cm.nbe = pcent.Codecumul.ToString(); cm.nbs = ""; cm.nbl = ""; cm.nbr = ""; cm.nfact = ""; cm.sortie = ""; cm.retour = ""; CumulEnt cment = new CumulEnt(); cment = cmentser.getcumulbycode((Int32)pcent.Codecumul); cm.nomtier = cment.nomfr; cums.Add(cm); } foreach (Piece_cumulsortie pcent in sorties) { Cumul cm = new Cumul(); cm.date = (DateTime)pcent.date; cm.sortie = pcent.quantite.ToString(); cm.nbs = pcent.Codecumul.ToString(); cm.nbe = ""; cm.nbl = ""; cm.nbr = ""; cm.nfact = ""; cm.entree = ""; cm.retour = ""; Cumulsortie cmsort = new Cumulsortie(); cmsort = cmsortser.getcumulsortiebycode((Int32)pcent.Codecumul); cm.nomtier = cmsort.nomfr; cums.Add(cm); } foreach (Piece_bonret pcent in retours) { Cumul cm = new Cumul(); cm.date = (DateTime)pcent.date; cm.retour = pcent.quantite.ToString(); cm.nbr = pcent.Codecumul.ToString(); cm.nbe = ""; cm.nbl = ""; cm.nbs = ""; cm.nfact = ""; cm.entree = ""; cm.sortie = ""; BonRetour br = new BonRetour(); br = brser.getretourbycode((Int32)pcent.Codecumul); cm.nomtier = br.nomfr; cums.Add(cm); } return(cums.Where(aa => aa.date <= date1).OrderBy(aa => aa.date).ToList()); }