예제 #1
0
 public Pais_TO GetByCode(Pais_TO pTO)
 {
     try
     {
         return(new Pais_DAO().GetByCode(pTO));
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #2
0
        public bool Delete(Pais_TO pTO)
        {
            bool retorno = false;

            try
            {
                retorno = new Pais_DAO().Delete(pTO);
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
예제 #3
0
        public List <Pais_TO> SearchAll(Pais_TO pTO)
        {
            string condicao = "";

            try
            {
// implementa a condição de procura
                condicao += "";
                return(new Pais_DAO().SearchAll(condicao));
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #4
0
        internal List <Pais_TO> SearchAll(string pCondicao)
        {
            SqlConnection connection = null;

            try
            {
                connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString);
                connection.Open();
            }
            catch (Exception)
            {
                throw;
            }

            SqlCommand    command = null;
            SqlDataReader reader  = null;

            string sql = " SELECT * FROM vcrm_pais ";

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

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

                while (reader.Read())
                {
                    Pais_TO PaisTO = new Pais_TO();
                    PaisTO.pai_codigo     = Convert.ToInt32(reader["pai_codigo"]);
                    PaisTO.pai_nome       = Convert.ToString(reader["pai_nome"]);
                    PaisTO.pai_continente = Convert.ToString(reader["pai_continente"]);
                    collection.Add(PaisTO);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                reader.Close();
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }
            return(collection);
        }
예제 #5
0
        internal bool Save(Pais_TO pTO)
        {
            SqlConnection connection = null;

            try
            {
                connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString);
                connection.Open();
            }
            catch (Exception)
            {
                throw;
            }

            SqlCommand command = null;
            bool       retorno = false;

            string sql = "INSERT INTO vcrm_pais" +
                         " ( pai_codigo " +
                         ", pai_nome " +
                         ", pai_continente) " +
                         "VALUES " +
                         "( @pai_codigo " +
                         " , @pai_nome " +
                         " , @pai_continente ) ";

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

            return(retorno);
        }
예제 #6
0
        internal Pais_TO GetByCode(Pais_TO pTO)
        {
            SqlConnection connection = null;

            try
            {
                connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString);
                connection.Open();
            }
            catch (Exception)
            {
                throw;
            }
            SqlCommand    command = null;
            SqlDataReader reader  = null;

            string sql = " SELECT * FROM vcrm_pais ";

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

                reader = command.ExecuteReader();

                if (reader.Read())
                {
                    pTO.pai_codigo     = Convert.ToInt32(reader["pai_codigo"]);
                    pTO.pai_nome       = Convert.ToString(reader["pai_nome"]);
                    pTO.pai_continente = Convert.ToString(reader["pai_continente"]);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                reader.Close();
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }

            return(pTO);
        }
예제 #7
0
        public bool Save(bool pOpcao, Pais_TO pTO)
        {
            bool retorno = false;

            try
            {
                if (pOpcao)
                {
                    retorno = new Pais_DAO().Save(pTO);
                }
                else
                {
                    retorno = new Pais_DAO().Update(pTO);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
예제 #8
0
        internal bool Delete(Pais_TO pTO)
        {
            SqlConnection connection = null;

            try
            {
                connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString);
                connection.Open();
            }
            catch (Exception)
            {
                throw;
            }

            SqlCommand command = null;
            bool       retorno = false;

            string sql = "DELETE FROM vcrm_pais" +
                         "WHERE ... ";

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

                command.ExecuteNonQuery();
                retorno = true;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }

            return(retorno);
        }