Exemple #1
0
 public Status_TO GetByCode(Status_TO pTO)
 {
     try
     {
         return(new Status_DAO().GetByCode(pTO));
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #2
0
        public bool Delete(Status_TO pTO)
        {
            bool retorno = false;

            try
            {
                retorno = new Status_DAO().Delete(pTO);
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
Exemple #3
0
        public List <Status_TO> SearchAll(Status_TO pTO)
        {
            string condicao = "";

            try
            {
// implementa a condição de procura
                condicao += "";
                return(new Status_DAO().SearchAll(condicao));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #4
0
        internal List <Status_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_status ";

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

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

                while (reader.Read())
                {
                    Status_TO StatusTO = new Status_TO();
                    StatusTO.sta_codigo = Convert.ToInt32(reader["sta_codigo"]);
                    StatusTO.sta_nome   = Convert.ToString(reader["sta_nome"]);
                    StatusTO.sta_final  = Convert.ToInt32(reader["sta_final"]);
                    collection.Add(StatusTO);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                reader.Close();
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }
            return(collection);
        }
Exemple #5
0
        internal bool Save(Status_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_status" +
                         " ( sta_codigo " +
                         ", sta_nome " +
                         ", sta_final) " +
                         "VALUES " +
                         "( @sta_codigo " +
                         " , @sta_nome " +
                         " , @sta_final ) ";

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

            return(retorno);
        }
Exemple #6
0
        internal Status_TO GetByCode(Status_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_status ";

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

                reader = command.ExecuteReader();

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

            return(pTO);
        }
Exemple #7
0
        public bool Save(bool pOpcao, Status_TO pTO)
        {
            bool retorno = false;

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

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

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

            return(retorno);
        }