コード例 #1
0
 public static decimal RetourneMontantTotalDevis(string pNumDevis)
 {
     try
     {
         using (galadbEntities context = new galadbEntities())
         {
             decimal MontantTotalDevis = 0;
             DEMANDE devis             = context.DEMANDE.FirstOrDefault(t => t.NUMDEM == pNumDevis);
             //if (devis != null && !string.IsNullOrEmpty(devis.NUMDEM))
             //    MontantTotalDevis = devis.MONTANTTTC.Value ;
             return(MontantTotalDevis);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #2
0
        public static void InsertionInitReclamation(CsDemandeReclamation pDemandeRecl, galadbEntities pContext)
        {
            try
            {
                galadbEntities  contextinter = new galadbEntities();
                RCL_Reclamation _Reclamation = new RCL_Reclamation();

                List <DOCUMENTSCANNE> lstDocumentScan = new List <DOCUMENTSCANNE>();
                if (pDemandeRecl.DonneDeDemande != null && pDemandeRecl.DonneDeDemande.Count != 0)
                {
                    lstDocumentScan = Entities.ConvertObject <DOCUMENTSCANNE, ObjDOCUMENTSCANNE>(pDemandeRecl.DonneDeDemande);
                }


                if (pDemandeRecl.ReclamationRcl != null)
                {
                    _Reclamation = Entities.ConvertObject <RCL_Reclamation, CsReclamationRcl>(pDemandeRecl.ReclamationRcl);
                }

                DEMANDE _DEMANDE = new DEMANDE();
                if (pDemandeRecl.LaDemande != null)
                {
                    _DEMANDE = Entities.ConvertObject <DEMANDE, CsDemandeBase>(pDemandeRecl.LaDemande);
                }

                foreach (DOCUMENTSCANNE item in lstDocumentScan)
                {
                    if (pContext.DOCUMENTSCANNE.FirstOrDefault(d => d.PK_ID == item.PK_ID) == null)
                    {
                        item.PK_ID = Guid.NewGuid();
                        _DEMANDE.DOCUMENTSCANNE.Add(item);
                    }
                }

                //DCLIENT _Dclient= new DCLIENT();
                //if (pDemandeRecl.LeClient  != null)
                //    _Dclient = Entities.ConvertObject<DCLIENT, CsClient>(pDemandeRecl.LeClient);

                //_DEMANDE.DCLIENT.Add(_Dclient);

                if (_DEMANDE.PK_ID == 0)
                {
                    _DEMANDE.RCL_Reclamation.Add(_Reclamation);
                    Entities.InsertEntity <DEMANDE>(_DEMANDE, pContext);
                }
                else
                {
                    Entities.UpdateEntity <DEMANDE>(_DEMANDE, pContext);
                    Entities.UpdateEntity <RCL_Reclamation>(_Reclamation, pContext);
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                // Retrieve the error messages as a list of strings.
                //var errorMessages = ex.EntityValidationErrors
                //        .SelectMany(x => x.ValidationErrors)
                //        .Select(x => x.ErrorMessage);

                //// Join the list to a single string.
                //var fullErrorMessage = string.Join("; ", errorMessages);

                //// Combine the original exception message with the new one.
                //var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);

                ////return exceptionMessage;
                //// Throw a new DbEntityValidationException with the improved exception message.
                //throw new System.Data.Entity.Validation.DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
                throw ex;
            }
        }