public string GetToString(Societe societe, DeclarationCnss declaration, Exercice exercice)
        {
            if (societe == null || declaration == null || exercice == null)
            {
                return(string.Empty);
            }
            string result = string.Empty;

            result += societe.NumeroEmployeur.PadLeft(8, '0');
            result += societe.CleEmployeur.PadLeft(2, '0');
            result += CodeExploitation.PadLeft(4, '0');
            result += declaration.Trimestre.ToString().PadLeft(1);
            result += exercice.Annee.PadLeft(4, '0');
            result += Page.ToString().PadLeft(3, '0');
            result += Ligne.ToString().PadLeft(2, '0');
            result += NumeroCnss.PadLeft(8, '0');
            result += CleCnss.PadLeft(2, '0');
            string identite = (Prenom.Trim() + " " + AutresNom.Trim() + " " + Nom.Trim() + " " + NomJeuneFille.Trim());

            result += Helper.StrTr(identite.PadRight(60)).ToUpper();
            result += Cin.PadLeft(8, '0');
            decimal total = Brut1 + Brut2 + Brut3;

            result += ((double)(total * 1000)).ToString("0").PadLeft(10, '0');
            result += string.Empty.PadLeft(10, '0');

            if (result.Length != 122)
            {
                throw new InvalidOperationException(
                          "Le nombre de caractère est invalide! Année [" + exercice + "] Trimestre " +
                          declaration.Trimestre);
            }

            return(result);
        }
Exemplo n.º 2
0
        public string Aprenom()
        {
            // string test = prenom.ToLower();
            // test.ElementAt(1).ToUpper;
            // return test;

            StringBuilder builder = new StringBuilder();

            if (Prenom != null)
            {
                string s = null;
                char[] modulatedsurname = Prenom.ToCharArray();
                for (int i = 0; i < modulatedsurname.Length; i++)
                {
                    if (i == 0) // Premier element maj
                    {
                        s = modulatedsurname[i].ToString();
                        s = s.ToUpper();
                        builder.Insert(i, s);
                    }
                    else //autres elem minuscule
                    {
                        s = modulatedsurname[i].ToString();
                        s = s.ToLower();
                        builder.Insert(i, s);
                    }
                }
            }
            // return (double)(DateTime.Today - _dateDeNaissance).Days / 365;
            return(builder.ToString());
        }
Exemplo n.º 3
0
        /* Fonction qui renvoie la liste des prénoms qui commencent
         * par chaîne de caractère donnée */
        public static Prenom[] prenomCommencePar(Prenom[] prenoms, string debutPrenom)
        {
            Prenom[] resultatTmp = new Prenom[prenoms.Length], resultat;
            int      nb          = -1;

            foreach (Prenom p in prenoms)
            {
                if (startsWith(debutPrenom, p.prenom))
                {
                    resultatTmp[++nb] = p;
                }
            }

            if (nb != -1)
            {
                resultat = new Prenom[nb + 1];

                for (int i = 0; i < nb + 1; ++i)
                {
                    resultat[i] = resultatTmp[i];
                }
            }
            else
            {
                resultat = null;
            }

            return(resultat);
        }
Exemplo n.º 4
0
 public void InversePrenom()
 {
     char[] tmp = Prenom.ToCharArray();
     Array.Reverse(tmp);
     Prenom = new string(tmp);
     Console.WriteLine($"Nouveau prénom : {Prenom}");
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            DataClasses1DataContext dc = new DataClasses1DataContext();
            String nomCherche          = null;
            var    Liste = from p in dc.Person
                           where p.FirstName == nomCherche
                           select new { p.FirstName, p.LastName };

            nomCherche = "Martin";
            foreach (var x in Liste)
            {
                Console.WriteLine(String.Format("{0} {1}", x.FirstName, x.LastName));
            }
            var nb = Liste.Count();

            Console.WriteLine(String.Format("Il y a {0} {1}", nb, nomCherche));
            var Decompte = from p in dc.Person
                           group p by p.FirstName into Prenom
                           where Prenom.Count() < 10
                           orderby Prenom.Count()
                           select Prenom;

            Console.WriteLine("------------ Prenoms avec moins de 10 occurences --------------");
            foreach (var g in Decompte)
            {
                Console.WriteLine(g.Key + " " + g.Count());
            }
        }
