Example #1
0
        private void ButtonSalvar_Click(object sender, RoutedEventArgs e)
        {
            var messageQueue = SnackbarThree.MessageQueue;

            DateTime dataNascimento;
            String   nome       = TextBoxNome.Text;
            String   cpf        = TextBoxCpf.Text;
            String   senhaAtual = TextBoxSenhaAtual.Password;
            String   senhaNova  = TextBoxSenhaNova.Password;

            if (String.IsNullOrEmpty(nome))
            {
                TextBoxNome.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Nome não informado."));
                return;
            }

            if (String.IsNullOrEmpty(senhaAtual))
            {
                TextBoxSenhaAtual.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Senha atual não informada."));
                return;
            }


            if (DatePickerNascimento.SelectedDate == null || DatePickerNascimento.SelectedDate > DateTime.Now)
            {
                DatePickerNascimento.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Data de nascimento inválida."));
                return;
            }
            else
            {
                dataNascimento = DatePickerNascimento.SelectedDate.Value;
            }

            if (!String.IsNullOrEmpty(TextBoxSenhaNova.Password))
            {
                if (!control.ValidarSenha(cpf, senhaAtual))
                {
                    Task.Factory.StartNew(() => messageQueue.Enqueue("Senha atual inválida!"));
                    return;
                }
            }
            else
            {
                senhaNova = senhaAtual;
            }

            if (control.Salvar(nome, senhaNova, dataNascimento))
            {
                Task.Factory.StartNew(() => messageQueue.Enqueue("Perfil atualizado com sucesso!"));
                return;
            }
            else
            {
                Task.Factory.StartNew(() => messageQueue.Enqueue("Erro ao atualizar perfil, tente novamente!"));
                return;
            }
        }
Example #2
0
        private void ButtonSalvar_Click(object sender, RoutedEventArgs e)
        {
            var messageQueue = SnackbarThree.MessageQueue;

            DateTime dataNascimento;
            String   nome  = TextBoxNome.Text;
            String   cpf   = TextBoxCpf.Text;
            String   senha = TextBoxSenha.Password;

            if (String.IsNullOrEmpty(nome))
            {
                TextBoxNome.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Nome não informado."));
                return;
            }

            if (String.IsNullOrEmpty(cpf))
            {
                TextBoxCpf.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("CPF não informado."));
                return;
            }

            if (String.IsNullOrEmpty(senha))
            {
                TextBoxSenha.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Senha não informada."));
                return;
            }

            if (String.IsNullOrEmpty(TextBoxConfirmaSenha.Password) || TextBoxConfirmaSenha.Password != senha)
            {
                TextBoxConfirmaSenha.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Confirmação diferente da senha informada!"));
                return;
            }

            if (DatePickerNascimento.SelectedDate == null)
            {
                DatePickerNascimento.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Data de nascimento não informada."));
                return;
            }
            else
            {
                dataNascimento = DatePickerNascimento.SelectedDate.Value;
            }

            if (control.Cadastrar(TextBoxNome.Text, TextBoxCpf.Text, TextBoxSenha.Password, dataNascimento))
            {
                Voltar();
            }
            else
            {
                Task.Factory.StartNew(() => messageQueue.Enqueue("Erro no cadastro, tente novamente!"));
            }
        }