public void SaveCurrencyOfFormation(string formationSAP, string routeName, int recurrency)
        {
            Education_Matrice_Formation MatriceFormation = db.Education_Matrice_Formation
                                                           .Where(p => p.Education_Matrice.Matrice_Description == routeName &&
                                                                  p.Education_Formation.Formation_SAP == formationSAP)
                                                           .FirstOrDefault();

            MatriceFormation.MatriceFormation_Recurrency = recurrency;

            db.SaveChanges();
        }
        public void RemoveFormationFromTrajet(string formationSAP, string routeName)
        {
            Education_Matrice Matrice = db.Education_Matrice
                                        .Where(x => x.Matrice_Description == routeName)
                                        .FirstOrDefault();

            Education_Matrice_Formation MatriceFormation = db.Education_Matrice_Formation
                                                           .Where(p => p.Education_Matrice.Matrice_Id == Matrice.Matrice_Id &&
                                                                  p.Education_Formation.Formation_SAP == formationSAP)
                                                           .FirstOrDefault();;

            db.Education_Matrice_Formation.Remove(MatriceFormation);
            db.SaveChanges();
        }
        public Education_Matrice_Formation SaveMatriceFormation(Education_Matrice_Formation matriceFormation, int recurrency)
        {
            Education_Matrice_Formation MatriceFormation = db.Education_Matrice_Formation
                                                           .Where(x => x.MatriceFormation_Matrice == matriceFormation.MatriceFormation_Matrice &&
                                                                  x.MatriceFormation_Formation == matriceFormation.MatriceFormation_Formation)
                                                           .FirstOrDefault();

            if (MatriceFormation != null)
            {
                MatriceFormation.MatriceFormation_Recurrency = recurrency;
                db.SaveChanges();
            }

            return(MatriceFormation);
        }
        public void RemoveAllMatriceForamtion(TreeNodeCollection nodes, string routeName)
        {
            Education_Matrice Matrice = db.Education_Matrice
                                        .Where(x => x.Matrice_Description == routeName)
                                        .FirstOrDefault();

            foreach (TreeNode singleRecord in nodes)
            {
                Education_Matrice_Formation MatriceFormation = db.Education_Matrice_Formation
                                                               .Where(p => p.Education_Matrice.Matrice_Id == Matrice.Matrice_Id &&
                                                                      p.Education_Formation.Formation_SAP == singleRecord.Name)
                                                               .FirstOrDefault();;


                db.Education_Matrice_Formation.Remove(MatriceFormation);
                db.SaveChanges();
            }

            db.Education_Matrice.Remove(Matrice);
            db.SaveChanges();
        }
        public List <Education_Formation> LoadAllEducation_FormationsInFrame(List <Education_Matrice_Formation> listMatriceFormationSelected)
        {
            try
            {
                List <Education_Formation> listefiltered = new List <Education_Formation>();
                var lisformation = db.Education_Formation.ToList();
                Education_Matrice_Formation itemroRemove = new Education_Matrice_Formation();
                foreach (var itemFormationFormDb in lisformation)
                {
                    itemroRemove = listMatriceFormationSelected.Where(r => r.Education_Formation.Formation_Id == itemFormationFormDb.Formation_Id)
                                   .FirstOrDefault();


                    if (itemroRemove == null)
                    {
                        listefiltered.Add(itemFormationFormDb);
                    }
                }
                return(listefiltered);
            }
            catch (Exception ex) { throw ex; }
        }