示例#1
0
 public TipoDestino_TO GetByCode(TipoDestino_TO pTO)
 {
     try
     {
         return(new TipoDestino_DAO().GetByCode(pTO));
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#2
0
        internal bool Save(TipoDestino_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_tipo_destino" +
                         " ( tde_codigo " +
                         ", tde_nome " +
                         ", tde_descricao " +
                         ", tde_e_cidade) " +
                         "VALUES " +
                         "( @tde_codigo " +
                         " , @tde_nome " +
                         " , @tde_descricao " +
                         " , @tde_e_cidade ) ";

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

            return(retorno);
        }
示例#3
0
        public bool Delete(TipoDestino_TO pTO)
        {
            bool retorno = false;

            try
            {
                retorno = new TipoDestino_DAO().Delete(pTO);
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
示例#4
0
        internal List <TipoDestino_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_tipo_destino ";

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

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

                while (reader.Read())
                {
                    TipoDestino_TO TipoDestinoTO = new TipoDestino_TO();
                    TipoDestinoTO.tde_codigo    = Convert.ToInt32(reader["tde_codigo"]);
                    TipoDestinoTO.tde_nome      = Convert.ToString(reader["tde_nome"]);
                    TipoDestinoTO.tde_descricao = Convert.ToString(reader["tde_descricao"]);
                    TipoDestinoTO.tde_e_cidade  = Convert.ToInt32(reader["tde_e_cidade"]);
                    collection.Add(TipoDestinoTO);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                reader.Close();
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }
            return(collection);
        }
示例#5
0
        public List <TipoDestino_TO> SearchAll(TipoDestino_TO pTO)
        {
            string condicao = "";

            try
            {
// implementa a condição de procura
                condicao += "";
                return(new TipoDestino_DAO().SearchAll(condicao));
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#6
0
        internal TipoDestino_TO GetByCode(TipoDestino_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_tipo_destino ";

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

                reader = command.ExecuteReader();

                if (reader.Read())
                {
                    pTO.tde_codigo    = Convert.ToInt32(reader["tde_codigo"]);
                    pTO.tde_nome      = Convert.ToString(reader["tde_nome"]);
                    pTO.tde_descricao = Convert.ToString(reader["tde_descricao"]);
                    pTO.tde_e_cidade  = Convert.ToInt32(reader["tde_e_cidade"]);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                reader.Close();
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }

            return(pTO);
        }
示例#7
0
        public bool Save(bool pOpcao, TipoDestino_TO pTO)
        {
            bool retorno = false;

            try
            {
                if (pOpcao)
                {
                    retorno = new TipoDestino_DAO().Save(pTO);
                }
                else
                {
                    retorno = new TipoDestino_DAO().Update(pTO);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
示例#8
0
        internal bool Delete(TipoDestino_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_tipo_destino" +
                         "WHERE ... ";

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

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

            return(retorno);
        }