Esempio n. 1
0
        public ItensOrcamentoModel Post(ItensOrcamentoModel itensOrcamento)
        {
            try
            {
                var where = $"ORCAMENTO_ID = {itensOrcamento.ORCAMENTO_ID}";
                if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("ORCAMENTO_ID", "T_ORCA_ORCAMENTO", where)))
                {
                    throw new Exception();
                }

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

                where = $"ORCAMENTO_ID = {itensOrcamento.ORCAMENTO_ID}";
                var ultimaNumeroLinha = MetodosGenericosService.DlookupOrcamentaria("IF(MAX(NUMERO_LINHA) IS NULL, 0, MAX(NUMERO_LINHA))", "T_ORCA_ITENS_ORCAMENTO", where);

                itensOrcamento.NUMERO_LINHA = int.Parse(ultimaNumeroLinha) + 1;

                var novoItensOrcamento = ItensOrcamentoRepository.Create(itensOrcamento);

                return(novoItensOrcamento);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
        public void Put(int pessoaId, FuncionarioModel funcionario)
        {
            try
            {
                var where = $"PESSOA_ID = {pessoaId}";
                if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("PESSOA_ID", "T_ORCA_FUNCIONARIO", where)))
                {
                    throw new Exception();
                }

                if (funcionario.TIPO_CADASTRO != "Funcionario")
                {
                    throw new Exception();
                }
                var pessoa   = MetodosGenericosService.CopiarPropriedadesObj(funcionario, new PessoaModel());
                var pessoaDB = PessoaService.GetComParametro(new PessoaQO(pessoaId, "")).ToArray()[0];

                ComparisonResult resultando = new CompareLogic().Compare(pessoa, pessoaDB);

                if (!resultando.AreEqual)
                {
                    var res = resultando.Differences;

                    PessoaService.Put(pessoaId, pessoa);
                }

                FuncionarioRepository.Update(pessoaId, funcionario);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 3
