コード例 #1
0
        private void carregarEntidade()
        {
            decimal valorLiquido             = 0;
            decimal valorParcelaComissao     = 0;
            decimal valorParcelaAgenciamento = 0;

            if (proposta_id > 0)
            {
                proposta_tb proposta = new PropostaRepositorio().RecuperarPelaChave(proposta_id);

                comissao.proposta_id         = proposta_id;
                comissao.percentual_imposto  = Math.Round(Convert.ToDecimal(txtImposto.Text), 2);
                comissao.percentual_comissao = Math.Round(Convert.ToDecimal(txtComissaoProposta.Text), 2);
                comissao.valor_bruto         = proposta.premio_liquido;
                comissao.valor_liquido       = calculaValorLiquido(comissao.valor_bruto, comissao.percentual_comissao, comissao.percentual_imposto);

                valorParcelaComissao = calculaValorLiquido(comissao.valor_liquido, Convert.ToDecimal(txtComissionamento.Text));

                foreach (var parcela in proposta.proposta_parcela_tb)
                {
                    var comissaoDetalhe = new recibo_comissao_detalhe_tb();
                    comissaoDetalhe.data_pagamento      = parcela.data_vencimento;
                    comissaoDetalhe.percentual_comissao = Math.Round(Convert.ToDecimal(txtComissionamento.Text), 2);
                    comissaoDetalhe.valor_pagamento     = valorParcelaComissao;
                    comissaoDetalhe.status_pagamento    = 0;
                    comissaoDetalhe.corretor_id         = Convert.ToInt16(ddlCorretor.SelectedValue);

                    comissao.recibo_comissao_detalhe_tb.Add(comissaoDetalhe);
                }

                if (Convert.ToBoolean(proposta.agenciamento))
                {
                    valorParcelaAgenciamento = calculaValorLiquido(comissao.valor_liquido, Convert.ToDecimal(txtAgenciamento.Text));

                    foreach (var parcela in proposta.proposta_parcela_tb)
                    {
                        var agenciamentoDetalhe = new recibo_agenciamento_detalhe_tb();
                        agenciamentoDetalhe.data_pagamento      = parcela.data_vencimento;
                        agenciamentoDetalhe.percentual_comissao = Math.Round(Convert.ToDecimal(txtAgenciamento.Text), 2);
                        agenciamentoDetalhe.valor_pagamento     = valorParcelaAgenciamento;
                        agenciamentoDetalhe.status_pagamento    = 0;
                        agenciamentoDetalhe.agenciador_id       = Convert.ToInt16(ddlAgenciador.SelectedValue);

                        comissao.recibo_agenciamento_detalhe_tb.Add(agenciamentoDetalhe);
                    }
                }
            }


            //comissao.valor_bruto = parcela.premio_liquido;
            //comissao.percentual_comissao = Math.Round(Convert.ToDecimal(txtPercentual.Text), 2);
            //comissao.valor_liquido = Math.Round(((comissao.valor_bruto * comissao.imposto) * comissao.percentual_comissao),2);
            //comissao.data_pagamento = parcela.data_vencimento;
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CarregarTela();
            }



            if (!string.IsNullOrEmpty(Request["id"]))
            {
                comissao = new ComissaoRepositorio().RecuperarPelaChave(Convert.ToInt32(Request["id"]));

                //chkAgenciamento.Checked = Convert.ToBoolean(proposta.agenciamento);
                //txtCodigo.Text = proposta.codigo.ToString();
                //txtDataEmissao.Text = proposta.data_emissao.ToString();
                //txtDataProposta.Text = proposta.data_proposta.ToString();
                //txtParcelamento.Text = proposta.parcelamento.ToString();
                //txtPremio.Text = proposta.premio_liquido.ToString();
                //txtPercentual.Text = proposta.percentual_comissao.ToString();
                //chkAgenciamento.Checked = Convert.ToBoolean(proposta.agenciamento);

                estado = EntityState.Modified;
            }
            else
            {
                estado = EntityState.Added;
            }



            if (!string.IsNullOrEmpty(Request["proposta_id"]))
            {
                proposta_id = Convert.ToInt16(Request["proposta_id"]);
                proposta_tb proposta = new PropostaRepositorio().RecuperarPelaChave(proposta_id);
                //txtValorBruto.Text = proposta.premio_liquido.ToString();
            }

            //else if (!string.IsNullOrEmpty(comissao.recibo_comissao_id.ToString())) cotacao_id = proposta.cotacao_id;

            //txtDataEmissao.Text = System.DateTime.Now.ToString();
            //txtDataProposta.Text = System.DateTime.Now.ToString();
            ////txtPremio.Text = string.IsNullOrEmpty(Request["premio"]) ? "" : Request["premio"].ToString();
            txtValorBruto.Enabled   = false;
            txtValorLiquido.Enabled = false;
        }