private void button_Copy1_Click(object sender, RoutedEventArgs e) { storyboard = this.FindResource("Login") as Storyboard; // ANIMAÇÃO 2 storyboard.Begin(); TabUsers = new Framework.Login.DadosModel(); foreach (var user in TabUsers.users) { if ((tb_usuario.Text == string.Empty) || (tb_senha.Password == string.Empty)) { MessageBox.Show("Preencha todos os campos antes de continuar", "Atenção", MessageBoxButton.OK, MessageBoxImage.Error); storyboard.Remove(); return; } else if ((tb_usuario.Text == user.usuario) && (Crypt.md5(tb_senha.Password) == user.senha)) { MessageBox.Show("Login realizado com sucesso, " + user.usuario, "Info", MessageBoxButton.OK, MessageBoxImage.Information); principal = new Principal(user.nome, user.Id_users, user.level); principal.Show(); UsuarioNome = user.nome; this.Close(); storyboard.Remove(); return; } } }
private void btnCadastrarNovoUser_Click(object sender, RoutedEventArgs e) { Cad = new Framework.Login.DadosModel(); if (tb_nomeCadastro.Text == string.Empty || tb_usuarioCadastro.Text == string.Empty || tb_senhaCadastro.Password == string.Empty || tb_cpfCadastro.Text == string.Empty || cb_permissaoCadastro.SelectedIndex == -1) { MessageBox.Show("Tente preencher todos os campos antes de clicar em Cadastrar novamente! :P", "Algo Errado!!!", MessageBoxButton.OK, MessageBoxImage.Error); } else { Cad.users.Add(new Framework.Login.users { nome = tb_nomeCadastro.Text, usuario = tb_usuarioCadastro.Text, senha = Crypt.md5(tb_senhaCadastro.Password), cpf = tb_cpfCadastro.Text, level = cb_permissaoCadastro.SelectedIndex }); Cad.SaveChanges(); tb_nomeCadastro.Text = ""; tb_usuarioCadastro.Text = ""; tb_senhaCadastro.Password = ""; tb_cpfCadastro.Text = ""; cb_permissaoCadastro.SelectedIndex = -1; MessageBox.Show("Usuário " + tb_nomeCadastro.Text + " cadastrado!\nVocê já pode fazer login.", "Legal!!!", MessageBoxButton.OK, MessageBoxImage.Information); } }// FIM EVENTO PARA CADASTRAR