private void btnInscrire_Click(object sender, RoutedEventArgs e) { //si les champs obligatoires ont ete saisies, on cree un user if (txtCourriel.Text.Length > 0 && txtPwd.Password.Length > 0 && txtNom.Text.Length > 0) { Personne personneInscrite = new Personne(); personneInscrite.Adresse = txtAdresse.Text; if (date.Text.Length <= 0) { personneInscrite.Aniversaire = null; } else { personneInscrite.Aniversaire = Convert.ToDateTime(date.Text); } personneInscrite.Celulaire = txtCel.Text; personneInscrite.Compagnie = txtCompagnie.Text; personneInscrite.Courriel = txtCourriel.Text; personneInscrite.IsUser = true; personneInscrite.IsVisible = (bool)chkVisible.IsChecked;//vient comme bool? par default personneInscrite.LastVisit = DateTime.Now; personneInscrite.ListeContact = new List <Contact>(); personneInscrite.ListePersonnes = new List <Personne>(); personneInscrite.Nom = txtNom.Text; personneInscrite.Password = txtPwd.Password; personneInscrite.Pays = txtPays.Text; personneInscrite.Province = txtProvince.Text; personneInscrite.SiteWeb = txtSite.Text; personneInscrite.Telephone = txtTelephone.Text; personneInscrite.Ville = txtVille.Text; if (newUrl == null) { personneInscrite.UrlPhoto = @"images\photoProfile.png";//utiliser une valeur par default } else { personneInscrite.UrlPhoto = newUrl; } bool userCree = PersonneManager.InsertUser(personneInscrite); //tester si la insertion est bien passe if (userCree) { //stocker le user dans la fenetre login MainWindow.User = personneInscrite; //nouvelles fenetres Contacts contactsWindow = new Contacts(personneInscrite); contactsWindow.Show(); this.Close(); } else { txtMsgErreur.Text = "L'utilisateur n'a pas ete cree, ressayez, svp."; } } else { txtMsgErreur.Text = "Saisir les champs obligatoires, svp!"; } }