Beispiel #1
0
        private void FormWork_FormClosed(object sender, FormClosedEventArgs e)
        {
            string db = string.Empty;

            if (CurrentUser.Name != "Admin")
            {
                foreach (User user in Users)
                {
                    if (user.Name != "Admin")
                    {
                        db += "\n" + user.Name + " " + user.Password + " " + user.PasswordLimit + " " + user.Lock + " " + user.TempPassword;
                    }
                    else
                    {
                        db += user.Name + " " + user.Password + " " + "False" + " " + "False" + " " + "False";
                    }
                }
            }
            else
            {
                foreach (User user in listBox_A_UsersList.Items)
                {
                    if (user.Name != "Admin")
                    {
                        db += "\n" + user.Name + " " + user.Password + " " + user.PasswordLimit + " " + user.Lock + " " + user.TempPassword;
                    }
                    else
                    {
                        db += user.Name + " " + user.Password + " " + "False" + " " + "False" + " " + "False";
                    }
                }
            }

            File.WriteAllBytes(Environment.CurrentDirectory + "\\db.txt", RC4.R4EncoderText(Form_Authorization.Key, Encoding.Unicode.GetBytes(db)));

            if (DialogResult != DialogResult.Retry)
            {
                DialogResult = DialogResult.OK;
            }
        }
Beispiel #2
0
        public Form_Authorization()
        {
            InitializeComponent();
            List <User> users = new List <User>();

            if (!File.Exists(Environment.CurrentDirectory + "\\db.txt"))
            {
                // ИмяПользователя Пароль ОграничениеНаПароль Блокировка ВременныйПароль
                File.WriteAllBytes(Environment.CurrentDirectory + "\\db.txt", RC4.R4EncoderText(Key, Encoding.Unicode.GetBytes("Admin admin False False False")));
            }

            while (true)
            {
                if (new Form_PasswordFromDb().ShowDialog() == DialogResult.OK)
                {
                    break;
                }
                else
                {
                    MessageBox.Show("Ошибка доступа! Не верен пароль от БД!");
                }
            }
        }