Exemplo n.º 6
0
 public void modifier(IClientEntrepriseMessage message)
 {
     Civilité = (Civilite)message.Civilité;
     Nom = new Nom(message.Nom);
     Prénom = new Prenom(message.Prénom);
     AdresseEmail = new AdresseEmail(message.AdresseEmail);
     Téléphone = new NumeroTelephone(message.Téléphone);
     Entreprise = Entreprise.charger(message.IdEntreprise);
 }
Exemplo n.º 7
0
 public void modifier(IClientParticulierMessage message)
 {
     Civilité = (Civilite)message.Civilité;
     Nom = new Nom(message.Nom);
     Prénom = new Prenom(message.Prénom);
     AdresseEmail = new AdresseEmail(message.AdresseEmail);
     Téléphone = new NumeroTelephone(message.Téléphone);
     AdressePostale.modifier(message.AdressePostale);
 }
Exemplo n.º 8
0
        // Le tri par défaut d'un conteneur d'objets dérivés de la classe Personne se fera sur le nom et le prénom

        public int CompareTo(Personne o)
        {
            int res = Nom.CompareTo(o.Nom);

            if (res == 0)
            {
                res = Prenom.CompareTo(o.Prenom);
            }
            return(res);
        }
 private void button4_Click(object sender, EventArgs e)
 {
     Nom.ResetText();
     Prenom.ResetText();
     Adresse.ResetText();
     Telephone.ResetText();
     Photo.ResetText();
     Ville.ResetText();
     Email.ResetText();
     Age.ResetText();
     Status.ResetText();
     Type.ResetText();
 }
        public int CompareTo(object obj)
        {
            IPersonne p            = (IPersonne)obj;
            int       resultNom    = Nom.CompareTo(p.Nom);
            int       resultPNom   = Postnom.CompareTo(p.Postnom);
            int       resultPreNom = Prenom.CompareTo(p.Prenom);
            int       goodResult   = -1;

            if (resultNom == 0 && resultPNom == 0 && resultPreNom == 0)
            {
                goodResult = 0;
            }

            return(goodResult);
        }
Exemplo n.º 11
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (!(obj is Personne))
            {
                return(false);
            }

            Personne p = (Personne)obj;

            return(Nom.Equals(p.Nom) && Prenom.Equals(p.Prenom));
        }
Exemplo n.º 12
0
        /* Réécriture du Contains(...), méthode disponible pour les tableaux,
         * mais adaptée à notre cas
         * On ne savait pas si on avait le droit de l'utiliser */
        public static bool containsPrenom(Prenom[] prenoms, Prenom prenom)
        {
            bool res = false;
            int  i   = 0;

            if (prenom.prenom != null)
            {
                while (i < prenoms.Length && !res)
                {
                    if (prenom.prenom.Equals(prenoms[i++].prenom))
                    {
                        res = true;
                    }
                }
            }
            return(res);
        }
Exemplo n.º 13
0
        /* Fonction permettant de gérer le TOP X de naissances sur une année donnée,
         * et qui retourne les résultats sous forme de tableau */
        public static Prenom[] topXNaissanceAnnee(Prenom[] prenoms, int top, bool top10, int anneeMin, int anneeMax)
        {
            int i = 0, indexResultat = 0, annee = -1; // Index pour parcourir les tableaux et année

            Prenom[] resultat = new Prenom[top];      // Tableau de Prenom contenant les résultats

            Console.Clear();                          // On vide la console

            if (top10)                                // On affiche le menu de la bonne fonctionnalité
            {
                top10Affichage();
                Console.WriteLine("Rentrez l'année du top 10 ({0} - {1}) : ", anneeMin, anneeMax);
            }
            else
            {
                nbNaissanceEtOrdreAnneeAffichage();
                Console.WriteLine("Rentrez l'année ({0} - {1}) : ", anneeMin, anneeMax);
            }

            do
            {
                annee = rentrerAnnee(anneeMin, anneeMax);             // On rentre l'année
            }while (annee == -1);

            /* On stocke dans resultat les prénoms de l'année choisie */
            while (i < prenoms.Length && indexResultat < resultat.Length)
            {
                if (prenoms[i].annee == annee)
                {
                    resultat[indexResultat] = prenoms[i];
                    ++indexResultat;
                }
                ++i;
            }

            if (top10)
            {
                afficherPrenomsTop10(resultat);
            }

            return(resultat);
        }
