Example #1
0
        private void Login()
        {
            var messageQueue = SnackbarThree.MessageQueue;

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

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

            if (control.Logar(TextBoxCpf.Text, TextBoxSenha.Password))
            {
                Dashboard dash = new Dashboard();
                dash.Show();
                this.Close();
            }
            else
            {
                Task.Factory.StartNew(() => messageQueue.Enqueue("CPF ou senha incorreto"));
            }
        }
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!"));
            }
        }