Beispiel #1
0
        //Metodo excluir
        public static string Deletar(int Idapresentacao)
        {
            DApresentacao OBJ = new CamadaDados.DApresentacao();

            OBJ.Idapresentacao = Idapresentacao;
            return(OBJ.Deletar(OBJ));
        }
        //Método Buscar Nome
        public DataTable BuscarNome(DApresentacao Apresentacao)
        {
            DataTable     DtResultado = new DataTable("apresentacao");
            SqlConnection SqlCon      = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = Conexao.Cn;
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "spbuscar_apresentacao_nome";
                SqlCmd.CommandType = CommandType.StoredProcedure;


                SqlParameter ParTextoBuscar = new SqlParameter();
                ParTextoBuscar.ParameterName = "@textobuscar";
                ParTextoBuscar.SqlDbType     = SqlDbType.VarChar;
                ParTextoBuscar.Size          = 50;
                ParTextoBuscar.Value         = Apresentacao.TextoBuscar;
                SqlCmd.Parameters.Add(ParTextoBuscar);

                SqlDataAdapter sqlDat = new SqlDataAdapter(SqlCmd);
                sqlDat.Fill(DtResultado);
            }
            catch (Exception ex)
            {
                DtResultado = null;
            }
            return(DtResultado);
        }
Beispiel #3
0
        //Metodo Buscar Texto
        public static DataTable BuscarNome(String textobuscar)
        {
            DApresentacao OBJ = new CamadaDados.DApresentacao();

            OBJ.TextoBuscar = textobuscar;
            return(OBJ.BuscarNome(OBJ));
        }
        //metodo Excluir
        public static string Excluir(int idapresentacao)
        {
            DApresentacao Obj = new CamadaDados.DApresentacao();

            Obj.Idapresentacao = idapresentacao;

            return(Obj.Excluir(Obj));
        }
Beispiel #5
0
        //Método Inserir
        public static string Inserir(string nome, string descricao)
        {
            DApresentacao Obj = new CamadaDados.DApresentacao();

            Obj.Nome      = nome;
            Obj.Descricao = descricao;
            return(Obj.Inserir(Obj));
        }
Beispiel #6
0
        // Método Buscar Nome
        public static DataTable ConsultarPorNome(string textobuscar)
        {
            DApresentacao Obj = new CamadaDados.DApresentacao();

            Obj.TextoBuscar = textobuscar;

            return(Obj.ConsultarPorNome(Obj));
        }
Beispiel #7
0
        //Método Editar
        public static string Editar(int idapresentacao, string nome, string descricao)
        {
            DApresentacao Obj = new CamadaDados.DApresentacao();

            Obj.Idapresentacao = idapresentacao;
            Obj.Nome           = nome;
            Obj.Descricao      = descricao;
            return(Obj.Editar(Obj));
        }
Beispiel #8
0
        //Metodo editar
        public static string Editar(int Idapresentacao, string nome, string descricao)
        {
            DApresentacao OBJ = new CamadaDados.DApresentacao();

            OBJ.Idapresentacao = Idapresentacao;
            OBJ.Nome           = nome;
            OBJ.Descricao      = descricao;
            return(OBJ.Editar(OBJ));
        }