Exemplo n.º 14
0
        /* Méthode permettant de trier les prénoms selon le nombre de fois
         * qu'ils ont été donné */
        public static void trierPrenomsParNombre(Prenom[] prenoms)
        {
            bool ok = false;

            /* Tri utilisé : tri à bulles */
            while (!ok)
            {
                ok = true;
                for (int i = 1; i < prenoms.Length; ++i)
                {
                    if (prenoms[i - 1].nombre < prenoms[i].nombre)
                    {
                        Prenom p = prenoms[i];
                        prenoms[i]     = prenoms[i - 1];
                        prenoms[i - 1] = p;
                        ok             = false;
                    }
                }
            }
        }
Exemplo n.º 15
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(Nom.Text) == true)
            {
                MessageBox.Show("Nom vide");
            }
            else if (String.IsNullOrEmpty(Prenom.Text) == true)
            {
                MessageBox.Show("Prenom vide");
            }
            else if (String.IsNullOrEmpty(Numero.Text) == true)
            {
                MessageBox.Show("Numero vide");
            }
            else if (String.IsNullOrEmpty(Email.Text) == true)
            {
                MessageBox.Show("Email vide");
            }


            else
            {
                Client cli = new Client();
                cli._Nom    = Nom.Text.ToString();
                cli._Prenom = Prenom.Text.ToString();
                cli._Numero = Int32.Parse(Numero.Text);
                cli._Email  = Email.Text.ToString();
                cli.insertclient(cli);
                MessageBox.Show("Client ajoute Client: " + Nom.Text + " Prenom " + Prenom.Text);



                //DataTable dt = new DataTable();
                //dt = cli.RecupAllClient();
                dataGridView1.DataSource = cli.RecupAllClient();
                Prenom.Clear();
                Nom.Clear();
                Numero.Clear();
                Email.Clear();
            }
        }
