private void btnConnect_Click(object sender, RoutedEventArgs e) { string courriel = txtCourriel.Text; string password = txtPwd.Password; if (courriel != "" && password != "") { try { User = PersonneManager.GetUserLogin(courriel, password); if (User == null) { MessageBox.Show("Login fail, veulliez ressayer, svp.", "LOGIN FAIL", MessageBoxButton.OK, MessageBoxImage.Error); txtPwd.Password = ""; } else { this.Visibility = System.Windows.Visibility.Hidden; //creer nouvelles fenetres ici! Contacts contactsWindow = new Contacts(User); contactsWindow.Show(); //update lastVisit BD int retour = PersonneManager.UpdateLastVisit(DateTime.Now, User.Id); this.Close(); } } catch (Exception) { MessageBox.Show("serveur indisponible"); this.Close(); throw; } } else if (courriel == "") { MessageBox.Show("Saisir le courriel, svp.", "Erreur de saisie", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else if (password == "") { MessageBox.Show("Saisir le password, svp.", "Erreur de saisie", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { MessageBox.Show("Saisir les champs, svp.", "Erreur de saisie", MessageBoxButton.OK, MessageBoxImage.Exclamation); } //SQLHelper.GetUserLogin(courriel, password); }
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!"; } }