示例#1
0
        public CsDemandeReclamation RetourneLaDemande(int fk_demande)
        {
            //cmd.CommandText = "SPX_GUI_RETOURNE_DEMANDE";
            CsDemandeReclamation _LaDemande = new CsDemandeReclamation();

            try
            {
                galadbEntities        transaction  = new galadbEntities();
                CsReclamationRcl      _Reclamation = new CsReclamationRcl();
                List <ADMUTILISATEUR> lstUser      = transaction.ADMUTILISATEUR.ToList();
                DEMANDE _DEMANDE = new DEMANDE();
                _LaDemande.LaDemande = Entities.ConvertObject <CsDemandeBase, DEMANDE>(transaction.DEMANDE.FirstOrDefault(p => p.PK_ID == fk_demande));

                try
                {
                    DataTable dt = Galatee.Entity.Model.ReclamationProcedure.RetourneListeReclamationbyDemande(fk_demande);
                    _Reclamation = Entities.GetEntityFromQuery <CsReclamationRcl>(dt);
                    if (!string.IsNullOrEmpty(_Reclamation.AgentEmetteur))
                    {
                        _Reclamation.NOMAGENTCREATION = lstUser.FirstOrDefault(t => t.MATRICULE == _Reclamation.AgentEmetteur) != null?
                                                        lstUser.FirstOrDefault(t => t.MATRICULE == _Reclamation.AgentEmetteur).LIBELLE : string.Empty;
                    }

                    if (!string.IsNullOrEmpty(_Reclamation.AgentRecepteur))
                    {
                        _Reclamation.NOMAGENTRECEPTEUR = lstUser.FirstOrDefault(t => t.MATRICULE == _Reclamation.AgentRecepteur) != null?
                                                         lstUser.FirstOrDefault(t => t.MATRICULE == _Reclamation.AgentRecepteur).LIBELLE : string.Empty;
                    }

                    if (!string.IsNullOrEmpty(_Reclamation.AgentValidation))
                    {
                        _Reclamation.NOMAGENTVALIDATEUR = lstUser.FirstOrDefault(t => t.MATRICULE == _Reclamation.AgentValidation) != null?
                                                          lstUser.FirstOrDefault(t => t.MATRICULE == _Reclamation.AgentValidation).LIBELLE : string.Empty;
                    }


                    _LaDemande.ReclamationRcl = _Reclamation;


                    DataTable dtDoc = DevisProcedures.DEVIS_DOCUMENTSCANNE_RETOURNEByIdDemande(_LaDemande.LaDemande.PK_ID);
                    _LaDemande.DonneDeDemande = Entities.GetEntityListFromQuery <ObjDOCUMENTSCANNE>(dtDoc);
                }
                catch (Exception)
                {
                    _LaDemande.ReclamationRcl = null;
                }
                transaction.Dispose();
                return(_LaDemande);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        public string ValiderInitReclamation(CsDemandeReclamation LaDemande)
        {
            try
            {
                string DemandeID         = string.Empty;
                bool   Resultat          = false;
                int    resultTransaction = -1;
                using (galadbEntities transaction = new galadbEntities())
                {
                    try
                    {
                        LaDemande.LaDemande.NUMDEM = AccueilProcedures.GetNumDevis(LaDemande.LaDemande);
                        LaDemande.ReclamationRcl.NumeroReclamation = LaDemande.LaDemande.NUMDEM;
                        LaDemande.ReclamationRcl.FK_IDDEMANDE      = LaDemande.LaDemande.PK_ID;
                        //LaDemande.LeClient.NUMDEM  = LaDemande.LaDemande.NUMDEM;

                        ReclamationProcedure.InsertionInitReclamation(LaDemande, transaction);
                        resultTransaction = transaction.SaveChanges();
                        if (resultTransaction != -1)
                        {
                            LaDemande.LaDemande.PK_ID = transaction.DEMANDE.FirstOrDefault(d => d.NUMDEM == LaDemande.LaDemande.NUMDEM && d.CENTRE == LaDemande.LaDemande.CENTRE).PK_ID;
                            if (LaDemande.LaDemande.PK_ID == 0)
                            {
                                using (galadbEntities tctx = new galadbEntities())
                                {
                                    DEMANDE laDem = tctx.DEMANDE.FirstOrDefault(t => t.NUMDEM == LaDemande.LaDemande.NUMDEM);
                                    if (laDem != null)
                                    {
                                        DemandeID = laDem.PK_ID + "." + LaDemande.LaDemande.NUMDEM;
                                    }
                                };
                            }
                            else
                            {
                                DemandeID = LaDemande.LaDemande.PK_ID + "." + LaDemande.LaDemande.NUMDEM;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                };
                return(DemandeID);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        //public static bool InsertControl(CsControleTravaux pControle)
        //{
        //    try
        //    {
        //        //pControle.FK_IDMATRICULE =GetAgentByMatricul(pControle.USERCREATION);
        //        return Entities.InsertEntity<Galatee.Entity.Model.CONTROLETRAVAUX>(Entities.ConvertObject<Galatee.Entity.Model.CONTROLETRAVAUX, CsControleTravaux>(pControle));
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}


        public static bool InsertControl(CsControleTravaux pControle)
        {
            try
            {
                //pControle.FK_IDMATRICULE =GetAgentByMatricul(pControle.USERCREATION);
                bool    DmdSaved  = false;
                DEMANDE laDemande = new DEMANDE();
                using (galadbEntities context = new galadbEntities())
                {
                    laDemande            = context.DEMANDE.FirstOrDefault(d => d.PK_ID == pControle.FK_IDDEMANDE);
                    laDemande.ISCONTROLE = true;
                }
                DmdSaved = Entities.UpdateEntity(laDemande);
                var CrtTravaux = Entities.ConvertObject <Galatee.Entity.Model.CONTROLETRAVAUX, CsControleTravaux>(pControle);
                CrtTravaux.NUMDEM       = laDemande.NUMDEM;
                CrtTravaux.FK_IDDEMANDE = laDemande.PK_ID;
                return(DmdSaved && Entities.InsertEntity <Galatee.Entity.Model.CONTROLETRAVAUX>(CrtTravaux));
            }
            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);
            }
        }