Exemplo n.º 16
0
        /* Fonction permettant de récupérer les prénoms d'une période (triés par nombre) */
        public static Prenom[] recupererEtTrierPrenomsPeriode(Prenom[] prenoms, int anneeD, int anneeF)
        {
            Prenom[] prenomsPeriodeTmp, resultat;
            int      cpt = 0;

            prenomsPeriodeTmp = new Prenom[(anneeF - anneeD + 1) * 100];

            /* Pour chaque Prenom du tableau, s'il n'existe pas dans le tableau
             * prenomsPeriodeTmp, on le rajoute. Sinon, on ajoute le nombre de fois
             * que le prénom a été donné une autre année */
            foreach (Prenom p in prenoms)
            {
                if (p.annee >= anneeD && p.annee <= anneeF)
                {
                    if (!containsPrenom(prenomsPeriodeTmp, p))
                    {
                        prenomsPeriodeTmp[cpt++] = p;
                    }
                    else
                    {
                        ajouterNombreAuPrenom(prenomsPeriodeTmp, p.prenom, p.nombre);
                    }
                }
            }

            resultat = new Prenom[cpt];               // On stocke dans un autre tableau pour enlever les cases inutiles

            trierPrenomsParNombre(prenomsPeriodeTmp); // On trie le tableau par ordre croissant sur prenom.nombre

            /* On stocke les données dans le nouveau tableau, en redéfinissant l'ordre
             * et l'année (0) */
            for (int i = 0; i < resultat.Length; ++i)
            {
                resultat[i]       = prenomsPeriodeTmp[i];
                resultat[i].ordre = i + 1;
                resultat[i].annee = 0;
            }

            return(resultat);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Redéfinition de Equals pour comparer les contacts, comparaison sur nom et prénom
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (!(obj is Contact))
            {
                return(false);
            }
            Contact tmp = (Contact)obj;

            if (!Nom.Equals(tmp.Nom))
            {
                return(false);
            }
            if (!Prenom.Equals(tmp.Prenom))
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 18
0
        /* Méthode permettant de trier un tableau de Prenom par ordre alphabétique */
        public static void triAlphabetique(Prenom[] prenoms)
        {
            bool termine = false, echangeOk = false;
            int  i = 1, indexString = 0;

            /* Tri utilisé : tri à bulles */
            while (!termine)
            {
                termine = true;
                while (i < prenoms.Length)
                {
                    echangeOk = false;
                    while (indexString < prenoms[i - 1].prenom.Length &&
                           indexString < prenoms[i].prenom.Length && !echangeOk)
                    {
                        if (prenoms[i - 1].prenom[indexString] > prenoms[i].prenom[indexString])
                        {
                            Prenom p = prenoms[i - 1];
                            prenoms[i - 1] = prenoms[i];
                            prenoms[i]     = p;
                            echangeOk      = true;
                            termine        = false;
                        }
                        else
                        if (prenoms[i - 1].prenom[indexString] < prenoms[i].prenom[indexString])
                        {
                            echangeOk = true;
                        }

                        ++indexString;
                    }
                    ++i;
                    indexString = 0;
                }
                i = 1;
            }
        }
Exemplo n.º 19
0
 public bool Equals(Personne p)
 {
     return(Nom.Equals(p.Nom) && Prenom.Equals(p.Prenom));
 }
Exemplo n.º 20
0
 public static string ToDisplayableName(Prenom p)
 {
     return(DATE_CULTURE.TextInfo.ToTitleCase(p.Value.ToLower()));
 }
Exemplo n.º 21
0
 public virtual void MajPrenom()
 {
     Prenom = Prenom.ToUpper();
 }
Exemplo n.º 22
0
 public override string ToString()
 {
     return(Nom.Trim() + " " + Prenom.Trim());
 }
Exemplo n.º 23
0
 public override int GetHashCode()
 {
     return(Nom.GetHashCode() + 7 * Prenom.GetHashCode() + 43 * DateNaissance.GetHashCode());
 }
Exemplo n.º 24
0
 public bool Equals(CompositeurMetier other)
 {
     return(Nom.Equals(other.Nom) && Prenom.Equals(other.Prenom) && (DateNaissance == other.DateNaissance));
 }
Exemplo n.º 25
0
 public bool Equals(CompositeurIHM other)
 {
     return(Nom.Equals(other.Nom) && Prenom.Equals(other.Prenom) && DateNaissance == other.DateNaissance);
 }
Exemplo n.º 26
0
 public override string ToString()
 {
     return($"({Id}) {Nom.ToUpper()},{Prenom.ToLower()} - Ad. {Adresse}");
 }
Exemplo n.º 27
0
        public bool IsValide()
        {
            bool        isValid          = true;
            var         regNumber        = new Regex(@"^\d+$");
            var         regName          = new Regex(@"^[\ a-zA-Z\'\.]+$");
            CultureInfo culture          = Thread.CurrentThread.CurrentCulture;
            string      decimalSeparator = culture.NumberFormat.NumberDecimalSeparator;

            Matricule  = Matricule.Trim();
            CleCnss    = CleCnss.Trim();
            NumeroCnss = NumeroCnss.Trim();
            Nom        = Nom.Trim();
            Prenom     = Prenom.Trim();

            //******* Verify Nom ***********

            if (string.IsNullOrEmpty(Nom))
            {
                return(false);
            }
            if (!regName.IsMatch(Nom))
            {
                return(false);
            }

            //******* Verify Prenom ***********

            if (string.IsNullOrEmpty(Prenom))
            {
                return(false);
            }
            if (!regName.IsMatch(Prenom))
            {
                return(false);
            }

            //******* Verify CIN ***********

            if (string.IsNullOrEmpty(Cin))
            {
                return(false);
            }
            if (Cin.Length > 8)
            {
                return(false);
            }
            if (Cin.Length < 8)
            {
                Cin = Cin.Trim().PadLeft(8, '0');
            }
            var rgxCin = new Regex(@"[0-9]{8}");

            if (!rgxCin.IsMatch(Cin))
            {
                return(false);
            }

            //******** Verify Civilite **********
            if (CiviliteNo < 0 || CiviliteNo > 2)
            {
                return(false);
            }

            //******* Verify Autres nom ********
            if (!regName.IsMatch(AutresNom) && AutresNom.Trim() != string.Empty)
            {
                return(false);
            }

            //******* Verify NomJeuneFille ********

            if (!string.IsNullOrEmpty(NomJeuneFille) && !regName.IsMatch(NomJeuneFille.Trim()))
            {
                return(false);
            }

            //******* Verify BrutA ********

            string brutAtStr = BrutAStr
                               .Replace(",", decimalSeparator)
                               .Replace(".", decimalSeparator);
            decimal brutA;

            if (!decimal.TryParse(brutAtStr, out brutA))
            {
                return(false);
            }
            if (brutA < 0)
            {
                return(false);
            }

            //******* Verify BrutB ********

            string brutBtStr = BrutBStr
                               .Replace(",", decimalSeparator)
                               .Replace(".", decimalSeparator);
            decimal brutB;

            if (!decimal.TryParse(brutBtStr, out brutB))
            {
                return(false);
            }
            if (brutB < 0)
            {
                return(false);
            }

            //******* Verify BrutC ********

            string brutCtStr = BrutCStr
                               .Replace(",", decimalSeparator)
                               .Replace(".", decimalSeparator);
            decimal brutC;

            if (!decimal.TryParse(brutCtStr, out brutC))
            {
                return(false);
            }
            if (brutC < 0)
            {
                return(false);
            }

            //******* Verify Matricule ********
            if (NumeroCnss.Trim().Length < 8)
            {
                NumeroCnss = NumeroCnss.Trim().PadLeft(8, '0');
            }
            if (string.IsNullOrEmpty(NumeroCnss) ||
                NumeroCnss.Length > 8 ||
                !regNumber.IsMatch(NumeroCnss))
            {
                return(false);
            }

            //******* Verify Cle ********
            if (CleCnss.Trim().Length < 2)
            {
                CleCnss = CleCnss.Trim().PadLeft(2, '0');
            }
            if (string.IsNullOrEmpty(CleCnss) ||
                CleCnss.Length > 2 ||
                !regNumber.IsMatch(CleCnss))
            {
                return(false);
            }

            //******* Verify matricule interne ********

            if (string.IsNullOrEmpty(Matricule) ||
                Matricule.Length > 10 ||
                !regNumber.IsMatch(Matricule))
            {
                return(false);
            }

            //******* Verify Type cnss  ********

            if (TypeCnss > 19 || TypeCnss < 0)
            {
                return(false);
            }

            //******* Situation familiale  ********

            if (SituationFamilleNo > 8 || SituationFamilleNo < 0)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 28
0
        public void GetPropertyError(string propertyName, ErrorInfo info)
        {
            var         regNumber        = new Regex(@"^\d+$");
            var         regName          = new Regex(@"^[\ a-zA-Z\'\.]+$");
            CultureInfo culture          = Thread.CurrentThread.CurrentCulture;
            string      decimalSeparator = culture.NumberFormat.NumberDecimalSeparator;

            //******* Verify Nom ***********
            if (propertyName == "Nom")
            {
                if (string.IsNullOrEmpty(Nom.Trim()))
                {
                    info.ErrorText = "Le champs [Nom] est obligatoire!";
                    info.ErrorType = ErrorType.Critical;
                }
                else
                {
                    if (!regName.IsMatch(Nom.Trim()))
                    {
                        info.ErrorText = "Le champs [Nom] est invalide!";
                        info.ErrorType = ErrorType.Critical;
                    }
                }
            }
            //******* Verify Prenom ***********
            if (propertyName == "Prenom")
            {
                if (string.IsNullOrEmpty(Prenom.Trim()))
                {
                    info.ErrorText = "Le champs [Prenom] est obligatoire!";
                    info.ErrorType = ErrorType.Critical;
                }
                else
                {
                    if (!regName.IsMatch(Prenom.Trim()))
                    {
                        info.ErrorText = "Le champs [Prénom] est invalide!";
                        info.ErrorType = ErrorType.Critical;
                    }
                }
            }
            //******* Verify CIN ***********
            if (propertyName == "Cin")
            {
                if (string.IsNullOrEmpty(Cin.Trim()))
                {
                    info.ErrorText = "Le champs [Cin] est obligatoire!";
                    info.ErrorType = ErrorType.Critical;
                }
                else
                {
                    if (Cin.Length > 8)
                    {
                        info.ErrorText = "Le champs [Cin] est invalide!";
                        info.ErrorType = ErrorType.Critical;
                    }
                    else
                    {
                        if (Cin.Length < 8)
                        {
                            Cin = Cin.Trim().PadLeft(8, '0');
                        }
                        var rgxCin = new Regex(@"[0-9]{8}");
                        if (!rgxCin.IsMatch(Cin))
                        {
                            info.ErrorText = "Le champs [Cin] est invalide!";
                            info.ErrorType = ErrorType.Critical;
                        }
                    }
                }
            }
            //******** Verify Civilite **********
            if (propertyName == "Civilite" && (CiviliteNo < 0 || CiviliteNo > 2))
            {
                info.ErrorText = "Le champs [Civilité] est invalide!";
                info.ErrorType = ErrorType.Critical;
            }

            //******* Verify Autres nom ********
            if (propertyName == "AutresNom" &&
                !regName.IsMatch(AutresNom.Trim()) &&
                AutresNom.Trim() != string.Empty)
            {
                info.ErrorText = "Le champs [Autres nom] est invalide!";
                info.ErrorType = ErrorType.Critical;
            }

            //******* Verify NomJeuneFille ********
            if (propertyName == "NomJeuneFille")
            {
                if (!string.IsNullOrEmpty(NomJeuneFille.Trim()) && !regName.IsMatch(NomJeuneFille.Trim()))
                {
                    info.ErrorText = "Le champs [Nom de jeune fille] est invalide!";
                    info.ErrorType = ErrorType.Critical;
                }
            }

            //******* Verify BrutA ********
            if (propertyName == "BrutA")
            {
                if (BrutA < 0)
                {
                    info.ErrorText = "BrutA invalide! ";
                    info.ErrorType = ErrorType.Critical;
                }
            }

            //******* Verify BrutB ********
            if (propertyName == "BrutB")
            {
                if (BrutB < 0)
                {
                    info.ErrorText = "BrutB invalide! ";
                    info.ErrorType = ErrorType.Critical;
                }
            }

            //******* Verify BrutC ********
            if (propertyName == "BrutC")
            {
                if (BrutC < 0)
                {
                    info.ErrorText = "BrutC invalide! ";
                    info.ErrorType = ErrorType.Critical;
                }
            }
            //******* Verify Matricule ********
            if (propertyName == "NumeroCnss")
            {
                if (string.IsNullOrEmpty(NumeroCnss.Trim()) ||
                    NumeroCnss.Length > 8 ||
                    !regNumber.IsMatch(NumeroCnss.Trim()))
                {
                    info.ErrorText = "Numéro Cnss invalide! ";
                    info.ErrorType = ErrorType.Critical;
                }
                else
                {
                    NumeroCnss = NumeroCnss.PadLeft(8, '0');
                }
            }
            //******* Verify Cle ********
            if (propertyName == "CleCnss")
            {
                if (string.IsNullOrEmpty(CleCnss.Trim()) ||
                    CleCnss.Length > 2 ||
                    !regNumber.IsMatch(CleCnss.Trim()))
                {
                    info.ErrorText = "Clé Cnss invalide! ";
                    info.ErrorType = ErrorType.Critical;
                }
                else
                {
                    CleCnss = CleCnss.PadLeft(2, '0');
                }
            }
            //******* Verify matricule interne ********
            if (propertyName == "Matricule")
            {
                if (string.IsNullOrEmpty(Matricule.Trim()) ||
                    Matricule.Trim().Length > 10 ||
                    !regNumber.IsMatch(Matricule.Trim()))
                {
                    info.ErrorText = "Matricule interne invalide! ";
                    info.ErrorType = ErrorType.Critical;
                }
            }
            //******* Verify Type cnss  ********
            if (propertyName == "TypeCnss")
            {
                if (TypeCnss > 19 || TypeCnss < 0)
                {
                    info.ErrorText = "Type cnss invalide! ";
                    info.ErrorType = ErrorType.Critical;
                }
            }
            //******* Situation familiale  ********
            if (propertyName == "SituationFamille")
            {
                if (SituationFamilleNo > 8 || SituationFamilleNo < 0)
                {
                    info.ErrorText = "Situation familiale invalide! ";
                    info.ErrorType = ErrorType.Critical;
                }
            }
        }
Exemplo n.º 29
0
 public bool Equals(Intervenant intervenant)
 {
     return(Nom.Equals(intervenant.Nom) && Prenom.Equals(intervenant.Prenom) && Mail.Equals(intervenant.Mail));
 }
Exemplo n.º 30
0
 public void MajPrenom() => Prenom = Prenom.ToUpper();
Exemplo n.º 31
0
        /// <summary>
        /// Evenement pour ajouter un réalisateur
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddDirector_Click(object sender, RoutedEventArgs e)
        {
            Personne directorToAdd;

            String   Nom;
            String   Prenom;
            String   Nationalite;
            String   Biographie;
            DateTime Naissance;
            DateTime?Mort;

            int NaissanceAnnee;
            int NaissanceMois;
            int NaissanceJour;

            int MortAnnee;
            int MortMois;
            int MortJour;

            if (String.IsNullOrWhiteSpace(NomDirector.Text))
            {
                MessageBox.Show("Ce champ est nul ou non renseigné", "Erreur format nom", MessageBoxButton.OK);
                return;
            }
            if (String.IsNullOrWhiteSpace(PrenomDirector.Text))
            {
                MessageBox.Show("Ce champ est nul ou non renseigné", "Erreur format prénom", MessageBoxButton.OK);
                return;
            }
            try
            {
                NaissanceAnnee = Int32.Parse(NaissanceAnneeDirector.Text);
            }
            catch (FormatException ex)
            {
                MessageBox.Show(ex.Message, "Erreur format année de naissance", MessageBoxButton.OK);
                return;
            }
            if (String.IsNullOrWhiteSpace(NationaliteDirector.Text))
            {
                MessageBox.Show("Ce champ est nul ou non renseigné", "Erreur format nationalité", MessageBoxButton.OK);
                return;
            }
            if (String.IsNullOrWhiteSpace(BiographieDirector.Text))
            {
                MessageBox.Show("Ce champ est nul ou non renseigné", "Erreur format biographie", MessageBoxButton.OK);
                return;
            }
            if (NaissanceJourDirector.SelectedItem == null)
            {
                MessageBox.Show("Ce champ est nul ou non renseigné", "Erreur format jour de naissance", MessageBoxButton.OK);
                return;
            }
            if (NaissanceMoisDirector.SelectedItem == null)
            {
                MessageBox.Show("Ce champ est nul ou non renseigné", "Erreur format mois de naissance", MessageBoxButton.OK);
                return;
            }

            NaissanceMois = Int32.Parse(NaissanceMoisDirector.SelectedItem.ToString());
            NaissanceJour = Int32.Parse(NaissanceJourDirector.SelectedItem.ToString());
            Naissance     = new DateTime(NaissanceAnnee, NaissanceMois, NaissanceJour);

            if (MortJourDirector.SelectedIndex != -1)
            {
                MortJour = Int32.Parse(MortJourDirector.SelectedItem.ToString());
                if (MortMoisDirector.SelectedIndex != -1)
                {
                    MortMois = Int32.Parse(MortMoisDirector.SelectedItem.ToString());
                    if (MortAnneeDirector.Text != null)
                    {
                        try
                        {
                            MortAnnee = Int32.Parse(MortAnneeDirector.Text);
                        }
                        catch (FormatException ex)
                        {
                            MessageBox.Show(ex.Message, "Erreur format année de mort", MessageBoxButton.OK);
                            return;
                        }
                        Mort = new DateTime(MortAnnee, MortMois, MortJour);
                    }
                    else
                    {
                        Mort = new DateTime?();
                    }
                }
                else
                {
                    Mort = new DateTime?();
                }
            }
            else
            {
                Mort = new DateTime?();
            }

            Nom         = NomDirector.Text;
            Prenom      = PrenomDirector.Text;
            Nationalite = NationaliteDirector.Text;
            Biographie  = BiographieDirector.Text;

            string extension;
            string pathimg;

            if (SourcePath != null)
            {
                int index = 0;

                for (; SourcePath[index] != '.'; ++index)
                {
                }

                extension = SourcePath.Remove(0, index);
                pathimg   = $"{Prenom.ToLower().Replace(" ", string.Empty) + "-" + Nom.ToLower().Replace(" ", string.Empty)}{extension}";
                File.Move(SourcePath, Directory.GetCurrentDirectory() + "\\..\\..\\img\\" + pathimg);
            }
            else
            {
                pathimg = "noavatar.png";
            }

            if (Mort == null)
            {
                directorToAdd = new Personne(Nom, Prenom, Naissance, Nationalite, Biographie, pathimg);
            }
            else
            {
                directorToAdd = new Personne(Nom, Prenom, Naissance, Mort, Nationalite, Biographie, pathimg);
            }

            LeManager.AjouterReal(directorToAdd);
            MessageBox.Show("Vous avez ajouter le réalisateur " + directorToAdd.Nom + " " + directorToAdd.Prenom + " avec succès.", "Ajout réalisateur", MessageBoxButton.OK, MessageBoxImage.Information);
            NavManager.SelectedPart = NavManager.Parts["Accueil"]();
        }
Exemplo n.º 32
0
        public bool IsValide()
        {
            bool isValid   = true;
            var  regNumber = new Regex(@"^\d+$");
            var  regName   = new Regex(@"^[\ a-zA-Z\'\.]+$");

            Matricule = Matricule.Trim();
            CleCnss   = CleCnss.Trim();
            NumCnss   = NumCnss.Trim();
            Nom       = Nom.Trim();
            Prenom    = Prenom.Trim();

            //******* Verify Nom ***********

            if (string.IsNullOrEmpty(Nom))
            {
                return(false);
            }
            if (!regName.IsMatch(Nom))
            {
                return(false);
            }

            //******* Verify Prenom ***********

            if (string.IsNullOrEmpty(Prenom))
            {
                return(false);
            }
            if (!regName.IsMatch(Prenom))
            {
                return(false);
            }

            //******* Verify CIN ***********



            if (string.IsNullOrEmpty(Cin))
            {
                return(false);
            }
            if (Cin.Length > 8)
            {
                return(false);
            }
            if (Cin.Length < 8)
            {
                Cin = Cin.Trim().PadLeft(8, '0');
            }
            //var rgxCin = new Regex(@"[0-9]{8}");
            //if (!rgxCin.IsMatch(Cin))
            //{
            //    return false;
            //}

            //******* Verify Autres nom ********
            if (!regName.IsMatch(AutreNom) && AutreNom.Trim() != string.Empty)
            {
                return(false);
            }

            //******* Verify NomJeuneFille ********

            if (!string.IsNullOrEmpty(NomJeuneFille) && !regName.IsMatch(NomJeuneFille.Trim()))
            {
                return(false);
            }

            //******* Verify BrutA ********

            if (BrutA < 0)
            {
                return(false);
            }

            //******* Verify BrutB ********

            if (BrutB < 0)
            {
                return(false);
            }

            //******* Verify BrutC ********

            if (BrutC < 0)
            {
                return(false);
            }

            //******* Verify Matricule ********
            if (string.IsNullOrEmpty(NumCnss) ||
                NumCnss.Length > 8 ||
                !regNumber.IsMatch(NumCnss))
            {
                return(false);
            }
            if (NumCnss.Trim().Length < 8)
            {
                NumCnss = NumCnss.Trim().PadLeft(8, '0');
            }


            //******* Verify Cle ********

            if (string.IsNullOrEmpty(CleCnss) ||
                CleCnss.Length > 2 ||
                !regNumber.IsMatch(CleCnss.Trim()))
            {
                return(false);
            }


            if (CleCnss.Trim().Length < 2)
            {
                CleCnss = CleCnss.Trim().PadLeft(2, '0');
            }


            //******* Verify matricule interne ********

            if (string.IsNullOrEmpty(Matricule) ||
                Matricule.Length > 10
                //|| !regNumber.IsMatch(Matricule)
                )
            {
                return(false);
            }

            return(true);
        }