public static void Update(CRPlanning newPl)
        {
            try
            {
                if (newPl == null)
                {
                    throw new Exception("The 'CRPlanning' entity does not contain any data!");
                }

                using (var context = new CompteResultatEntities())
                {
                    //CRPlanning oldPl = context.CRPlannings.Where(c => c.Id == newPl.Id).First();
                    var elements = context.CRPlannings.Where(c => c.Id == newPl.Id);

                    if (elements.Any())
                    {
                        CRPlanning oldPl = elements.First();

                        oldPl.DateArret         = newPl.DateArret;
                        oldPl.DatePlanification = newPl.DatePlanification;
                        oldPl.DateTraitement    = newPl.DateTraitement;
                        oldPl.DebutPeriode      = newPl.DebutPeriode;
                        oldPl.FinPeriode        = newPl.FinPeriode;

                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw ex;
            }
        }
        public static int Insert(CRPlanning crp)
        {
            try
            {
                using (var context = new CompteResultatEntities())
                {
                    context.CRPlannings.Add(crp);
                    context.SaveChanges();

                    return(crp.Id);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw ex;
            }
        }