Esempio n. 1
0
        private void register_click(Object sender, RoutedEventArgs e)
        {
            var curWindow = Window.GetWindow(this);

            string user = username.Text;
            string pw = password.Password;
            string em = email.Text;

            if (user == "" || pw == "" || em == "")
            {
                MessageBox.Show("Please enter a username, password and email address.");
                return;
            }

            mw_model mw = new mw_model();
            mw.NewUser(user, pw, em);

            if (mw.UserExists(user, pw))
            {
                mw_model.Username = user;
                mw_model.Password = pw;
                MainWindow m = new MainWindow();
                m.Show();
                curWindow.Close();
            }
            else
            {
                MessageBox.Show("Something went wrong while creating a new user account.");
            }
        }
Esempio n. 2
0
        private void login_click(Object sender, RoutedEventArgs e)
        {
            var curWindow = Window.GetWindow(this);
            mw_model mw = new mw_model();
            string user = username.Text;
            string pw = password.Password;

            if (user == "" || pw == "")
            {
                MessageBox.Show("Please enter a username and password.");
                return;
            }

            if (mw.UserExists(user, pw))
            {
                mw_model.Username = user;
                mw_model.Password = pw;
                MainWindow m = new MainWindow();
                m.Show();
                curWindow.Close();
            }
            else
            {
                // TODO register new user

                if (MessageBox.Show("This user does not exist. Do you want to create an account?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    Content = null;
                    Content = new RegisterUC();
                }
                else
                {

                }
            }
        }