Beispiel #1
0
        internal bool Save(Instrutor_TO pTO)
        {
            SqlConnection connection = null;

            try
            {
                connection = new SqlConnection(ConfigurationSettings.AppSettings["conn_bdvveasycomp"]);
                connection.Open();
            }
            catch (Exception)
            {
                throw;
            }

            SqlCommand command = null;
            bool       retorno = false;

            string sql = "INSERT INTO instrutor" +
                         "( ins_rg " +
                         ", ins_nome " +
                         ", ins_descricao " +
                         ", ins_data_nascimento " +
                         ", ins_email " +
                         ", ins_telefone) " +
                         "VALUES " +
                         "(  @ins_rg " +
                         " , @ins_nome " +
                         " , @ins_descricao " +
                         " , @ins_data_nascimento " +
                         " , @ins_email " +
                         " , @ins_telefone ) ";

            try
            {
                command = new SqlCommand(sql, connection);
                command.Parameters.AddWithValue("@ins_rg", pTO.ins_rg);
                command.Parameters.AddWithValue("@ins_nome", pTO.ins_nome);
                command.Parameters.AddWithValue("@ins_descricao", pTO.ins_descricao);
                command.Parameters.AddWithValue("@ins_data_nascimento", pTO.ins_data_nascimento);
                command.Parameters.AddWithValue("@ins_email", pTO.ins_email);
                command.Parameters.AddWithValue("@ins_telefone", pTO.ins_telefone);
                command.ExecuteNonQuery();
                retorno = true;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }

            return(retorno);
        }
Beispiel #2
0
 public Instrutor_TO GetByCode(Instrutor_TO pTO)
 {
     try
     {
         return(new Instrutor_DAO().GetByCode(pTO));
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #3
0
        internal List <Instrutor_TO> SearchAll(string pCondicao)
        {
            SqlConnection connection = null;

            try
            {
                connection = new SqlConnection(ConfigurationSettings.AppSettings["conn_bdvveasycomp"]);
                connection.Open();
            }
            catch (Exception)
            {
                throw;
            }

            SqlCommand    command = null;
            SqlDataReader reader  = null;

            string sql = " SELECT * FROM instrutor ";

            List <Instrutor_TO> collection = new List <Instrutor_TO>();

            try
            {
                command = new SqlCommand(sql, connection);
                reader  = command.ExecuteReader();

                while (reader.Read())
                {
                    Instrutor_TO InstrutorTO = new Instrutor_TO();
                    InstrutorTO.ins_codigo          = Convert.ToInt32(reader["ins_codigo"]);
                    InstrutorTO.ins_rg              = Convert.ToInt32(reader["ins_rg"]);
                    InstrutorTO.ins_nome            = Convert.ToString(reader["ins_nome"]);
                    InstrutorTO.ins_descricao       = Convert.ToString(reader["ins_descricao"]);
                    InstrutorTO.ins_data_nascimento = Convert.ToDateTime(reader["ins_data_nascimento"]);
                    InstrutorTO.ins_email           = Convert.ToString(reader["ins_email"]);
                    InstrutorTO.ins_telefone        = Convert.ToInt32(reader["ins_telefone"]);
                    collection.Add(InstrutorTO);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                reader.Close();
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }
            return(collection);
        }
Beispiel #4
0
        internal Instrutor_TO GetByCode(Instrutor_TO pTO)
        {
            SqlConnection connection = null;

            try
            {
                connection = new SqlConnection(ConfigurationSettings.AppSettings["conn_bdvveasycomp"]);
                connection.Open();
            }
            catch (Exception)
            {
                throw;
            }
            SqlCommand    command = null;
            SqlDataReader reader  = null;

            string sql = " SELECT * FROM instrutor " +
                         "WHERE  ins_codigo = @ins_codigo ";

            try
            {
                command = new SqlCommand(sql, connection);

                command.Parameters.AddWithValue("@ins_codigo", pTO.ins_codigo);
                reader = command.ExecuteReader();

                if (reader.Read())
                {
                    pTO.ins_codigo          = Convert.ToInt32(reader["ins_codigo"]);
                    pTO.ins_rg              = Convert.ToInt32(reader["ins_rg"]);
                    pTO.ins_nome            = Convert.ToString(reader["ins_nome"]);
                    pTO.ins_descricao       = Convert.ToString(reader["ins_descricao"]);
                    pTO.ins_data_nascimento = Convert.ToDateTime(reader["ins_data_nascimento"]);
                    pTO.ins_email           = Convert.ToString(reader["ins_email"]);
                    pTO.ins_telefone        = Convert.ToInt32(reader["ins_telefone"]);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                reader.Close();
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }

            return(pTO);
        }
Beispiel #5
0
        public bool Delete(Instrutor_TO pTO)
        {
            bool retorno = false;

            try
            {
                retorno = new Instrutor_DAO().Delete(pTO);
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
Beispiel #6
0
        public List <Instrutor_TO> SearchAll(Instrutor_TO pTO)
        {
            string condicao = "";

            try
            {
                // implementa a condição de procura
                condicao += "";
                return(new Instrutor_DAO().SearchAll(condicao));
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #7
0
        public bool Save(Instrutor_TO pTO, bool novo)
        {
            bool retorno = false;

            try
            {
                if (novo)
                {
                    retorno = new Instrutor_DAO().Save(pTO);
                }
                else
                {
                    retorno = new Instrutor_DAO().Update(pTO);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
Beispiel #8
0
        internal bool Delete(Instrutor_TO pTO)
        {
            SqlConnection connection = null;

            try
            {
                connection = new SqlConnection(ConfigurationSettings.AppSettings["conn_bdvveasycomp"]);
                connection.Open();
            }
            catch (Exception)
            {
                throw;
            }

            SqlCommand command = null;
            bool       retorno = false;

            string sql = "DELETE FROM instrutor WHERE ins_codigo = @ins_codigo ";

            try
            {
                command = new SqlCommand(sql, connection);
                command.Parameters.AddWithValue("@ins_codigo", pTO.ins_codigo);
                command.ExecuteNonQuery();
                retorno = true;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }

            return(retorno);
        }