0
        public IEnumerable <OrcamentoGeralModel> Get()
        {
            try
            {
                var listOrcamento = OrcamentoRepository.List();

                foreach (OrcamentoGeralModel orcamento in listOrcamento)
                {
                    var pessoaId = MetodosGenericosService.DlookupOrcamentaria("PESSOA_ID", "T_ORCA_ORCAMENTO", $"ORCAMENTO_ID = {orcamento.ORCAMENTO_ID}");
                    orcamento.CLIENTE_ORCAMENTO = PessoaService.GetComParametro(new PessoaQO(int.Parse(pessoaId), "")).ToArray()[0];

                    orcamento.LIST_ITENS_ORCAMENTO_GERAL = ItensOrcamentoGeralService.GetComParametro(new ItensOrcamentoQO(0, orcamento.ORCAMENTO_ID)).ToList();
                    orcamento.LIST_MAO_OBRA_ORCAMENTO    = MaoObraOrcamentoService.Get(orcamento.ORCAMENTO_ID).ToList();
                    orcamento.LIST_CUSTO_ORCAMENTO       = CustoOrcamentoService.GetComParametro(new CustoOrcamentoQO(0, orcamento.ORCAMENTO_ID)).ToList();
                    orcamento.LIST_EQUIPAMENTO_ORCAMENTO = EquipamentoOrcamentoService.GetComParametro(new EquipamentoOrcamentoQO(0, orcamento.ORCAMENTO_ID)).ToList();
                    orcamento.LIST_MATERIAL_ORCAMENTO    = MaterialOrcamentoService.GetComParametro(new MaterialOrcamentoQO(0, orcamento.ORCAMENTO_ID)).ToList();
                    orcamento.TOTAIS_ORCAMENTO           = TotaisOrcamentoRepository.FindPorOrcamentoId(orcamento.ORCAMENTO_ID);
                }

                return(listOrcamento);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 4
0
        public IEnumerable <EnderecoModel> GetComParametro(EnderecoQO endereco)
        {
            try
            {
                if (endereco.PessoaId != 0)
                {
                    var where = $"PESSOA_ID = {endereco.PessoaId}";
                    if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("PESSOA_ID", "T_ORCA_PESSOA", where)))
                    {
                        throw new Exception();
                    }

                    return(EnderecoRepository.ListPorPessoaId(endereco.PessoaId));
                }
                else
                {
                    List <EnderecoModel> listEndereco = new List <EnderecoModel>();

                    listEndereco.Add(EnderecoRepository.Find(endereco.EnderecoId));

                    return(listEndereco);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 5
0
        public IEnumerable <ItensOrcamentoIntumescenteModel> Get()
        {
            try
            {
                var listItensOrcamentoIntumescente = ItensOrcamentoIntumescenteRepository.List();

                foreach (ItensOrcamentoIntumescenteModel itensOrcamentoIntumescente in listItensOrcamentoIntumescente)
                {
                    var perfilId = MetodosGenericosService.DlookupOrcamentaria("PERFIL_ID", "T_ORCA_ITENS_ORCAMENTO_INTUMESCENTE", $"ITENS_ORCAMENTO_ID = {itensOrcamentoIntumescente.ITENS_ORCAMENTO_ID}");

                    if (int.Parse(perfilId) != 0)
                    {
                        itensOrcamentoIntumescente.PERFIL = PerfilService.GetComParametro(new PerfilQO(int.Parse(perfilId), "")).ToArray()[0];
                    }

                    var cartaCoberturId = MetodosGenericosService.DlookupOrcamentaria("CARTA_COBERTURA_ID", "T_ORCA_ITENS_ORCAMENTO_INTUMESCENTE", $"ITENS_ORCAMENTO_ID = {itensOrcamentoIntumescente.ITENS_ORCAMENTO_ID}");

                    if (int.Parse(cartaCoberturId) != 0)
                    {
                        itensOrcamentoIntumescente.CARTA_COBERTURA = CartaCoberturaService.GetComParametro(new CartaCoberturaQO(int.Parse(cartaCoberturId), 0, 0, "")).ToArray()[0];
                    }
                }

                return(listItensOrcamentoIntumescente);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 6
0
        public void Put(int perfilId, PerfilModel perfil)
        {
            try
            {
                var where = $"PERFIL_ID = {perfilId}";
                if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("PERFIL_ID", "T_ORCA_PERFIL", where)))
                {
                    throw new Exception();
                }

                PerfilRepository.Update(perfilId, perfil);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 7
0
        public ItensCartaCoberturaModel Post(ItensCartaCoberturaModel itensCartaCobertura)
        {
            try
            {
                var where = $"CARTA_COBERTURA_ID = {itensCartaCobertura.CARTA_COBERTURA_ID}";
                if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("CARTA_COBERTURA_ID", "T_ORCA_CARTA_COBERTURA", where)))
                {
                    throw new Exception();
                }

                return(ItensCartaCoberturaRepository.Create(itensCartaCobertura));
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 8
0
        public void Put(int custoId, CustoModel custo)
        {
            try
            {
                var where = $"CUSTO_ID = {custoId}";
                if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("CUSTO_ID", "T_ORCA_CUSTO", where)))
                {
                    throw new Exception();
                }

                CustoRepository.Update(custoId, custo);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 9
0
        public IEnumerable <OrcamentoIntumescenteModel> Get()
        {
            try
            {
                var listOrcamentoIntumescente = OrcamentoIntumescenteRepository.List();

                foreach (OrcamentoIntumescenteModel orcamentoIntumescente in listOrcamentoIntumescente)
                {
                    var pessoaId = MetodosGenericosService.DlookupOrcamentaria("PESSOA_ID", "T_ORCA_ORCAMENTO", $"ORCAMENTO_ID = {orcamentoIntumescente.ORCAMENTO_ID}");
                    orcamentoIntumescente.CLIENTE_ORCAMENTO = PessoaService.GetComParametro(new PessoaQO(int.Parse(pessoaId), "")).FirstOrDefault();

                    var materialId = MetodosGenericosService.DlookupOrcamentaria("MATERIAL_ID", "T_ORCA_ORCAMENTO_INTUMESCENTE", $"ORCAMENTO_ID = {orcamentoIntumescente.ORCAMENTO_ID}");
                    if (materialId != "")
                    {
                        orcamentoIntumescente.PRODUTO = MaterialService.GetComParametro(new MaterialQO(int.Parse(materialId), "", "")).FirstOrDefault();
                    }

                    orcamentoIntumescente.LIST_ITENS_ORCAMENTO_INTUMESCENTE = ItensOrcamentoIntumescenteService.GetComParametro(new ItensOrcamentoQO(0, orcamentoIntumescente.ORCAMENTO_ID)).ToList();
                    orcamentoIntumescente.LIST_MAO_OBRA_ORCAMENTO           = MaoObraOrcamentoService.Get(orcamentoIntumescente.ORCAMENTO_ID).ToList();
                    orcamentoIntumescente.LIST_CUSTO_ORCAMENTO       = CustoOrcamentoService.GetComParametro(new CustoOrcamentoQO(0, orcamentoIntumescente.ORCAMENTO_ID)).ToList();
                    orcamentoIntumescente.LIST_EQUIPAMENTO_ORCAMENTO = EquipamentoOrcamentoService.GetComParametro(new EquipamentoOrcamentoQO(0, orcamentoIntumescente.ORCAMENTO_ID)).ToList();
                    orcamentoIntumescente.LIST_MATERIAL_ORCAMENTO    = MaterialOrcamentoService.GetComParametro(new MaterialOrcamentoQO(0, orcamentoIntumescente.ORCAMENTO_ID)).ToList();
                    orcamentoIntumescente.TOTAIS_ORCAMENTO           = TotaisOrcamentoRepository.FindPorOrcamentoId(orcamentoIntumescente.ORCAMENTO_ID);
                }

                return(listOrcamentoIntumescente);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 10
0
        public IEnumerable <EquipamentoModel> Get()
        {
            try
            {
                var listEquipamento = EquipamentoRepository.List();

                foreach (EquipamentoModel equipamento in listEquipamento)
                {
                    var pessoaId = MetodosGenericosService.DlookupOrcamentaria("PESSOA_ID", "T_ORCA_EQUIPAMENTO", $"EQUIPAMENTO_ID = {equipamento.EQUIPAMENTO_ID}");

                    equipamento.FABRICANTE = PessoaService.GetComParametro(new PessoaQO(int.Parse(pessoaId), "")).ToArray()[0];
                }

                return(listEquipamento);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 11
0
        public IEnumerable <MaoObraOrcamentoModel> Get()
        {
            try
            {
                var listMaoObraOrcamento = MaoObraOrcamentoRepository.List();

                foreach (MaoObraOrcamentoModel maoObraOrcamento in listMaoObraOrcamento)
                {
                    var pessoaId = MetodosGenericosService.DlookupOrcamentaria("PESSOA_ID", "T_ORCA_MAO_OBRA_ORCAMENTO", $"MAO_OBRA_ORCAMENTO_ID = {maoObraOrcamento.MAO_OBRA_ORCAMENTO_ID}");

                    maoObraOrcamento.FUNCIONARIO = FuncionarioService.GetComParametro(new FuncionarioQO(int.Parse(pessoaId), "")).ToArray()[0];

                    maoObraOrcamento.LIST_CUSTO = CustosMaoObraService.Get(maoObraOrcamento.MAO_OBRA_ORCAMENTO_ID).ToList();
                }

                return(listMaoObraOrcamento);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 12
0
        public void Put(int pessoaId, PessoaModel pessoa)
        {
            try
            {
                var where = $"PESSOA_ID = {pessoaId}";
                if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("PESSOA_ID", "T_ORCA_PESSOA", where)))
                {
                    throw new Exception();
                }

                if (MetodosGenericosService.DlookupOrcamentaria("TIPO_CADASTRO", "T_ORCA_PESSOA", where) == "Funcionario" && pessoa.TIPO_CADASTRO != "Funcionario")
                {
                    throw new Exception();
                }

                PessoaRepository.Update(pessoaId, pessoa);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 13
0
        public IEnumerable <ItensOrcamentoGeralModel> Get()
        {
            try
            {
                var listItensOrcamentoGeral = ItensOrcamentoGeralRepository.List();

                foreach (ItensOrcamentoGeralModel itensOrcamentoGeral in listItensOrcamentoGeral)
                {
                    var materialId = MetodosGenericosService.DlookupOrcamentaria("MATERIAL_ID", "T_ORCA_ITENS_ORCAMENTO_GERAL", $"ITENS_ORCAMENTO_ID = {itensOrcamentoGeral.ITENS_ORCAMENTO_ID}");

                    itensOrcamentoGeral.PRODUTO = MaterialService.GetComParametro(new MaterialQO(int.Parse(materialId), "", "")).ToArray()[0];
                }

                return(listItensOrcamentoGeral);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 14
0
        public IEnumerable <MaterialOrcamentoModel> Get()
        {
            try
            {
                var listMaterialOrcamento = MaterialOrcamentoRepository.List();

                foreach (MaterialOrcamentoModel materialOrcamento in listMaterialOrcamento)
                {
                    var materialId = MetodosGenericosService.DlookupOrcamentaria("MATERIAL_ID", "T_ORCA_MATERIAL_ORCAMENTO", $"MATERIAL_ORCAMENTO_ID = {materialOrcamento.MATERIAL_ORCAMENTO_ID}");

                    materialOrcamento.MATERIAL = MaterialService.GetComParametro(new MaterialQO(int.Parse(materialId), "", "")).ToArray()[0];
                }

                return(listMaterialOrcamento);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 15
0
        public IEnumerable <CustoOrcamentoModel> Get()
        {
            try
            {
                var listCustoOrcamento = CustoOrcamentoRepository.List();

                foreach (CustoOrcamentoModel custoOrcamento in listCustoOrcamento)
                {
                    var custoId = MetodosGenericosService.DlookupOrcamentaria("CUSTO_ID", "T_ORCA_CUSTO_ORCAMENTO", $"CUSTO_ORCAMENTO_ID = {custoOrcamento.CUSTO_ORCAMENTO_ID}");

                    custoOrcamento.CUSTO_OBRA = CustoService.GetComParametro(new CustoQO(int.Parse(custoId), "")).ToArray()[0];
                }

                return(listCustoOrcamento);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 16
0
        public TotaisOrcamentoModel Post(TotaisOrcamentoModel totaisOrcamento)
        {
            try
            {
                var where = $"ORCAMENTO_ID = {totaisOrcamento.ORCAMENTO_ID}";
                if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("ORCAMENTO_ID", "T_ORCA_ORCAMENTO", where)))
                {
                    throw new Exception();
                }

                return(TotaisOrcamentoRepository.Create(totaisOrcamento));
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 17
0
        public IEnumerable <MaterialModel> Get()
        {
            try
            {
                var listMaterial = MaterialRepository.List();

                foreach (MaterialModel materialModel in listMaterial)
                {
                    var pessoaId = MetodosGenericosService.DlookupOrcamentaria("PESSOA_ID", "T_ORCA_MATERIAL", $"MATERIAL_ID = {materialModel.MATERIAL_ID}");

                    materialModel.FABRICANTE = PessoaService.GetComParametro(new PessoaQO(int.Parse(pessoaId), "")).ToArray()[0];
                }

                return(listMaterial);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 18
0
        public IEnumerable <ContatoModel> Get(int pessoaId, string tipoContato)
        {
            try
            {
                var where = $"PESSOA_ID = {pessoaId}";
                if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("PESSOA_ID", "T_ORCA_PESSOA", where)))
                {
                    throw new Exception();
                }

                List <ContatoModel> listContato = new List <ContatoModel>();

                listContato.Add(ContatoRepository.FindPorContatoPadraoETipoContato(pessoaId, tipoContato));

                return(listContato);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 19
0
        public IEnumerable <CustoModel> Get(int maoObraOrcamentoId)
        {
            try
            {
                var where = $"MAO_OBRA_ORCAMENTO_ID = {maoObraOrcamentoId}";
                if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("MAO_OBRA_ORCAMENTO_ID", "T_ORCA_MAO_OBRA_ORCAMENTO", where)))
                {
                    throw new Exception();
                }

                return(CustosMaoObraRepository.List(maoObraOrcamentoId));
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 20
0
        public IEnumerable <CartaCoberturaModel> Get()
        {
            try
            {
                List <CartaCoberturaModel> listCartaCobertura = CartaCoberturaRepository.List().ToList();

                foreach (CartaCoberturaModel cartaCobertura in listCartaCobertura)
                {
                    cartaCobertura.LIST_ITENS_CARTA_COBERTURA = ItensCartaCoberturaService.GetComParametro(new ItensCartaCoberturaQO(0, cartaCobertura.CARTA_COBERTURA_ID, "")).ToList();

                    var materialId = MetodosGenericosService.DlookupOrcamentaria("MATERIAL_ID", "T_ORCA_CARTA_COBERTURA", $"CARTA_COBERTURA_ID = {cartaCobertura.CARTA_COBERTURA_ID}");

                    cartaCobertura.MATERIAL = MaterialService.GetComParametro(new MaterialQO(int.Parse(materialId), "", "")).ToArray()[0];
                }

                return(listCartaCobertura);
            }
            catch (Exception)
            {
                throw;
            }
        }