Example #1
0
        public int CadastraFuncao(Funcao f)
        {
            String sql = "INSERT INTO funcao ([nome], [nivelAcesso]) VALUES " +
                         "(@nome, @nivelAcesso)";
            int result;

            SqlConnection conn   = new SqlConnection(strConnection);
            SqlCommand    sqlcmd = new SqlCommand(sql, conn);

            sqlcmd.Parameters.AddWithValue("@nivelAcesso", f.GetNivelAcesso());
            sqlcmd.Parameters.AddWithValue("@nome", f.GetNome());

            try
            {
                conn.Open();
                result = sqlcmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
            return(result);
        }
Example #2
0
        public int EditarFuncao(Funcao f)
        {
            string sql    = "UPDATE funcao SET nivelAcesso = @nivelAcesso, nome = @nome WHERE codFuncao = @codigo;";
            int    result = 0;

            SqlConnection conn   = new SqlConnection(strConnection);
            SqlCommand    sqlcmd = new SqlCommand(sql, conn);

            sqlcmd.Parameters.AddWithValue("@codigo", f.GetCodFuncao());
            sqlcmd.Parameters.AddWithValue("@nivelAcesso", f.GetNivelAcesso());
            sqlcmd.Parameters.AddWithValue("@nome", f.GetNome());

            try
            {
                conn.Open();
                result = sqlcmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
            return(result);
        }