示例#1
0
        private void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            if (UserPassword.Password == UserPasswordEnsure.Password)
            {
                user.Password = UserPassword.Password;
                if ((UserType)UserTypeComboBox.SelectedItem == BE.UserType.Host)
                {
                    try
                    {
                        if (myIBL.AddHostCanMoveOn(user))
                        {
                            Window NewHostRegWindow = new HostRegWindow(user);
                            NewHostRegWindow.Show();
                            this.Close();
                        }
                    }
                    catch (UserAlreadyExistsException)
                    {
                        UserName.Focus();
                        MessageBox.Show("The UserName you entered is alredy used.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    catch (NotValidEmailAddressException)
                    {
                        MailTextBox.Focus();
                        MessageBox.Show("The MailAddress you entered is invalid.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("There was a problem!!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else if ((UserType)UserTypeComboBox.SelectedItem == BE.UserType.Guest)
                {
                    try
                    {
                        myIBL.AddGuest(user);
                        Window loginWindow = new LoginWindow();
                        loginWindow.Show();
                        this.Close();
                    }
                    catch (UserAlreadyExistsException)
                    {
                        UserName.Focus();
                        MessageBox.Show("The UserName you entered is alredy used.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    catch (NotValidEmailAddressException)
                    {
                        MailTextBox.Focus();
                        MessageBox.Show("The MailAddress you entered is invalid.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("There was a problem!!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }

            else
            {
                UserPasswordEnsure.Focus();
                MessageBox.Show("Check Your Password again!!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }