private void btnAba5Sub2Remover_Click(object sender, EventArgs e) { if (lstAba5Sub2Agregado.SelectedIndex > -1) { if (PremioAgregadoTemp.Count > 0) { PremioAgregado -= PremioAgregadoTemp[lstAba5Sub2Agregado.SelectedIndex]; PremioAgregadoTemp.RemoveAt(lstAba5Sub2Agregado.SelectedIndex); } lstAba5Sub2Agregado.Items.RemoveAt(lstAba5Sub2Agregado.SelectedIndex); PreencherCamposTotais(); lblAba5Sub2QuantidadeValor.Text = lstAba5Sub2Agregado.Items.Count.ToString(); } if (lstAba5Sub2Dependente.SelectedIndex > -1) { lstAba5Sub2Dependente.Items.RemoveAt(lstAba5Sub2Dependente.SelectedIndex); lblAba5Sub2QtdDepValor.Text = lstAba5Sub2Dependente.Items.Count.ToString(); } }
private void btnAba5Sub2Adicionar_Click(object sender, EventArgs e) { if (cmbAba5Sub2Parentesco.SelectedIndex > 0 && !string.IsNullOrEmpty(txtAba5Sub2Idade.Text)) { if ((ProdutoCalculo == (int)ProdutoPrincipal.PLANOSENIOR) && (Convert.ToInt32(cmbAba5Sub2Parentesco.SelectedValue) == (int)GrauParentesco.CONJUGE) && (Convert.ToInt32(txtAba5Sub2Idade.Text) >= 61)) { lstAba5Sub2Dependente.Items.Add(cmbAba5Sub2Parentesco.Text + " - " + txtAba5Sub2Idade.Text); lblAba5Sub2QtdDepValor.Text = lstAba5Sub2Dependente.Items.Count.ToString(); return; } else if ((ProdutoCalculo == (int)ProdutoPrincipal.PLANOPROTECAO) && (cmbAba5Sub2Parentesco.Text.Equals(GrauParentesco.FILHO.GetStringValue()) || cmbAba5Sub2Parentesco.Text.Equals(GrauParentesco.ENTEADO.GetStringValue())) && (Convert.ToInt32(txtAba5Sub2Idade.Text) <= 24)) { lstAba5Sub2Dependente.Items.Add(cmbAba5Sub2Parentesco.Text + " - " + txtAba5Sub2Idade.Text); lblAba5Sub2QtdDepValor.Text = lstAba5Sub2Dependente.Items.Count.ToString(); return; } else if (Convert.ToInt32(txtAba5Sub2Idade.Text) > 80) { Util.CaixaMensagem.ExibirOk("O titular não poderá informar um agregado maior que 80 anos."); return; } else { TAgregadoDOMINIO temporario = new TAgregadoDOMINIO(); temporario.GrauParentesco = cmbAba5Sub2Parentesco.Text; temporario.Idade = Convert.ToInt32(txtAba5Sub2Idade.Text); switch (ProdutoCalculo) { case (int)ProdutoPrincipal.PLANOPROTECAO: temporario.Funeral = DadosTPlanoProtecao.NomePlano; temporario.Premio = ControllerPlanoProtecao.CalcularPremioAgregado(Convert.ToInt32(cmbAba5Sub2Parentesco.SelectedValue), temporario.Idade, temporario.Funeral); break; case (int)ProdutoPrincipal.PLANOSENIOR: temporario.Funeral = DadosTPlanoSenior.NomePlano; temporario.Premio = ControllerPlanoSenior.CalcularPremioAgregado(Convert.ToInt32(cmbAba5Sub2Parentesco.SelectedValue), temporario.Idade, temporario.Funeral); break; case (int)ProdutoPrincipal.PLANOCASAL: temporario.Funeral = DadosTPlanoCasal.NomePlano; temporario.Premio = ControllerPlanoCasal.CalcularPremioAgregado(Convert.ToInt32(cmbAba5Sub2Parentesco.SelectedValue), temporario.Idade, temporario.Funeral); break; default: break; } lstAba5Sub2Agregado.Items.Add(temporario.GrauParentesco.Trim() + " - " + temporario.Idade + " - " + String.Format(new CultureInfo("pt-BR"), "{0:C}", temporario.Premio)); PremioAgregadoTemp.Add(temporario.Premio); PremioAgregado += temporario.Premio; cmbAba5Sub2Parentesco.SelectedIndex = 0; txtAba5Sub2Idade.Text = string.Empty; PreencherCamposTotais(); lblAba5Sub2QuantidadeValor.Text = lstAba5Sub2Agregado.Items.Count.ToString(); } } }