public void Update(int totaisOrcamentoId, TotaisOrcamentoModel totaisOrcamento) { try { using (var cn = Conexao.AbrirConexao()) { cn.Execute(@"UPDATE T_ORCA_TOTAIS_ORCAMENTO SET TOTAIS_ITENS = @TOTAIS_ITENS, TOTAIS_MAO_OBRA = @TOTAIS_MAO_OBRA, TOTAIS_EQUIPAMENTOS = @TOTAIS_EQUIPAMENTOS, TOTAIS_MATERIAL = @TOTAIS_MATERIAL, TOTAIS_CUSTOS = @TOTAIS_CUSTOS, TOTAL_GERAL = @TOTAL_GERAL, AREA_TOTAL = @AREA_TOTAL WHERE TOTAIS_ORCAMENTO_ID = @totaisOrcamentoId", new { totaisOrcamento.TOTAIS_ITENS, totaisOrcamento.TOTAIS_MAO_OBRA, totaisOrcamento.TOTAIS_EQUIPAMENTOS, totaisOrcamento.TOTAIS_MATERIAL, totaisOrcamento.TOTAIS_CUSTOS, totaisOrcamento.TOTAL_GERAL, totaisOrcamento.AREA_TOTAL, totaisOrcamentoId }); } } catch (Exception) { throw; } }
public void Put(int totaisOrcamentoId, TotaisOrcamentoModel totaisOrcamento) { try { var where = $"TOTAIS_ORCAMENTO_ID = {totaisOrcamentoId}"; if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("TOTAIS_ORCAMENTO_ID", "T_ORCA_TOTAIS_ORCAMENTO", where))) { throw new Exception(); } TotaisOrcamentoRepository.Update(totaisOrcamentoId, totaisOrcamento); } catch (Exception) { throw; } }
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; } }
public OrcamentoModel(int orcamentoId, string nomeObra, string referencia, string prazoEntrega, int diasTrabalhado, DateTime dataCriacaoOrcamento, string contatoObra, string tipoObra, TotaisOrcamentoModel totaisOrcamento, PessoaModel clienteOrcamento, List <MaoObraOrcamentoModel> maoObraOrcamento, List <CustoOrcamentoModel> custoOrcamento, List <EquipamentoOrcamentoModel> equipamentoOrcamento, List <MaterialOrcamentoModel> materialOrcamento) { ORCAMENTO_ID = orcamentoId; NOME_OBRA = nomeObra; REFERENCIA = referencia; PRAZO_ENTREGA = prazoEntrega; DIAS_TRABALHADO = diasTrabalhado; DATA_CRIACAO_ORCAMENTO = dataCriacaoOrcamento; A_C = contatoObra; TIPO_OBRA = tipoObra; TOTAIS_ORCAMENTO = totaisOrcamento; CLIENTE_ORCAMENTO = clienteOrcamento; LIST_MAO_OBRA_ORCAMENTO = maoObraOrcamento; LIST_CUSTO_ORCAMENTO = custoOrcamento; LIST_EQUIPAMENTO_ORCAMENTO = equipamentoOrcamento; LIST_MATERIAL_ORCAMENTO = materialOrcamento; }
public TotaisOrcamentoModel Create(TotaisOrcamentoModel totaisOrcamento) { try { using (var cn = Conexao.AbrirConexao()) { cn.Execute(@"INSERT INTO T_ORCA_TOTAIS_ORCAMENTO (ORCAMENTO_ID, TOTAIS_ITENS, TOTAIS_MAO_OBRA, TOTAIS_EQUIPAMENTOS, TOTAIS_MATERIAL, TOTAIS_CUSTOS, TOTAL_GERAL, AREA_TOTAL) VALUES(@ORCAMENTO_ID, @TOTAIS_ITENS, @TOTAIS_MAO_OBRA, @TOTAIS_EQUIPAMENTOS, @TOTAIS_MATERIAL, @TOTAIS_CUSTOS, @TOTAL_GERAL, @AREA_TOTAL)", totaisOrcamento); return(Find(cn.Query <int>("SELECT LAST_INSERT_ID()").FirstOrDefault())); } } catch (Exception) { throw; } }
public OrcamentoIntumescenteModel(string grupo, string ocupacaoUso, string classe, string divisao, string tempoResistenciaFogo, double qtdeLitrosTotal, double percentualPerda, double qtdeBaldes, double qtdeBaldesReal, double valorUnitarioIntumescente, double valorBaldeIntumescente, MaterialModel produto, List <ItensOrcamentoIntumescenteModel> itensOrcamentoIntumescente, int orcamentoId, string nomeObra, string referencia, string prazoEntrega, int diasTrabalhado, DateTime dataCriacaoOrcamento, string contatoObra, string tipoObra, TotaisOrcamentoModel totaisOrcamento, PessoaModel clienteOrcamento, List <MaoObraOrcamentoModel> maoObraOrcamento, List <CustoOrcamentoModel> custoOrcamento, List <EquipamentoOrcamentoModel> equipamentoOrcamento, List <MaterialOrcamentoModel> materialOrcamento) : base(orcamentoId, nomeObra, referencia, prazoEntrega, diasTrabalhado, dataCriacaoOrcamento, contatoObra, tipoObra, totaisOrcamento, clienteOrcamento, maoObraOrcamento, custoOrcamento, equipamentoOrcamento, materialOrcamento) { GRUPO = grupo; OCUPACAO_USO = ocupacaoUso; CLASSE = classe; DIVISAO = divisao; TEMPO_RESISTENCIA_FOGO = tempoResistenciaFogo; QTDE_LITROS_TOTAL = qtdeLitrosTotal; PERCENTUAL_PERDA = percentualPerda; QTDE_BALDES = qtdeBaldes; QTDE_BALDES_REAL = qtdeBaldesReal; VALOR_UNITARIO_INTUMESCENTE = valorUnitarioIntumescente; VALOR_BALDE_INTUMESCENTE = valorBaldeIntumescente; PRODUTO = produto; LIST_ITENS_ORCAMENTO_INTUMESCENTE = itensOrcamentoIntumescente; ORCAMENTO_ID = orcamentoId; NOME_OBRA = nomeObra; REFERENCIA = referencia; PRAZO_ENTREGA = prazoEntrega; DIAS_TRABALHADO = diasTrabalhado; DATA_CRIACAO_ORCAMENTO = dataCriacaoOrcamento; A_C = contatoObra; TIPO_OBRA = tipoObra; TOTAIS_ORCAMENTO = totaisOrcamento; CLIENTE_ORCAMENTO = clienteOrcamento; LIST_MAO_OBRA_ORCAMENTO = maoObraOrcamento; LIST_CUSTO_ORCAMENTO = custoOrcamento; LIST_EQUIPAMENTO_ORCAMENTO = equipamentoOrcamento; LIST_MATERIAL_ORCAMENTO = materialOrcamento; }
public void CalcularTotaisOrcamento(int orcamentoId) { try { var where = $"ORCAMENTO_ID = {orcamentoId}"; if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("ORCAMENTO_ID", "T_ORCA_ORCAMENTO", where))) { throw new Exception(); } var totaisOrcamento = new TotaisOrcamentoModel(); var totaisMaoObra = 0.0; var totaisEquipamentos = 0.0; var totaisMateriais = 0.0; var totaisCustos = 0.0; var totaisItens = 0.0; var totalArea = 0.0; var totalGeral = 0.0; var orcamentoDb = OrcamentoGeralService.Get(orcamentoId); var diasTrabalhado = orcamentoDb.FirstOrDefault().DIAS_TRABALHADO; foreach (MaoObraOrcamentoModel maoObraOrcamento in orcamentoDb.FirstOrDefault().LIST_MAO_OBRA_ORCAMENTO) { totaisMaoObra += maoObraOrcamento.FUNCIONARIO.VALOR_DIA_TRABALHADO * diasTrabalhado; totaisMaoObra += maoObraOrcamento.LIST_CUSTO.Aggregate(0.0, (acumulador, obj) => acumulador += obj.VALOR_CUSTO * MetodosGenericosService.RetornarFator(obj.TIPO_CUSTO, diasTrabalhado)); } totaisEquipamentos = orcamentoDb.FirstOrDefault().LIST_EQUIPAMENTO_ORCAMENTO.Aggregate(0.0, (acumulador, obj) => acumulador += obj.VALOR_UNITARIO_EQUIPAMENTO * obj.QTDE_EQUIPAMENTO); totaisMateriais = orcamentoDb.FirstOrDefault().LIST_MATERIAL_ORCAMENTO.Aggregate(0.0, (acumulador, obj) => acumulador += obj.VALOR_UNITARIO_MATERIAL * obj.QTDE_MATERIAL); totaisCustos = orcamentoDb.FirstOrDefault().LIST_CUSTO_ORCAMENTO.Aggregate(0.0, (acumulador, obj) => acumulador += obj.VALOR_CUSTO * MetodosGenericosService.RetornarFator(obj.CUSTO_OBRA.TIPO_CUSTO, diasTrabalhado)); if (orcamentoDb.FirstOrDefault().TIPO_OBRA != "Geral") { if (!string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("ORCAMENTO_ID", "T_ORCA_ORCAMENTO_INTUMESCENTE", where))) { var orcamentoIntumescenteDb = OrcamentoIntumescenteService.Get(orcamentoId); foreach (ItensOrcamentoIntumescenteModel itensOrcamentoIntumescente in orcamentoIntumescenteDb.FirstOrDefault().LIST_ITENS_ORCAMENTO_INTUMESCENTE) { totalArea += itensOrcamentoIntumescente.VALOR_HP * itensOrcamentoIntumescente.QTDE * itensOrcamentoIntumescente.VALOR_COMPRIMENTO; } totaisItens = totalArea * orcamentoIntumescenteDb.FirstOrDefault().VALOR_UNITARIO_INTUMESCENTE; totaisItens += Math.Round((orcamentoIntumescenteDb.FirstOrDefault().QTDE_BALDES_REAL + 0.4)) * orcamentoIntumescenteDb.FirstOrDefault().VALOR_BALDE_INTUMESCENTE; } } else { foreach (ItensOrcamentoGeralModel itensOrcamentoGeralModel in orcamentoDb.FirstOrDefault().LIST_ITENS_ORCAMENTO_GERAL) { var areaAux = itensOrcamentoGeralModel.AREA; totalArea += areaAux; totaisItens += areaAux * itensOrcamentoGeralModel.VALOR_M_2; } } totalGeral = totaisItens + totaisMaoObra + totaisEquipamentos + totaisCustos + totaisMateriais; totaisOrcamento = new TotaisOrcamentoModel(0, orcamentoId, totaisItens, totaisMaoObra, totaisEquipamentos, totaisMateriais, totaisCustos, totalGeral, totalArea); if (orcamentoDb.FirstOrDefault().TOTAIS_ORCAMENTO.TOTAIS_ORCAMENTO_ID == 0) { Post(totaisOrcamento); } else { Put(orcamentoDb.FirstOrDefault().TOTAIS_ORCAMENTO.TOTAIS_ORCAMENTO_ID, totaisOrcamento); } } catch (Exception) { throw; } }