Esempio n. 1
0
        public ItensOrcamentoGeralModel Create(ItensOrcamentoGeralModel itensOrcamentoGeral)
        {
            try
            {
                using (var cn = Conexao.AbrirConexao())
                {
                    cn.Execute(@"INSERT INTO T_ORCA_ITENS_ORCAMENTO_GERAL (ITENS_ORCAMENTO_ID, ORCAMENTO_ID, 
                                AMBIENTE_APLICACAO, LOCAL_APLICACAO, ACAO_APLICAR, VALOR_LARGURA, VALOR_M_2,
                                MATERIAL_ID, NOME_MATERIAL, DESCRICAO_MATERIAL) VALUES(@ITENS_ORCAMENTO_ID, 
                                @ORCAMENTO_ID, @AMBIENTE_APLICACAO, @LOCAL_APLICACAO, @ACAO_APLICAR, 
                                @VALOR_LARGURA, @VALOR_M_2, @MATERIAL_ID, @NOME_MATERIAL, @DESCRICAO_MATERIAL)", new
                    {
                        itensOrcamentoGeral.ITENS_ORCAMENTO_ID,
                        itensOrcamentoGeral.ORCAMENTO_ID,
                        itensOrcamentoGeral.AMBIENTE_APLICACAO,
                        itensOrcamentoGeral.LOCAL_APLICACAO,
                        itensOrcamentoGeral.ACAO_APLICAR,
                        itensOrcamentoGeral.VALOR_LARGURA,
                        itensOrcamentoGeral.VALOR_M_2,
                        itensOrcamentoGeral.PRODUTO.MATERIAL_ID,
                        itensOrcamentoGeral.PRODUTO.NOME_MATERIAL,
                        itensOrcamentoGeral.PRODUTO.DESCRICAO_MATERIAL
                    });

                    return(Find(itensOrcamentoGeral.ITENS_ORCAMENTO_ID));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
 public void Update(int itensOrcamentoId, ItensOrcamentoGeralModel itensOrcamentoGeral)
 {
     try
     {
         using (var cn = Conexao.AbrirConexao())
         {
             cn.Execute(@"UPDATE T_ORCA_ITENS_ORCAMENTO_GERAL SET AMBIENTE_APLICACAO = @AMBIENTE_APLICACAO, 
                         LOCAL_APLICACAO = @LOCAL_APLICACAO, ACAO_APLICAR = @ACAO_APLICAR, 
                         VALOR_LARGURA = @VALOR_LARGURA, VALOR_M_2 = @VALOR_M_2, MATERIAL_ID = @MATERIAL_ID,
                         NOME_MATERIAL = @NOME_MATERIAL, DESCRICAO_MATERIAL = @DESCRICAO_MATERIAL
                         WHERE ITENS_ORCAMENTO_ID = @itensOrcamentoId", new
             {
                 itensOrcamentoGeral.AMBIENTE_APLICACAO,
                 itensOrcamentoGeral.LOCAL_APLICACAO,
                 itensOrcamentoGeral.ACAO_APLICAR,
                 itensOrcamentoGeral.VALOR_LARGURA,
                 itensOrcamentoGeral.VALOR_M_2,
                 itensOrcamentoGeral.PRODUTO.MATERIAL_ID,
                 itensOrcamentoGeral.PRODUTO.NOME_MATERIAL,
                 itensOrcamentoGeral.PRODUTO.DESCRICAO_MATERIAL,
                 itensOrcamentoId
             });
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 3
0
        public void Put(int itensOrcamentoId, ItensOrcamentoGeralModel itensOrcamentoGeral)
        {
            try
            {
                var where = $"ITENS_ORCAMENTO_ID = {itensOrcamentoId}";
                if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("ITENS_ORCAMENTO_ID", "T_ORCA_ITENS_ORCAMENTO_GERAL", where)))
                {
                    throw new Exception();
                }

                var itensOrcamento = MetodosGenericosService.CopiarPropriedadesObj(itensOrcamentoGeral, new ItensOrcamentoModel());

                ItensOrcamentoService.Put(itensOrcamentoId, itensOrcamento);

                if (itensOrcamentoGeral.VALOR_COMPRIMENTO < 0 || itensOrcamentoGeral.AREA < 0)
                {
                    throw new Exception();
                }

                where = $"MATERIAL_ID = {itensOrcamentoGeral.PRODUTO.MATERIAL_ID}";
                if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("MATERIAL_ID", "T_ORCA_MATERIAL", where)))
                {
                    throw new Exception();
                }

                itensOrcamentoGeral.PRODUTO = MaterialService.GetComParametro(new MaterialQO(itensOrcamentoGeral.PRODUTO.MATERIAL_ID, "", "")).FirstOrDefault();

                ItensOrcamentoGeralRepository.Update(itensOrcamentoId, itensOrcamentoGeral);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 4
0
 public void Put(int itensOrcamentoId, [FromBody] ItensOrcamentoGeralModel itensOrcamentoGeral)
 {
     try
     {
         ItensOrcamentoGeralService.Put(itensOrcamentoId, itensOrcamentoGeral);
         TotaisOrcamentoService.CalcularTotaisOrcamento(itensOrcamentoGeral.ORCAMENTO_ID);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 5
0
 public ItensOrcamentoGeralModel Post([FromBody] ItensOrcamentoGeralModel itensOrcamentoGeral)
 {
     try
     {
         var itens = ItensOrcamentoGeralService.Post(itensOrcamentoGeral);
         TotaisOrcamentoService.CalcularTotaisOrcamento(itensOrcamentoGeral.ORCAMENTO_ID);
         return(itens);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 6
0
        public ItensOrcamentoGeralModel Post(ItensOrcamentoGeralModel itensOrcamentoGeral)
        {
            try
            {
                var where = $"ORCAMENTO_ID = {itensOrcamentoGeral.ORCAMENTO_ID}";
                if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("ORCAMENTO_ID", "T_ORCA_ORCAMENTO", where)))
                {
                    throw new Exception();
                }

                where = $"MATERIAL_ID = {itensOrcamentoGeral.PRODUTO.MATERIAL_ID}";
                if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("MATERIAL_ID", "T_ORCA_MATERIAL", where)))
                {
                    throw new Exception();
                }

                if (itensOrcamentoGeral.VALOR_LARGURA < 0 || itensOrcamentoGeral.VALOR_M_2 < 0)
                {
                    throw new Exception();
                }

                MetodosGenericosService.StartTransactionCommitRollbackOrcamentaria(MetodosGenericosEnum.START);

                var itensOrcamento = MetodosGenericosService.CopiarPropriedadesObj(itensOrcamentoGeral, new ItensOrcamentoModel());

                itensOrcamento = ItensOrcamentoService.Post(itensOrcamento);

                itensOrcamentoGeral.ITENS_ORCAMENTO_ID = itensOrcamento.ITENS_ORCAMENTO_ID;

                itensOrcamentoGeral.NUMERO_LINHA = itensOrcamento.NUMERO_LINHA;

                var produto = MaterialService.GetComParametro(new MaterialQO(itensOrcamentoGeral.PRODUTO.MATERIAL_ID, "", "")).FirstOrDefault();

                itensOrcamentoGeral.PRODUTO = produto;

                ItensOrcamentoGeralRepository.Create(itensOrcamentoGeral);

                MetodosGenericosService.StartTransactionCommitRollbackOrcamentaria(MetodosGenericosEnum.COMMIT);

                return(itensOrcamentoGeral);
            }
            catch (Exception)
            {
                MetodosGenericosService.StartTransactionCommitRollbackOrcamentaria(MetodosGenericosEnum.ROLLBACK);
                throw;
            }
        }