Exemple #1
0
        private void Validation_Click(object sender, RoutedEventArgs e)
        {
            Error.Text = "";

            if (string.IsNullOrWhiteSpace(TextName.Text) && string.IsNullOrWhiteSpace(TextPassword.Password) && string.IsNullOrWhiteSpace(TextPassword1.Password))
            {
                Error.Text                = "Veuillez saisir le nom et le mot de passe";
                TextName.BorderBrush      = System.Windows.Media.Brushes.Red;
                TextPassword.BorderBrush  = System.Windows.Media.Brushes.Red;
                TextPassword1.BorderBrush = System.Windows.Media.Brushes.Red;
            }
            else if (string.IsNullOrWhiteSpace(TextName.Text))
            {
                Error.Text           = "Veuillez saisir le nom";
                TextName.BorderBrush = System.Windows.Media.Brushes.Red;
            }
            else if (string.IsNullOrWhiteSpace(TextPassword.Password))
            {
                Error.Text = "Veuillez saisir le mot de passe";
                TextPassword.BorderBrush = System.Windows.Media.Brushes.Red;
            }
            else if (string.IsNullOrWhiteSpace(TextPassword1.Password))
            {
                Error.Text = "Veuillez confirmer le mot de passe";
                TextPassword1.BorderBrush = System.Windows.Media.Brushes.Red;
            }
            else if (!TextPassword1.Password.Equals(TextPassword.Password))
            {
                Error.Text = "Veuillez confirmer le mot de passe";
                TextPassword.BorderBrush  = System.Windows.Media.Brushes.Red;
                TextPassword1.BorderBrush = System.Windows.Media.Brushes.Red;
            }
            else
            {
                if (access.verifIfUserExist(TextName.Text, TextPassword.Password))
                {
                    Error.Text = "Cet utilisateur existe déjà.";
                }
                else
                {
                    if (Manager.Instance.isThisPage(TITLE))
                    {
                        int id = access.GetNewIdUser();
                        Manager.Instance.CurrentUser = new Business.User(id, TextPassword.Password, TextName.Text);
                        access.createUser(Manager.Instance.CurrentUser);
                        MainPage main = new MainPage();
                        main.Show();
                        var myWindow = Window.GetWindow(this);
                        Manager.Instance.changePage(MainPage.TITLE);
                        myWindow.Close();
                    }
                }
            }
        }
Exemple #2
0
        private void Validation_Click(object sender, RoutedEventArgs e)
        {
            Error.Text = "";

            if (string.IsNullOrWhiteSpace(TextName.Text) && string.IsNullOrWhiteSpace(TextPassword.Password))
            {
                Error.Text               = "Veuillez saisir le nom et le mot de passe";
                TextName.BorderBrush     = System.Windows.Media.Brushes.Red;
                TextPassword.BorderBrush = System.Windows.Media.Brushes.Red;
            }
            else if (string.IsNullOrWhiteSpace(TextName.Text))
            {
                Error.Text           = "Veuillez saisir le nom";
                TextName.BorderBrush = System.Windows.Media.Brushes.Red;
            }
            else if (string.IsNullOrWhiteSpace(TextPassword.Password))
            {
                Error.Text = "Veuillez saisir le mot de passe";
                TextPassword.BorderBrush = System.Windows.Media.Brushes.Red;
            }
            else
            {
                if (Users != null)
                {
                    foreach (User u in Users)
                    {
                        Console.WriteLine(u.ToString());
                        if (u.Name.Equals(TextName.Text) && u.Password.Equals(TextPassword.Password))
                        {
                            if (Manager.Instance.isThisPage(TITLE))
                            {
                                Manager.Instance.CurrentUser = u;
                                MainPage main = new MainPage();
                                main.Show();
                                Manager.Instance.changePage(MainPage.TITLE);
                                var myWindow = Window.GetWindow(this);
                                myWindow.Close();
                            }
                        }
                    }
                    Error.Text = "Un des champs n'est pas valide.";
                }
                else
                {
                    MessageBox.Show("Il est impossible de se connecter aux données. Réessayez plus tard.");
                }
            }
        }