Esempio n. 1
0
        private void EnterButton_Click(object sender, EventArgs e)
        {
            try
            {
                var users = DataFabric.GetUsers();

                var currentUser = users.FirstOrDefault(user => user.User == LoginTextBox.Text &&
                                                       user.Password == PasswordTextBox.Text);
                if (currentUser == null)
                {
                    MessageBox.Show(@"Неправильный логин или пароль!",
                                    @"Ошибка доступа",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            var form = new People();

            form.Show();
        }
Esempio n. 2
0
        private void RegistrationButton_Click(object sender, EventArgs e)
        {
            //todo check regex
            var allUsers = DataFabric.GetUsers();

            var registerUser = allUsers.FirstOrDefault(currentUser => currentUser.Name == LoginTextBox.Text.Trim());

            if (registerUser != null)
            {
                MessageBox.Show(@"Такой пользователь уже существует",
                                @"Ошибка регистрации",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            var user = allUsers.FirstOrDefault(currentUser => currentUser.User == "password" &&
                                               currentUser.Password == CodeTextBox.Text.Trim());

            if (user == null)
            {
                MessageBox.Show(@"Неверный код!",
                                @"Ошибка регистрации",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            var newUser = new UserDto()
            {
                Name     = LoginTextBox.Text.Trim(),
                User     = NameTextBox.Text.Trim(),
                Password = PasswordTextBox.Text.Trim()
            };

            string values = $"'{newUser.User}', '{newUser.Password}', '{newUser.Name}'";

            _connect.Insert(Properties.MySQLNames.userTableName,
                            Properties.MySQLNames.userFields,
                            values);//todo maybe add filling authorization form by this values
        }
Esempio n. 3
0
 private void People_Load(object sender, EventArgs e)
 {
     _peopleData = DataFabric.GetPeople();
     InitializeDataGrid(_peopleData);
 }