Ejemplo n.º 1
0
        private void Register_Click(object sender, RoutedEventArgs e)
        {
            if (ConnectionHelper.CheckName(name.Text) && ConnectionHelper.CheckSurname(surname.Text) &&
                ConnectionHelper.CheckEmail(email.Text) && ConnectionHelper.CheckUsername(username.Text) &&
                ConnectionHelper.CheckPassword(password1.Password, password2.Password))
            {
                try
                {
                    FocusManager.SetFocusedElement(this, null);

                    if (ConnectionHelper.RegisterUser(name.Text, surname.Text, email.Text, username.Text, password1.Password, password2.Password))
                    {
                        if (EmailClientHelper.SMTP != null)
                        {
                            EmailClientHelper.SendEmail(email.Text, name.Text, surname.Text, username.Text, password1.Password);
                        }

                        MessageBox.Show("Congratulations!\nYou are successfully registered!", "Registration", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
                        //Close();
                    }
                }
                catch (SqlException exception)
                {
                    MessageBox.Show("Database insert error:\n" + exception.Message, "Registration", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    StatusBarString = Properties.Settings.Default.StatusReady;
                }
            }
        }
Ejemplo n.º 2
0
        private void Update_Click(object sender, RoutedEventArgs e)
        {
            if (firstName.DataChanged || surname.DataChanged || birth_date.DataChanged || address.DataChanged || email.DataChanged || phone.DataChanged)
            {
                if (ConnectionHelper.CheckName(firstName.Text) && ConnectionHelper.CheckSurname(surname.Text) && ConnectionHelper.CheckEmail(email.Text) && ConnectionHelper.CheckPhoneNumber(phone.Text))
                {
                    try
                    {
                        ConnectionHelper.UpdateUserData(firstName.Text, surname.Text, birth_date.SelectedDate, address.Text, email.Text, phone.Text, _userName, _password);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Database error:\n" + ex.Message, "Personal data update", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    finally
                    {
                        firstName.DataChanged = surname.DataChanged = birth_date.DataChanged = address.DataChanged = email.DataChanged = phone.DataChanged = false;
                    }
                }
            }
            else
            {
                MessageBox.Show("There is no changes in your personal data!", "Personal data update", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            StatusBarString = Properties.Settings.Default.StatusReady;
        }