Beispiel #9
0
        // Método Inserir
        public string Inserir(DApresentacao Apresentacao)
        {
            string resp = "";

            SqlConnection SqlCon = new SqlConnection();

            try
            {
                // código inserção
                SqlCon.ConnectionString = Conexao.con;
                SqlCon.Open();

                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "spinserir_apresentacao";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParIdapresentacao = new SqlParameter();
                ParIdapresentacao.ParameterName = "@idapresentacao";
                ParIdapresentacao.SqlDbType     = SqlDbType.Int;
                ParIdapresentacao.Direction     = ParameterDirection.Output;
                SqlCmd.Parameters.Add(ParIdapresentacao);

                SqlParameter ParNome = new SqlParameter();
                ParNome.ParameterName = "@nome";
                ParNome.SqlDbType     = SqlDbType.VarChar;
                ParNome.Size          = 50;
                ParNome.Value         = Apresentacao.Nome;
                SqlCmd.Parameters.Add(ParNome);

                SqlParameter ParDescricao = new SqlParameter();
                ParDescricao.ParameterName = "@descricao";
                ParDescricao.SqlDbType     = SqlDbType.VarChar;
                ParDescricao.Size          = 50;
                ParDescricao.Value         = Apresentacao.Descricao;
                SqlCmd.Parameters.Add(ParDescricao);

                // Executar o comando

                resp = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "Registro não foi inserido";
            }
            catch (Exception ex)
            {
                // mensagem de erro
                resp = ex.Message;
            }

            finally
            {
                if (SqlCon.State == ConnectionState.Open)
                {
                    SqlCon.Close();
                }
            }

            return(resp);
        }
        //Método Editar
        public string Editar(DApresentacao Apresentacao)
        {
            string        resp   = "";
            SqlConnection SqlCon = new SqlConnection();

            try
            {
                //codigo
                SqlCon.ConnectionString = Conexao.Cn;
                SqlCon.Open();

                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "speditar_apresentacao";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParIdapresentacao = new SqlParameter();
                ParIdapresentacao.ParameterName = "@idapresentacao";
                ParIdapresentacao.SqlDbType     = SqlDbType.Int;
                ParIdapresentacao.Value         = Apresentacao.Idapresentacao;
                SqlCmd.Parameters.Add(ParIdapresentacao);


                SqlParameter ParNome = new SqlParameter();
                ParNome.ParameterName = "@nome";
                ParNome.SqlDbType     = SqlDbType.VarChar;
                ParNome.Size          = 50;
                ParNome.Value         = Apresentacao.Nome;
                SqlCmd.Parameters.Add(ParNome);


                SqlParameter ParDescricao = new SqlParameter();
                ParDescricao.ParameterName = "@descricao";
                ParDescricao.SqlDbType     = SqlDbType.VarChar;
                ParDescricao.Size          = 256;
                ParDescricao.Value         = Apresentacao.Descricao;
                SqlCmd.Parameters.Add(ParDescricao);

                //Executar o comando

                resp = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "A edição não foi feita";
            }
            catch (Exception ex)
            {
                resp = ex.Message;
            }

            finally
            {
                if (SqlCon.State == ConnectionState.Open)
                {
                    SqlCon.Close();
                }
            }
            return(resp);
        }
Beispiel #11
0
        // Método Excluir
        public string Excluir(DApresentacao Apresentacao)
        {
            string resp = "";

            SqlConnection SqlCon = new SqlConnection();

            try
            {
                // código exclusão
                SqlCon.ConnectionString = Conexao.con;
                SqlCon.Open();

                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "spdeletar_apresentacao";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParIdapresentacao = new SqlParameter();
                ParIdapresentacao.ParameterName = "@idapresentacao";
                ParIdapresentacao.SqlDbType     = SqlDbType.Int;
                ParIdapresentacao.Value         = Apresentacao.Idapresentacao;
                SqlCmd.Parameters.Add(ParIdapresentacao);

                // Executar o comando

                resp = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "A exclusão não foi concluída!";
            }
            catch (Exception ex)
            {
                // mensagem de erro
                resp = ex.Message;
            }

            finally
            {
                if (SqlCon.State == ConnectionState.Open)
                {
                    SqlCon.Close();
                }
            }
            return(resp);
        }
Beispiel #12
0
        public DataTable ConsultarPorNome(DApresentacao Apresentacao)
        {
            DataTable     DtResultado = new DataTable("apresentacao");
            SqlConnection SqlCon      = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = Conexao.con;
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "spconsultar_nome_apresentacao";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                // quando precisar guardar informações de consulta e exibir em tabelas
                // listbox, use um DataAdapter

                SqlParameter ParTextoBuscar = new SqlParameter();
                ParTextoBuscar.ParameterName = "@textobuscar";
                ParTextoBuscar.SqlDbType     = SqlDbType.VarChar;
                ParTextoBuscar.Size          = 50;
                ParTextoBuscar.Value         = Apresentacao.TextoBuscar;
                SqlCmd.Parameters.Add(ParTextoBuscar);

                SqlDataAdapter SqlData = new SqlDataAdapter(SqlCmd);
                SqlData.Fill(DtResultado);
            }
            catch (Exception)
            {
                DtResultado = null;
            }

            //finally
            //{
            //    if (SqlCon.State == ConnectionState.Open)
            //        SqlCon.Close();
            //}

            return(DtResultado);
        }