예제 #1
0
        public void Update(CadastroMenu menu)
        {
            try {
                SqlCommand comando = new SqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText = "UPDATE Menu SET nome=@nome, url=@url, ordem=@ordem,codigoPai=@codigoPai WHERE id=@menuId ";

                comando.Parameters.AddWithValue("@nome", menu.nome);
                comando.Parameters.AddWithValue("@url", menu.url);
                comando.Parameters.AddWithValue("@ordem", menu.ordem);

                comando.Parameters.AddWithValue("@codigoPai", menu.codigoPai);
                comando.Parameters.AddWithValue("@menuId", menu.id);

                ConexaoBanco.CRUD(comando);
            } catch {
                throw;
            }
        }
예제 #2
0
        public void Insert(Historico historico, String mensagem) // responsavel por inserir um historico(Log) de alterações no sistema em uma tabela
        {
            try {
                SqlCommand comando = new SqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText = "INSERT INTO Historico (dataHora, usuario_fk,mensagem) " +
                                      "values(@dataHora,@usuario_fk,@mensagem)  ";

                comando.Parameters.AddWithValue("@dataHora", historico.dataHora);
                comando.Parameters.AddWithValue("@usuario_fk", historico.usuario.id);
                comando.Parameters.AddWithValue("@mensagem", mensagem);

                ConexaoBanco.CRUD(comando);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        public void Excluir(int idLink, int idGrupo) // exclui associação entre grupo e links/itens de menu
        {
            try
            {
                SqlCommand comando = new SqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText = "DELETE FROM [ExtranetFenix].[dbo].[grupoXMenu] where [ExtranetFenix].[dbo].[grupoXMenu].grupoUsuario_fk = @idGrupo and [ExtranetFenix].[dbo].[grupoXMenu].Menu_fk = @idLink";



                comando.Parameters.AddWithValue("@idLink", idLink);
                comando.Parameters.AddWithValue("@idGrupo", idGrupo);

                ConexaoBanco.CRUD(comando);
            }
            catch
            {
                throw;
            }
        }
예제 #4
0
        public void Update(Usuario usuario)
        {
            SqlCommand comando = new SqlCommand();

            comando.CommandType = CommandType.Text;
            comando.CommandText = "UPDATE usuario SET nome=@nome,cargo=@cargo,usuarioLogin=@usuarioLogin,senha=@senha," +
                                  "centroCusto=@centroCusto, email=@email, bU=@bU, setor=@setor,situacao=@situacao WHERE id=@id ";

            comando.Parameters.AddWithValue("@nome", usuario.nome);
            comando.Parameters.AddWithValue("@cargo", usuario.cargo);
            comando.Parameters.AddWithValue("@usuarioLogin", usuario.usuarioLogin);
            comando.Parameters.AddWithValue("@senha", usuario.senha);
            comando.Parameters.AddWithValue("@centroCusto", usuario.centroCusto);
            comando.Parameters.AddWithValue("@email", usuario.email);
            comando.Parameters.AddWithValue("@bU", usuario.bU);
            comando.Parameters.AddWithValue("@setor", usuario.setor);
            comando.Parameters.AddWithValue("@situacao", usuario.situacao);

            ConexaoBanco.CRUD(comando);
        }
예제 #5
0
        public int Insert(Anexo anexo) // insere dados na tabela anexo retornando um ID
        {
            SqlConnection conn    = new SqlConnection();
            SqlCommand    comando = new SqlCommand();

            comando.CommandType = CommandType.Text;
            comando.CommandText = "INSERT INTO anexo (nome,arquivo,tipoArquivo) values(@nome,@arquivo,@tipoArquivo); SELECT CAST(scope_identity() AS int);";

            comando.Parameters.AddWithValue("@nome", anexo.nome);
            comando.Parameters.AddWithValue("@arquivo", anexo.arquivo);
            comando.Parameters.AddWithValue("@tipoArquivo", anexo.tipoArquivo);

            conn = ConexaoBanco.Conectar();
            comando.Connection = conn;
            int id = (Int32)comando.ExecuteScalar();


            ConexaoBanco.CRUD(comando);

            return(id);
        }
예제 #6
0
        public void Gravar(List <int> listaDeLinks, int idGrupo) // grava associação entra grupo de usuairio e os links que esse grupo pode acessar
        {
            try {
                SqlCommand comando = new SqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText = "INSERT INTO [ExtranetFenix].[dbo].[grupoXMenu] (grupoUsuario_fk,Menu_fk) VALUES (@idGrupo,@idLink)";

                foreach (int x in listaDeLinks)
                {
                    comando.Parameters.AddWithValue("@idLink", x);
                    comando.Parameters.AddWithValue("@idGrupo", idGrupo);

                    ConexaoBanco.CRUD(comando);

                    comando.Parameters.Clear();
                }
            }
            catch  {
                throw;
            }
        }
예제 #7
0
        public void PublicarRascunho(int id) // ativa uma postagem que esta em modo rascunho para ser publicada
        {
            try
            {
                Postagem postagem = new Postagem();
                postagem.rascunho = 0;
                SqlConnection conn    = new SqlConnection();
                SqlCommand    comando = new SqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText = "UPDATE  postagem set rascunho=@rascunho WHERE postagem.id = @id ";

                comando.Parameters.AddWithValue("@rascunho", postagem.rascunho);
                comando.Parameters.AddWithValue("@id", id);

                ConexaoBanco.CRUD(comando);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #8
0
        public void Insert(Curriculo curriculo, DateTime dataEnvio)  //insere um curriculo na tabela curriculo
        {
            try
            {
                SqlCommand comando = new SqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText = "INSERT INTO[ExtranetFenix].[dbo].[curriculo] ([nome],[cpf],[dataNascimento],[uf],[cep],[cidade],[bairro],[rua],[numero],[descricao],[telefoneFixo]" +
                                      ",[telefoneCelular],[email],[siteBlog],[skype],[remuneracao],[genero],[areaPretendida_fk],[estadoCivil_fk],[anexo_fk],[dataEnvio]) VALUES" +
                                      "(@nome,@cpf,@dataNascimento,@uf,@cep,@cidade,@bairro,@rua,@numero,@descricao,@telefoneFixo,@telefoneCelular,@email,@siteBlog,@skype,@remuneracao,@genero,@areaPretendida_fk,@estadoCivil_fk,@anexo_fk,@dataEnvio)";

                comando.Parameters.AddWithValue("@nome", curriculo.nome);
                comando.Parameters.AddWithValue("@cpf", curriculo.cpf);
                comando.Parameters.AddWithValue("@dataNascimento", curriculo.dataNascimento);
                comando.Parameters.AddWithValue("@uf", curriculo.uf);
                comando.Parameters.AddWithValue("@cep", curriculo.cep);
                comando.Parameters.AddWithValue("@cidade", curriculo.cidade);
                comando.Parameters.AddWithValue("@bairro", curriculo.bairro);
                comando.Parameters.AddWithValue("@rua", curriculo.rua);
                comando.Parameters.AddWithValue("@numero", curriculo.numero);
                comando.Parameters.AddWithValue("@descricao", curriculo.descricao);
                comando.Parameters.AddWithValue("@telefoneFixo", curriculo.telefoneFixo);
                comando.Parameters.AddWithValue("@telefoneCelular", curriculo.telefoneCelular);
                comando.Parameters.AddWithValue("@email", curriculo.email);
                comando.Parameters.AddWithValue("@siteBlog", curriculo.siteBlog);
                comando.Parameters.AddWithValue("@skype", curriculo.skype);
                comando.Parameters.AddWithValue("@remuneracao", curriculo.remuneracao);
                comando.Parameters.AddWithValue("@genero", curriculo.genero);
                comando.Parameters.AddWithValue("@areaPretendida_fk", curriculo.area.id);
                comando.Parameters.AddWithValue("@estadoCivil_fk", curriculo.estado.id);

                comando.Parameters.AddWithValue("@anexo_fk", curriculo.anexo.id);
                comando.Parameters.AddWithValue("@dataEnvio", dataEnvio);

                ConexaoBanco.CRUD(comando);
            }
            catch
            {
                throw;
            }
        }
예제 #9
0
        public void Delete(int id)
        {
            Postagem rascunho = new Postagem();
            Imagem   img      = new Imagem();
            ImagemBO imgBO    = new ImagemBO();

            SqlConnection conn    = new SqlConnection();
            SqlCommand    comando = new SqlCommand();

            comando.CommandType = CommandType.Text;

            comando.CommandText = "Delete imagem from imagem left join postagem on postagem.id = imagem.postagem_fk" +
                                  " where imagem.postagem_fk = @id ";
            comando.Parameters.AddWithValue("@id", id);

            ConexaoBanco.CRUD(comando);

            comando.CommandText = "DELETE postagem FROM postagem WHERE id=@id;";
            comando.Parameters.AddWithValue("@postagemId", id);

            ConexaoBanco.CRUD(comando);
        }
예제 #10
0
        public void Gravar(int idUsuario, List <int> listaDeGrupos) // grava a associação de usuario com um ou mais grupos
        {
            try
            {
                SqlCommand comando = new SqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText = "INSERT INTO UsuarioXGrupo(usuario_fk,grupoUsuario_fk) VALUES (@idUsuario,@idGrupo)";

                foreach (int x in listaDeGrupos)
                {
                    comando.Parameters.AddWithValue("@idUsuario", idUsuario);
                    comando.Parameters.AddWithValue("@idGrupo", x);

                    ConexaoBanco.CRUD(comando);

                    comando.Parameters.Clear();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #11
0
        public void Update(GrupoUsuario perfil)
        {
            try
            {
                SqlCommand comando = new SqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText = "UPDATE grupoUsuario SET nome=@nome,descricao=@descricao,graficoUrl=@graficoUrl,privilegios=@privilegios WHERE Id=@id ";


                comando.Parameters.AddWithValue("@nome", perfil.nome);
                comando.Parameters.AddWithValue("@descricao", perfil.descricao);
                comando.Parameters.AddWithValue("@graficoUrl", perfil.graficoUrl);
                comando.Parameters.AddWithValue("@privilegios", perfil.privilegios);
                comando.Parameters.AddWithValue("@id", perfil.id);
                // this.updatelistaUsuarioPerfil(comando, perfil);

                ConexaoBanco.CRUD(comando);
            }
            catch
            {
                throw;
            }
        }
예제 #12
0
        public void Delete(int id)
        {
            try {
                SqlCommand comando = new SqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText = "DELETE [ExtranetFenix].[dbo].[grupoXMenu] WHERE Menu_fk = @menuId";

                comando.Parameters.AddWithValue("@menuId", id);
                ConexaoBanco.CRUD(comando);

                comando.Dispose();


                comando             = new SqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText = "DELETE FROM Menu WHERE id=@menuId ";

                comando.Parameters.AddWithValue("@menuId", id);
                ConexaoBanco.CRUD(comando);
            } catch  {
                throw;
            }
        }