Example #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox1.Text.Trim() == "")
         {
             return;
         }
         if (LoginSecurity.checkPassword(textBox1.Text.Trim()))
         {
             //密码校验成功
             Form1 mainForm = new Form1();
             mainForm.setLoginVisableFalse(this);
             mainForm.Show();
         }
         else
         {
             //密码校验失败
             MessageBox.Show("密钥无效,或已经过时,请重新输入");
         }
     }
     catch
     {
         //密码校验失败
         MessageBox.Show("密钥无效输入错误,请重试");
     }
 }
Example #2
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (!(txtPW.Password.ToString().Equals("")))
            {
                try
                {
                    if (LoginSecurity.checkPassword(txtPW.Password.ToString(), 2) == true)
                    {
                        GestionCommandeCaissier gcmd = new GestionCommandeCaissier();
                        this.Visibility = Visibility.Hidden;
                        gcmd.Show();
                    }
                    else
                    {
                        MessageBox.Show("MDP ERRRONE");
                        j++;
                        txtNotice.Text = "Il vous reste " + j + " /5 tentatives";
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                }
            }
            if (txtPW.Password.ToString().Equals(""))
            {
                MessageBox.Show("mot de passe requis");
                return;
            }

            if (j == 5)
            {
                DateTime now = DateTime.Now;
                try
                {
                    //check password
                    txtPW.IsEnabled      = false;
                    btnLogin.IsEnabled   = false;
                    txtNotice.Text       = "CONNEXION BLOQUEE";
                    txtNotice.Foreground = Brushes.Red;
                    if ((txtPW.IsEnabled == false) && (now == DateTime.Now.AddMinutes(3)))
                    {
                        txtPW.IsEnabled    = true;
                        btnLogin.IsEnabled = true;
                    }
                    //updating pw
                    int i = UserDAO.editUserPWAutomatically(1);
                    if (LoginSecurity.notifyAdminByEmail(2, "*****@*****.**", "Yassine Ben Hamida") == 1)
                    {
                        MessageBox.Show("Le mot de passe a été changé automatiquement veuillez consulter votre mail");
                    }
                }
                catch (Exception exe)
                {
                    MessageBox.Show("ERR " + exe.Message);
                }
                return;
            }
        }
Example #3
0
        private void btnValider_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtNPW.Password.ToString() == "" || txtConfi.Password.ToString() == "")
                {
                    MessageBox.Show("les deux champs sont requis !");
                    return;
                }
                if (txtNPW.Password.ToString().Contains(" ") || txtConfi.Password.ToString().Contains(" "))
                {
                    MessageBox.Show("Pas d'espaces dans votre mot de passe !");
                    return;
                }
                if (txtNPW.Password.Length < 8 || txtConfi.Password.Length < 8)
                {
                    MessageBox.Show("Le mdp doit etre au moins de 8 caractéres");
                    return;
                }


                if (txtNPW.Password.ToString() == txtConfi.Password.ToString())
                {
                    string finalpw = txtConfi.Password.ToString();
                    try
                    {
                        if (!(LoginSecurity.checkPassword(finalpw, idOfFetchedUser)))
                        {
                            if (UserDAO.editUserPWWrequested(idOfFetchedUser, finalpw) == 1)
                            {
                                MessageBox.Show("Le mot de passe a été changé avec succés");
                                this.Close();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally { Connexion.closeConnection(); }
                }


                else
                {
                    MessageBox.Show("Les deux mot de passe ne sont pas identique !");
                    MessageBox.Show("Veuillez entre un nouveau mot de passe !");
                }
            }
            catch (Exception n)
            {
                MessageBox.Show(n.Message);
            }
        }