Exemple #1
0
 public static void CadastrarFuncionario(FuncionarioBean bean)
 {
     try
     {
         Conexao.Conectar();
         string     qryVerifica = "SELECT COUNT(ID_FUNC) FROM USUARIO WHERE RE = @re";
         SqlCommand comando     = new SqlCommand(qryVerifica, Conexao.conexao);
         comando.Parameters.AddWithValue("@re", bean.Re);
         SqlDataReader reader = comando.ExecuteReader();
         if (reader.Read() == true)
         {
             reader.Close();
             string     qry = "INSERT INTO Usuario(Nome, RE, senha, permissao) values(@nome, @re, @senha, @permissao)";
             SqlCommand cmd = new SqlCommand(qry, Conexao.conexao);
             cmd.Parameters.AddWithValue("@nome", bean.Nome);
             cmd.Parameters.AddWithValue("@re", bean.Re);
             cmd.Parameters.AddWithValue("@senha", Encriptografar.Encripto(bean.Senha));
             cmd.Parameters.AddWithValue("@permissao", bean.Permissao);
             cmd.ExecuteNonQuery();
         }
         Conexao.Desconectar();
     }
     catch (SqlException e)
     {
         System.Windows.MessageBox.Show(e.Message);
     }
 }
Exemple #2
0
        private void btnCadastrar_Click(object sender, RoutedEventArgs e)
        {
            FuncionarioBean bean = new FuncionarioBean();

            bean.Nome      = txtNome.Text;
            bean.Re        = txtRE.Text;
            bean.Senha     = Encriptografar.Encripto(pswSenha.Password);
            bean.Permissao = permissao;
            FuncionarioDAO.CadastrarFuncionario(bean);
            this.Close();
            TelaInicial telaInicial = new TelaInicial();

            telaInicial.Show();
        }