Exemplo n.º 1
0
        private void Button_Auth_Click(object sender, RoutedEventArgs e)
        {
            string login = textBoxLogin.Text.Trim();
            string pass  = passBox.Password.Trim();


            if (login.Length < 5)
            {
                textBoxLogin.ToolTip    = "Некоректне значення";
                textBoxLogin.Background = Brushes.MistyRose;
            }

            else if (pass.Length < 5)
            {
                passBox.ToolTip    = "Некоректне значення";
                passBox.Background = Brushes.MistyRose;
            }

            else
            {
                textBoxLogin.ToolTip    = "";
                textBoxLogin.Background = Brushes.Transparent;
                passBox.ToolTip         = "";
                passBox.Background      = Brushes.Transparent;


                User authUser = null;
                using (ApplicationContext db = new ApplicationContext())
                {
                    authUser = db.Users.Where(user => user.Login == login && user.Pass == pass).FirstOrDefault();
                }

                if (authUser != null)
                {
                    MessageBox.Show("Успішно!");
                    UserPageWindow userPageWindow = new UserPageWindow();
                    userPageWindow.Show();
                    Hide();
                }

                else
                {
                    MessageBox.Show("Логін або пароль некоректні!");
                }
            }
        }
Exemplo n.º 2
0
        private void Button_Reg_Click(object sender, RoutedEventArgs e)
        {
            InitForm();
            CheskCorrectInput();

            if (isInputCorrect)
            {
                string login = TextBox_Login.Text.Trim();
                string pass  = PassBox.Password.Trim();
                string email = TextBox_Email.Text;

                var user = new User(login, pass, email);
                var db   = new ApplicationContext();
                db.Users.Add(user);
                db.SaveChanges();

                UserPageWindow userPageWindow = new UserPageWindow();
                userPageWindow.Show();
                this.Hide();
            }
        }