Esempio n. 1
0
        private void btnAba5Sub5Sub3Remover_Click(object sender, EventArgs e)
        {
            if (lstAba5Sub5Sub3Agregado.SelectedIndex > -1)
            {
                if (PremioAgregadoTabelas.Count > 0)
                {
                    PremioAgregadoTabelas.RemoveAt(lstAba5Sub5Sub3Agregado.SelectedIndex);
                }

                lstAba5Sub5Sub3Agregado.Items.RemoveAt(lstAba5Sub5Sub3Agregado.SelectedIndex);

                cmbAba5Sub5Sub3Parentesco.SelectedIndex = 0;
                txtAba5Sub5Sub3Idade.Text = string.Empty;

                decimal valorTotal = 0;
                foreach (decimal item in PremioAgregadoTabelas)
                {
                    valorTotal += item;
                }
                lblAba5Sub5Sub3PremioAgregadoValor.Text = String.Format(new CultureInfo("pt-BR"), "{0:C}", valorTotal);

                lblAba5Sub5Sub3QuantidadeValor.Text = lstAba5Sub5Sub3Agregado.Items.Count.ToString();
            }
        }
Esempio n. 2
0
        //private void cmbAba5Sub5Sub3Funeral_KeyPress(object sender, KeyPressEventArgs e)
        //{
        //    if (e.KeyChar == 42 || e.KeyChar == 9  || e.KeyChar == 13)
        //    {
        //        TextoCmbAba5Sub5Sub3Funeral = string.Empty;
        //        e.Handled = true;
        //        return;
        //    }

        //    string atual = TextoCmbAba5Sub5Sub3Funeral;

        //    if (e.KeyChar != 13)
        //        TextoCmbAba5Sub5Sub3Funeral += e.KeyChar.ToString();
        //    else
        //    {
        //        e.Handled = true; return;
        //    }

        //    Dictionary<int, string> verificaCombo = DadosCmbAba5Sub5Sub3Funeral.Where(registro => registro.Value.Contains(TextoCmbAba5Sub5Sub3Funeral)).ToDictionary(registro => registro.Key, registro => registro.Value);
        //    if (verificaCombo.Count > 0)
        //    {
        //        ((ComboBox)sender).SelectedValue = verificaCombo.FirstOrDefault().Key;
        //    }
        //    else
        //    {
        //        TextoCmbAba5Sub5Sub3Funeral = atual;
        //    }

        //    e.Handled = true;
        //}

        private void btnAba5Sub5Sub3Adicionar_Click(object sender, EventArgs e)
        {
            if (cmbAba5Sub5Sub3Parentesco.SelectedIndex > 0 && cmbAba5Sub5Sub3Funeral.SelectedIndex > 0 && !string.IsNullOrEmpty(txtAba5Sub5Sub3Idade.Text))
            {
                if ((Convert.ToInt32(cmbAba5Sub5Sub1Produto.SelectedValue) == (int)ProdutoPrincipal.PLANOSENIOR) &&
                    (Convert.ToInt32(cmbAba5Sub5Sub3Parentesco.SelectedValue) == (int)GrauParentesco.CONJUGE) &&
                    (Convert.ToInt32(txtAba5Sub5Sub3Idade.Text) >= 61))
                {
                    Util.CaixaMensagem.ExibirOk("O titular não poderá informar o cônjuge maior de 61 anos como agregado.");
                    return;
                }
                else if ((Convert.ToInt32(cmbAba5Sub5Sub1Produto.SelectedValue) == (int)ProdutoPrincipal.PLANOPROTECAO) &&
                         ((Convert.ToInt32(cmbAba5Sub5Sub3Parentesco.SelectedValue) == (int)GrauParentesco.FILHO) || (Convert.ToInt32(cmbAba5Sub5Sub3Parentesco.SelectedValue) == (int)GrauParentesco.ENTEADO)) &&
                         (Convert.ToInt32(txtAba5Sub5Sub3Idade.Text) <= 24))
                {
                    Util.CaixaMensagem.ExibirOk("O titular não poderá informar o filho/enteado menor de 25 anos como agregado.");
                    return;
                }
                else if (Convert.ToInt32(txtAba5Sub5Sub3Idade.Text) > 80)
                {
                    Util.CaixaMensagem.ExibirOk("O titular não poderá informar um agregado maior que 80 anos.");
                    return;
                }
                else
                {
                    TAgregadoDOMINIO temporario = new TAgregadoDOMINIO();
                    //PremioAgregadoTabelas = new List<decimal>();
                    temporario.GrauParentesco = cmbAba5Sub5Sub3Parentesco.Text;
                    temporario.Idade          = Convert.ToInt32(txtAba5Sub5Sub3Idade.Text);
                    temporario.Funeral        = cmbAba5Sub5Sub3Funeral.Text;
                    switch (Convert.ToInt32(cmbAba5Sub5Sub1Produto.SelectedValue))
                    {
                    case (int)ProdutoPrincipal.PLANOPROTECAO:
                        temporario.Premio           = ControllerPlanoProtecao.CalcularPremioAgregado(Convert.ToInt32(cmbAba5Sub5Sub3Parentesco.SelectedValue), temporario.Idade, temporario.Funeral);
                        cmbAba5Sub5Sub3Funeral.Text = DadosTPlanoProtecao.NomePlano;
                        break;

                    case (int)ProdutoPrincipal.PLANOSENIOR:
                        temporario.Premio           = ControllerPlanoSenior.CalcularPremioAgregado(Convert.ToInt32(cmbAba5Sub5Sub3Parentesco.SelectedValue), temporario.Idade, temporario.Funeral);
                        cmbAba5Sub5Sub3Funeral.Text = DadosTPlanoSenior.NomePlano;
                        break;

                    case (int)ProdutoPrincipal.PLANOCASAL:
                        temporario.Premio           = ControllerPlanoCasal.CalcularPremioAgregado(Convert.ToInt32(cmbAba5Sub5Sub3Parentesco.SelectedValue), temporario.Idade, temporario.Funeral);
                        cmbAba5Sub5Sub3Funeral.Text = DadosTPlanoCasal.NomePlano;
                        break;

                    default:
                        break;
                    }

                    lstAba5Sub5Sub3Agregado.Items.Add(temporario.GrauParentesco.Trim() + " - " + temporario.Idade + " - " + String.Format(new CultureInfo("pt-BR"), "{0:C}", temporario.Premio) + " - " + temporario.Funeral);
                    PremioAgregadoTabelas.Add(temporario.Premio);

                    cmbAba5Sub5Sub3Parentesco.SelectedIndex = 0;
                    txtAba5Sub5Sub3Idade.Text = string.Empty;

                    decimal valorTotal = 0;
                    foreach (decimal item in PremioAgregadoTabelas)
                    {
                        valorTotal += item;
                    }
                    lblAba5Sub5Sub3PremioAgregadoValor.Text = String.Format(new CultureInfo("pt-BR"), "{0:C}", valorTotal);

                    lblAba5Sub5Sub3QuantidadeValor.Text = lstAba5Sub5Sub3Agregado.Items.Count.ToString();

                    cmbAba5Sub5Sub3Parentesco.Focus();
                }
            }
        }