private void Button_Register_Click(object sender, RoutedEventArgs e)
        {
            var saver         = new Saver();
            var Users_List_DB = saver.LOAD_USER();
            var user          = new User(Login: Text_button.Text, Password: Password_button.Password);

            if ((user.Login == "Username" || user.Login == null || user.Login == "") || (user.Password == "Password" || user.Password == null || user.Password == ""))
            {
                HasErrorLabel.Foreground = Brushes.Red;
                HasErrorLabel.Text       = "Enter some Login/Password";
            }
            else
            {
                if (Users_List_DB.ListContains(user))
                {
                    HasErrorLabel.Foreground = Brushes.Red;
                    HasErrorLabel.Text       = "This user is already registered";
                }
                else
                {
                    HasErrorLabel.Foreground = Brushes.Green;
                    HasErrorLabel.Text       = "Success";
                    Users_List_DB.AddNewUser(user);
                    saver.SAVE_USER(Users_List_DB);
                    User.currentUser = Users_List_DB.GetCurrentUser(user);

                    AppWidnow appWidnow = new AppWidnow();
                    this.Hide();
                    appWidnow.ShowDialog();
                    this.Show();
                }
            }
        }
Example #2
0
        private void Button_Login_Click(object sender, RoutedEventArgs e)
        {
            User user          = new User();
            var  saver         = new Saver();
            var  Users_List_DB = saver.LOAD_USER();

            user = new User(Login: Text_button.Text, Password: Password_button.Password);
            if (Users_List_DB.CheckForCorrectUserAndPassword(user))
            {
                HasErrorLabel.Foreground = Brushes.Green;
                HasErrorLabel.Text       = "Success enter";
                User.currentUser         = Users_List_DB.GetCurrentUser(user);

                AppWidnow appWidnow = new AppWidnow();
                this.Hide();
                appWidnow.ShowDialog();
                this.Show();
            }
            else
            {
                HasErrorLabel.Foreground = Brushes.Red;
                HasErrorLabel.Text       = "This user dosen't exist";
            }
        }