예제 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            int       j = 0;
            Passwords p = new Passwords();

            p.Password = textBoxCurrentPassword.Text;

            if (p.IsCorrect(p.Password) == false)
            {
                textBoxCurrentPassword.Text = " ";
                MessageBox.Show("Wrong format of password");
            }

            if (textBoxCurrentPassword.Text != " ")
            {
                for (int i = 0; i < users.Userlist.Count; i++)
                {
                    if (users.Userlist[i].ToString() == textBoxCurrentPassword.Text)
                    {
                        j = i;
                        break;
                    }
                }

                if (j == 0)
                {
                    MessageBox.Show("Wrong password");
                }

                /*
                 * if (passwordlist.Contain(textBoxCurrentPassword.Text) == false)
                 *  MessageBox.Show("Wrong password");
                 * else
                 * {
                 *  j = users.BinarySearch(textBoxCurrentPassword.Text);
                 * }
                 */
            }

            Passwords n = new Passwords();

            n.Password = textBoxNewPassword.Text;

            if (p.IsCorrect(n.Password) == false)
            {
                textBoxNewPassword.Text = " ";
                MessageBox.Show("Wrong format of password");
            }

            if (textBoxNewPassword.Text != " ")
            {
                users.RemoveAt(j);
                users.Insert(j, textBoxNewPassword.Text);
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Passwords p = new Passwords();

            p.Password = textBoxPassword.Text;
            if (p.IsCorrect(p.Password) == false)
            {
                textBoxPassword.Text = " ";
                MessageBox.Show("Wrong format of password");
            }

            if (textBoxPassword.Text != " ")
            {
                int result = 0;

                if (users.Userlist.Count == 0)
                {
                    users.Add(new User(textBoxLogin.Text, textBoxPassword.Text, textBoxEmail.Text, textBoxPhone.Text, dateTimeExpiration.MaxDate));
                    listBoxUsers.Items.Add(((User)users.Userlist[users.Userlist.Count - 1]).ToString() + '\n');
                    passwordlist.Add(new Passwordlist(textBoxPassword.Text));
                    listBoxPassword.Items.Add(((Passwordlist)passwordlist.Passwordslist[passwordlist.Passwordslist.Count - 1]).ToString() + '\n');
                }
                else
                {
                    for (int i = 0; i < users.Userlist.Capacity; i++)
                    {
                        if (users.Userlist[i].ToString() != (textBoxPassword.Text))
                        {
                            users.Add(new User(textBoxLogin.Text, textBoxPassword.Text, textBoxEmail.Text, textBoxPhone.Text, dateTimeExpiration.MaxDate));
                            listBoxUsers.Items.Add(((User)users.Userlist[users.Userlist.Count - 1]).ToString() + '\n');
                            passwordlist.Add(new Passwordlist(textBoxPassword.Text));
                            listBoxPassword.Items.Add(((Passwordlist)passwordlist.Passwordslist[passwordlist.Passwordslist.Count - 1]).ToString() + '\n');
                            result = 1;
                            break;
                        }
                    }
                    if (result == 0)
                    {
                        textBoxPassword.Text = " ";
                        MessageBox.Show("Password has been already used");
                    }

                    result = 0;
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Passwords p = new Passwords();

            p.Password = tbPassword.Text;

            Logins l = new Logins();

            l.Login = tbLogin.Text;

            Emails em = new Emails();

            em.Email = tbEmail.Text;

            PhoneNumbers ph = new PhoneNumbers();

            ph.Phone = tbPhone.Text;

            if (p.IsCorrect(p.Password) == true && l.IsCorrect(l.Login) == true && em.IsCorrect(em.Email) == true && ph.IsCorrect(ph.Phone) == true)
            {
                if (CheckPsw(tbPassword.Text.ToString()))
                {
                    Users.Add(new User(tbLogin.Text, tbPassword.Text, tbEmail.Text, tbPhone.Text, dateTimeExpiration.Value));
                    listBoxUsers.Items.Add(Users[Users.Count - 1].ToString() + '\n');
                    tbPassword.BackColor = Color.White;
                    tbPhone.BackColor    = Color.White;
                    tbEmail.BackColor    = Color.White;
                    tbLogin.BackColor    = Color.White;
                }
                else
                {
                    MessageBox.Show("You're trying to enter the same password\n" +
                                    "You can't.Chenge it please");
                }
                endDate.Add(dateTimeExpiration.Value);
            }
            else if (p.IsCorrect(p.Password) == false)
            {
                if (tbPassword.BackColor != Color.Red)
                {
                    tbPassword.BackColor = Color.Red;
                    MessageBox.Show("Hey.It seems like you've made a mistake\n" +
                                    "in password field.You need to correct it");
                }
            }
            if (l.IsCorrect(l.Login) == false)
            {
                if (tbLogin.BackColor != Color.Red)
                {
                    tbLogin.BackColor = Color.Red;
                    MessageBox.Show("How did you manage to make a mistake \n" +
                                    "in a Login field? Correct it before anyone sees it");
                }
            }
            if (em.IsCorrect(em.Email) == false)
            {
                if (tbEmail.BackColor != Color.Red)
                {
                    tbEmail.BackColor = Color.Red;
                    MessageBox.Show("Another mistake\n" +
                                    "Will you correct it?");
                }
            }
            if (ph.IsCorrect(ph.Phone) == false)
            {
                if (tbPhone.BackColor != Color.Red)
                {
                    tbPhone.BackColor = Color.Red;
                    MessageBox.Show("Just correct it.Please");
                }
            }
        }