private void SalvarAbaSimulador() { try { MapearCamposAbaProdutoSubAbaPlanos(); ControllerSimuladorProduto.SalvarSimuladorProduto(DadosTSimuladorProduto); DataTable completaDadosTSimuladorProduto = ControllerSimuladorProduto.SelecioneSimuladorProduto(DadosTEntrevista.CodigoEntrevista); Int32 idSimuladorProduto = Convert.ToInt32(completaDadosTSimuladorProduto.Rows[0]["IDSimuladorProduto"]); DadosTSimuladorProduto.IDSimuladorProduto = idSimuladorProduto; DadosTSimuladorSubFuneral.IDSimuladorProduto = idSimuladorProduto; DadosTSimuladorSubRenda.IDSimuladorProduto = idSimuladorProduto; ControllerSimuladorSubFuneral.SalvarSimuladorABAPlanos(DadosTSimuladorProduto.Produto, DadosTSimuladorSubFuneral); MapearCamposAbaProdutoSubAbaAgregados(); ControllerSimuladorSubAgregado.SalvarSimuladorABAAgregados(idSimuladorProduto, DadosTSimuladorSubAgregado); MapearCamposAbaProdutoSubAbaRenda(); ControllerSimuladorSubRenda.SalvarSimuladorABARenda(DadosTSimuladorSubRenda); GravarSimulador = false; TipoRegistro = 'A'; } catch (Exception ex) { throw ex; } }
private void PopularSimulador() { try { if (ControllerEnum.FaixaEtariaDataNascimento(DadosTEntrevistado.DataNascimento.GetValueOrDefault()) != (int)FaixaEtaria.PREMIO_81) { List <ProdutoPrincipal> produtos = new List <ProdutoPrincipal>(); int idadeBase = 0; bool alterarAgregado = true; TipoRegistro = 'A'; DadosTSimuladorProduto = new TSimuladorProdutoDOMINIO(); DadosTPlanoProtecao = new TPlanoProtecaoDOMINIO(); DadosTPlanoSenior = new TPlanoSeniorDOMINIO(); DadosTPlanoCasal = new TPlanoCasalDOMINIO(); ControllerPlano.PlanoProtecaoDOMINIO = new TPlanoProtecaoDOMINIO(); ControllerPlano.PlanoSeniorDOMINIO = new TPlanoSeniorDOMINIO(); ControllerPlano.PlanoCasalDOMINIO = new TPlanoCasalDOMINIO(); //Verifica se já foi feita simulação DataTable tableProduto = ControllerSimuladorProduto.SelecioneSimuladorProduto(DadosTEntrevista.CodigoEntrevista); if (tableProduto.Rows.Count > 0) { DadosTSimuladorProduto.IDSimuladorProduto = Convert.ToInt32(tableProduto.Rows[0]["IDSimuladorProduto"]); DadosTSimuladorProduto.IDEntrevista = Convert.ToInt64(tableProduto.Rows[0]["IDEntrevista"]); DadosTSimuladorProduto.Produto = tableProduto.Rows[0]["Produto"].ToString(); DadosTSimuladorProduto.PremioTotal = Convert.ToDecimal(tableProduto.Rows[0]["PremioTotal"]); DadosTSimuladorProduto.FaixaEtaria = Convert.ToInt32(tableProduto.Rows[0]["FaixaEtaria"]); DadosTSimuladorProduto.FaixaEtariaConjuge = Convert.ToInt32(tableProduto.Rows[0]["FaixaEtariaConjuge"]); DadosTSimuladorProduto.RespostaBaseRenda = Convert.ToInt32(tableProduto.Rows[0]["RespostaBaseRenda"]); DadosTSimuladorProduto.RespostaBaseDisposto = Convert.ToInt32(tableProduto.Rows[0]["RespostaBaseDisposto"]); //Verificações para Aba Planos if ((DadosTSimuladorProduto.FaixaEtaria == DadosTEntrevistado.FaixaEtaria) && (DadosTSimuladorProduto.FaixaEtariaConjuge == DadosTEntrevistado.FaixaEtariaConjuge) && (DadosTSimuladorProduto.RespostaBaseRenda == Resposta2) && (DadosTSimuladorProduto.RespostaBaseDisposto == Resposta7)) { int CalculaBase = 0; ControllerPlano.FaixaBase(DadosTEntrevistado.FaixaEtaria, DadosTEntrevistado.FaixaEtariaConjuge, ref CalculaBase); FaixaBase = CalculaBase; ProdutoDisponivel = new List <ProdutoPrincipal>(); if ((FaixaBase <= 6) || (FaixaBase == 8)) { ProdutoDisponivel.Add(ProdutoPrincipal.PLANOPROTECAO); } if ((FaixaBase >= 6) && (FaixaBase != 8)) { ProdutoDisponivel.Add(ProdutoPrincipal.PLANOSENIOR); ProdutoDisponivel.Add(ProdutoPrincipal.PLANOCASAL); } PreencherDominoAbaSimuladorSubPlanos(); alterarAgregado = false; GravarSimulador = false; } else { if (ControllerPlano.SimularPlano(DadosTEntrevistado.DataNascimento.Value, DadosTEntrevistado.DataNascimentoConjuge, Resposta2, Resposta7, ref produtos, ref idadeBase)) { FaixaBase = idadeBase; DadosTPlanoProtecao = ControllerPlano.PlanoProtecaoDOMINIO; DadosTPlanoSenior = ControllerPlano.PlanoSeniorDOMINIO; DadosTPlanoCasal = ControllerPlano.PlanoCasalDOMINIO; PremioTotalMax = ControllerPlano.TotalMax; ProdutoDisponivel = produtos; GravarSimulador = true; TipoRegistro = 'S'; } } } else { if (ControllerPlano.SimularPlano(DadosTEntrevistado.DataNascimento.Value, DadosTEntrevistado.DataNascimentoConjuge, Resposta2, Resposta7, ref produtos, ref idadeBase)) { FaixaBase = idadeBase; DadosTPlanoProtecao = ControllerPlano.PlanoProtecaoDOMINIO; DadosTPlanoSenior = ControllerPlano.PlanoSeniorDOMINIO; DadosTPlanoCasal = ControllerPlano.PlanoCasalDOMINIO; PremioTotalMax = ControllerPlano.TotalMax; ProdutoDisponivel = produtos; GravarSimulador = true; TipoRegistro = 'S'; } DadosTSimuladorProduto.Produto = "Produto"; } //Preenche campos do simulador PreencherCamposSimuladorAbaPlanos(); //Verificações para Aba Agregados PreencherDominoAbaSimuladorSubAgregados(alterarAgregado); if (DadosTPlanoProtecao.IDPlanoProtecao > 0 || DadosTSimuladorProduto.Produto.Equals(ProdutoPrincipal.PLANOPROTECAO.GetStringValue())) { //Verificações para Aba Renda PreencherDominoAbaSimuladorSubRenda(); PreencherCamposSimuladorAbaRenda(); } PreencherCamposTotais(); if (GravarSimulador) { SalvarAbaSimulador(); } } } catch (Exception ex) { Util.CaixaMensagem.ExibirOk(ex.Message); Util.LogErro.GravaLog("Erro ao Simular Plano.", ex.Message); } }