コード例 #1
0
        internal List <AtendimentoVenda_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_atendimento_venda ";

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

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

                while (reader.Read())
                {
                    AtendimentoVenda_TO AtendimentoVendaTO = new AtendimentoVenda_TO();
                    AtendimentoVendaTO.atv_codigo               = Convert.ToInt32(reader["atv_codigo"]);
                    AtendimentoVendaTO.AtendimentoTO            = new Atendimento_TO();
                    AtendimentoVendaTO.AtendimentoTO.atd_codigo = Convert.ToInt32(reader["atd_codigo"]);
                    AtendimentoVendaTO.ProdutoTO            = new Produto_TO();
                    AtendimentoVendaTO.ProdutoTO.pro_codigo = Convert.ToInt32(reader["pro_codigo"]);
                    AtendimentoVendaTO.atv_sistema          = (reader["atv_sistema"]);
                    AtendimentoVendaTO.atv_venda            = Convert.ToInt32(reader["atv_venda"]);
                    AtendimentoVendaTO.atv_valor            = Convert.ToDecimal(reader["atv_valor"]);
                    AtendimentoVendaTO.atv_receita          = Convert.ToDecimal(reader["atv_receita"]);
                    AtendimentoVendaTO.DestinoTO            = new Destino_TO();
                    AtendimentoVendaTO.DestinoTO.des_codigo = Convert.ToInt32(reader["des_codigo"]);
                    collection.Add(AtendimentoVendaTO);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                reader.Close();
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }
            return(collection);
        }
コード例 #2
0
        internal bool Update(AtendimentoVenda_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 = "UPDATE vcrm_atendimento_venda" +
                         " SET atv_codigo = @atv_codigo " +
                         " , atd_codigo = @atd_codigo " +
                         " , pro_codigo = @pro_codigo " +
                         " , atv_sistema = @atv_sistema " +
                         " , atv_venda = @atv_venda " +
                         " , atv_valor = @atv_valor " +
                         " , atv_receita = @atv_receita " +
                         " , des_codigo = @des_codigo " +
                         "WHERE ... ";

            try
            {
                command = new SqlCommand(sql, connection);
                command.Parameters.AddWithValue("@atv_codigo", pTO.atv_codigo);
                command.Parameters.AddWithValue("@atd_codigo", pTO.AtendimentoTO.atd_codigo);
                command.Parameters.AddWithValue("@pro_codigo", pTO.ProdutoTO.pro_codigo);
                command.Parameters.AddWithValue("@atv_sistema", pTO.atv_sistema);
                command.Parameters.AddWithValue("@atv_venda", pTO.atv_venda);
                command.Parameters.AddWithValue("@atv_valor", pTO.atv_valor);
                command.Parameters.AddWithValue("@atv_receita", pTO.atv_receita);
                command.Parameters.AddWithValue("@des_codigo", pTO.DestinoTO.des_codigo);
                command.ExecuteNonQuery();
                retorno = true;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }

            return(retorno);
        }
コード例 #3
0
 public AtendimentoVenda_TO GetByCode(AtendimentoVenda_TO pTO)
 {
     try
     {
         return(new AtendimentoVenda_DAO().GetByCode(pTO));
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #4
0
        public bool Delete(AtendimentoVenda_TO pTO)
        {
            bool retorno = false;

            try
            {
                retorno = new AtendimentoVenda_DAO().Delete(pTO);
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
コード例 #5
0
        public List <AtendimentoVenda_TO> SearchAll(AtendimentoVenda_TO pTO)
        {
            string condicao = "";

            try
            {
// implementa a condição de procura
                condicao += "";
                return(new AtendimentoVenda_DAO().SearchAll(condicao));
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #6
0
        public bool Save(bool pOpcao, AtendimentoVenda_TO pTO)
        {
            bool retorno = false;

            try
            {
                if (pOpcao)
                {
                    retorno = new AtendimentoVenda_DAO().Save(pTO);
                }
                else
                {
                    retorno = new AtendimentoVenda_DAO().Update(pTO);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
コード例 #7
0
        internal bool Delete(AtendimentoVenda_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_atendimento_venda" +
                         "WHERE ... ";

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

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

            return(retorno);
        }