コード例 #1
0
 public void Atualiza(LogProduto log)
 {
     using (var contexto = new LojaContext())
     {
         contexto.LogProdutos.Update(log);
         contexto.SaveChanges();
     }
 }
コード例 #2
0
 public void Remover(LogProduto log)
 {
     using (var contexto = new LojaContext())
     {
         contexto.LogProdutos.Remove(log);
         contexto.SaveChanges();
     }
 }
コード例 #3
0
 public void Adiciona(LogProduto log)
 {
     using (var context = new LojaContext())
     {
         context.LogProdutos.Add(log);
         context.SaveChanges();
     }
 }
コード例 #4
0
        public void RegistrarLog(Produto produto, string modificacao)
        {
            Pessoa         user = (Pessoa)Session["UsuarioLogado"];
            LogProdutosDAO dao  = new LogProdutosDAO();
            LogProduto     log  = new LogProduto()
            {
                PessoaId        = user.Id,
                PessoaNome      = user.Nome,
                ProdutoId       = produto.Id,
                ProdutoNome     = produto.Nome,
                DataModificacao = DateTime.Now,
                Descricao       = "Funcionario " + user.Nome + " " + modificacao + " o produto " + produto.Nome
            };

            dao.Adiciona(log);
        }
コード例 #5
0
        public uint AtualizarTelaConfig(BenefConfigPreco objUpdate)
        {
            // Aplica o ajuste de preço com base na porcentagem escolhida pelo usuário
            float valorAtacado     = (100f + objUpdate.AjusteAtacado) / 100f;
            float valorBalcao      = (100f + objUpdate.AjusteBalcao) / 100f;
            float valorObra        = (100f + objUpdate.AjusteObra) / 100f;
            float valorCustoCompra = (100 + objUpdate.AjusteCustoCompra) / 100;

            if (valorAtacado < 1 && valorBalcao < 1 && valorObra < 1 && valorCustoCompra < 1)
            {
                throw new Exception("Selecione pelo menos 1 tipo de preço para reajustar.");
            }

            // Define o campo que contém o preço base
            string campoBase = "Custo";

            // Cria o filtro que será usado pelo SQL
            string filtroSubgrupo = "IdBenefConfig in (select idBenefConfig from benef_config where idParent=" + objUpdate.IdSubgrupoProd + " or idBenefConfig=" + objUpdate.IdSubgrupoProd + ")";

            // Define as colunas que serão alteradas
            string mudarAtacado = valorAtacado >= 1 ? "ValorAtacado=(" + campoBase + " * " + valorAtacado.ToString().Replace(',', '.') + ")" : String.Empty;
            string mudarBalcao  = valorBalcao >= 1 ? "ValorBalcao=(" + campoBase + " * " + valorBalcao.ToString().Replace(',', '.') + ")" : String.Empty;
            string mudarObra    = valorObra >= 1 ? "ValorObra=(" + campoBase + " * " + valorObra.ToString().Replace(',', '.') + ")" : String.Empty;

            string filtro       = " Where 1";
            string filtroCampos = String.Empty;

            if (!String.IsNullOrEmpty(filtroSubgrupo))
            {
                filtro += !String.IsNullOrEmpty(filtroSubgrupo) ? " and " + filtroSubgrupo : String.Empty;

                filtroCampos += " or coalesce(Custo ,0) <> 0";

                if (!String.IsNullOrEmpty(filtroCampos))
                {
                    filtroCampos = " and (" + filtroCampos.Substring(4) + ")";
                }
            }

            // Verifica se a alteração pode ser feita
            string nomeTabela = "benef_config_preco";
            string sql;

            // Define o SQL de alteração
            string mudar = String.Empty;

            mudar += !String.IsNullOrEmpty(mudarAtacado) ? mudarAtacado : String.Empty;
            mudar += !String.IsNullOrEmpty(mudar) && !String.IsNullOrEmpty(mudarBalcao) ? ", " : String.Empty;
            mudar += !String.IsNullOrEmpty(mudarBalcao) ? mudarBalcao : String.Empty;
            mudar += !String.IsNullOrEmpty(mudar) && !String.IsNullOrEmpty(mudarObra) ? ", " : String.Empty;
            mudar += !String.IsNullOrEmpty(mudarObra) ? mudarObra : String.Empty;

            sql = "update " + nomeTabela + " set " + mudar + filtro + " and coalesce(" + campoBase + ",0)<>0";

            objPersistence.ExecuteCommand(sql);

            LogProduto log = new LogProduto();

            log.DataAjuste = DateTime.Now;

            log.IdGrupoProd       = 0;
            log.IdSubgrupoProd    = (uint?)objUpdate.IdSubgrupoProd;
            log.TipoPrecoBase     = 1;
            log.AjusteAtacado     = objUpdate.AjusteAtacado;
            log.AjusteBalcao      = objUpdate.AjusteBalcao;
            log.AjusteCustoCompra = objUpdate.AjusteCustoCompra;
            log.AjusteObra        = objUpdate.AjusteObra;
            log.IdFunc            = UserInfo.GetUserInfo.CodUser;
            return(LogProdutoDAO.Instance.InsertBase(log));
        }