Esempio n. 1
0
        //регистрация
        private void Registration_of_User(object sender, RoutedEventArgs e)
        {
            UserRegistration registrationWindow = new UserRegistration();

            if (registrationWindow.ShowDialog() == true)
            {
                string Nickname = registrationWindow.tbNickName.Text;
                string Password = registrationWindow.tbPassword.Password;
                if (registrationWindow.tbNickName.Text != "" && registrationWindow.tbPassword.Password != "")
                {
                    bool result = client.InsertUser(Nickname, Password);
                    if (result == false)
                    {
                        MessageBox.Show("Nickname " + Nickname + " already exists",
                                        "Attention!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        MessageBox.Show("Registration was a success. Welcome to WCF_Chat!",
                                        "Attention!", MessageBoxButton.OK, MessageBoxImage.Information);
                        tblockUserName.Text       = Nickname;
                        tblockUserName.Foreground = Brushes.Red;
                        db.Users.Load();
                        usersGrid.ItemsSource = db.Users.Local.ToBindingList();
                    }
                }
                else
                {
                    MessageBox.Show("Username and password fields can not be empty!",
                                    "Attention!", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }