private void mnuExportarGerarArquivo_Click(object sender, EventArgs e) { try { lblExportarTotalDeContratos.Focus(); lblExportarTotalDeContratos.Text = @"Iniciando Exportação."; List <ParcelaController> Export = new List <ParcelaController>(); for (int y = 0; y < dgwExportarLista.RowCount; y++) { if (Convert.ToBoolean(dgwExportarLista.Rows[y].Cells["exportExportar"].Value) == true) { ParcelaController Contrato = new ParcelaController(); Contrato.TB012_id = Convert.ToInt64(dgwExportarLista.Rows[y].Cells["ExportTB012_id"].Value.ToString()); Export.Add(Contrato); } } ParcelaNegocios Parcela_N = new ParcelaNegocios(); string Arquivo = Parcela_N.ParcelasExportarBoletos(Export, Convert.ToInt32(cmbExportarCiclo.Text), lblExportarLocalArquivo.Text); MessageBox.Show(Arquivo, @"Arquivo Exportado", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, @"Erro ao executar operação", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void mnuConfirmacaoManualParcelaSalvar_Click(object sender, EventArgs e) { if (ValidarPagamentoManual()) { try { ParcelaController Boleto = new ParcelaController(); Boleto.TB016_id = Convert.ToInt64(lblConfirmacaoManualParcela.Text); Boleto.TB016_StatusS = "5"; Boleto.TB016_DataPagamento = dtmCadDependenteDataNascimento.Value; Boleto.TB016_ValorPago = Convert.ToDouble(mskConfirmacaoManualParcelaValorPago.Text.Replace("R$", "")); ParcelaNegocios Parcela_N = new ParcelaNegocios(); if (Parcela_N.BaixaBoletoImportacao(Boleto, ParametrosInterface.objUsuarioLogado.TB011_Id)) { PessoaNegocios Pessoa_N = new PessoaNegocios(); Pessoa_N.GerarCartoes(Convert.ToInt64(lblConfirmacaoManualPagadorID.Text), ParametrosInterface.objUsuarioLogado.TB011_Id); ContratoNegocios Contrato_N = new ContratoNegocios(); Contrato_N.contratoAtivar(Convert.ToInt64(lblConfirmacaoManualContrato.Text), ParametrosInterface.objUsuarioLogado.TB011_Id); MessageBox.Show(MensagensDoSistema._0025.ToString(), "Atualização", MessageBoxButtons.OK, MessageBoxIcon.Information); tabPrincipal.TabPages.Add(tbLista); tabPrincipal.TabPages.Remove(tbConfirmacaoManual); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro ao executar operação", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void mnuCreditoDebito_Click(object sender, EventArgs e) { if (ValidarDebito()) { mnuCreditoDebito.Enabled = false; ParcelaController Pagamento = new ParcelaController(); Pagamento.TB016_id = Convert.ToInt64(lblCredParcelaId.Text); Pagamento.TB016_DataPagamento = DateTime.Now; Pagamento.TB016_FormaProcessamentoBaixa = 1 /*Digitação Atendente*/; Pagamento.TB016_CredNCartao = txtCredNCartao.Text; Pagamento.TB016_CredCPFTitularCartaoCartao = mskCredCPFTitularCartao.Text; Pagamento.TB016_CredNomeTitularCartaoCartao = txtCredNomeCompletoTitularCartao.Text; Pagamento.TB016_CredBandeira = 0; Pagamento.TB016_CredNParcelas = 1; Pagamento.TB016_CredValorParcelas = Convert.ToDouble(lblDebValorParcela.Text.Replace("R$", "")); Pagamento.TB016_CredAutorizacao = txtDebAutorizacao.Text; Pagamento.TB016_CredCodValidador = txtDebCodValidador.Text; Pagamento.TB012_id = Convert.ToInt64(lblCredContrato.Text); Pagamento.TB016_CredFormaParamentoId = 2; Pagamento.TB016_CredFormaParamentoDescricao = lblDebDescricaoFormaPagamento.Text; Pagamento.TB016_AlteradoEm = DateTime.Now; Pagamento.TB016_AlteradoPor = ParametrosInterface.objUsuarioLogado.TB011_Id; Pagamento.TB016_CredBaixaFeitaEm = DateTime.Now; Pagamento.TB016_CredBaixaFeitaPor = ParametrosInterface.objUsuarioLogado.TB011_Id; Pagamento.TB016_StatusS = "5"; Pagamento.TB016_CredDataCredito = Convert.ToDateTime(lblDebVencimentoCartao.Text); Pagamento.TB016_ValorPago = Convert.ToDouble(lblDebValorParcela.Text.Replace("R$", "")); Pagamento.TB016_CredValor = Convert.ToDouble(lblDebValorCredito.Text.Replace("R$", "")); ParcelaNegocios Pagamento_N = new ParcelaNegocios(); if (Pagamento_N.ParcelaInserirPagamentoCredParcela(Pagamento, 0)) { tB016_ParcelaTableAdapter.Connection.ConnectionString = ParametrosInterface.ConectReport; tB016_ParcelaTableAdapter.Fill(clubeContezaRelatorios.TB016_Parcela, Pagamento.TB016_id); this.rptComprovanteCredito.RefreshReport(); ContratoDocNegocios Doc_N = new ContratoDocNegocios(); Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; ContratoDocController Documento = new ContratoDocController(); Documento.TB029_DocImpressaoPor = ParametrosInterface.objUsuarioLogado.TB011_Id; Documento.TB029_TipoS = "3"; Documento.TB012_id = Pagamento.TB012_id; Documento.TB029_DocImpressao = this.rptComprovanteCredito.LocalReport.Render("Pdf", null, out mimeType, out encoding, out extension, out streamids, out warnings); ContratoDocController Doc = Doc_N.DocImpressaoInserir(Documento); } } }
private void SICOOB240ProcessarArquivo(string PathArquivo) { List <ParcelaController> Boletos = new List <ParcelaController>(); int counter = 0; string line; StreamReader Arquivo = new StreamReader(PathArquivo); while ((line = Arquivo.ReadLine()) != null) { if (counter > 0 & counter < Convert.ToInt16(lblRegistrosNoArquivo.Text) + 1) { string TB016_id = line.Substring(116, 8).TrimEnd().TrimStart(); string TB016_ValorPago = line.Substring(154, 11).TrimEnd().TrimStart(); TB016_ValorPago = TB016_ValorPago.Insert(TB016_ValorPago.Length - 2, ",").TrimStart('0'); string TB016_NossoNumero = line.Substring(62, 12).TrimEnd().TrimStart().TrimStart('0'); string TB016_DataPagamento = line.Substring(146, 6).TrimEnd().TrimStart(); string Ano = TB016_DataPagamento.Substring(4, 2); string Dia = TB016_DataPagamento.Substring(0, 2); string Mes = TB016_DataPagamento.Substring(2, 2); DateTime Data = new DateTime(Convert.ToInt16("20" + Ano), Convert.ToInt16(Mes), Convert.ToInt16(Dia)); ParcelaController Boleto = new ParcelaController(); Boleto.TB016_id = Convert.ToInt64(TB016_id); Boleto.TB016_NossoNumero = TB016_NossoNumero; Boleto.TB016_DataPagamento = Data; Boleto.TB016_ValorPago = Convert.ToDouble(TB016_ValorPago);; Boletos.Add(Boleto); lblRegistrosProcessados.Text = counter.ToString(); prbRegistros.Value = counter; } counter++; } Arquivo.Close(); lblImportarBoletosEncontrados.Text = Boletos.Count.ToString(); /*Atualizar Boletos*/ ParcelaNegocios Parcela_N = new ParcelaNegocios(); int ParcelaInsert = 0; foreach (ParcelaController Parcela in Boletos) { if (Parcela_N.BaixaBoletoImportacao(Parcela, ParametrosInterface.objUsuarioLogado.TB011_Id)) { ParcelaInsert++; } } }
private void cmbCredParcelas_SelectionChangeCommitted(object sender, EventArgs e) { try { ParcelaNegocios Parcela_N = new ParcelaNegocios(); ParcelaController Retorno = Parcela_N.SelectFormaParamento(Convert.ToInt64(cmbCredParcelas.SelectedValue)); lblCredValorMinimoParcela.Text = double.Parse(Retorno.TB031_ValorMinimoParcela.ToString()).ToString("C2"); lblCredDescricaoPagamento.Text = Retorno.TB031_Descricao; lblCredTipoVencimento.Text = Retorno.TB031_TipoVencimento.ToString(); DateTime VencimentoCartao = DateTime.Now.AddDays(Retorno.TB031_DVencimento); lblCredVencimentoCartao.Text = VencimentoCartao.ToString("dd/MM/yyyy"); lblCredTaxas.Text = double.Parse(Retorno.TB031_Taxa.ToString()).ToString("C2"); double ValorCredito = Convert.ToDouble(lblCredValorTotal.Text.ToString().Replace("R$", "")) - Convert.ToDouble(lblCredTaxas.Text.ToString().Replace("R$", "")); lblCredValorCredito.Text = double.Parse(ValorCredito.ToString()).ToString("C2"); if (Convert.ToInt16(cmbCredParcelas.Text) > 0) { double Valor = Convert.ToDouble(lblCredValorTotal.Text.Replace("R$", "")); double Minimo = Convert.ToDouble(lblCredValorMinimoParcela.Text.Replace("R$", "")); double Resultado = Valor / Convert.ToInt16(cmbCredParcelas.Text); lblCredValorParcela.Text = double.Parse(Resultado.ToString()).ToString("C2"); if (Resultado < Minimo) { mnuCreditoEmitir.Enabled = false; MessageBox.Show(string.Format(MensagensDoSistema._0063, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)); } else { mnuCreditoEmitir.Enabled = true; } } else { lblCredValorMinimoParcela.Text = ""; lblCredValorParcela.Text = ""; lblCredDescricaoPagamento.Text = ""; lblCredVencimentoCartao.Text = ""; MessageBox.Show(string.Format(MensagensDoSistema._0062, "N.º Parcelas", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro ao executar operação", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cmbCredBandeira_SelectionChangeCommitted(object sender, EventArgs e) { try { if (Convert.ToInt16(cmbCredBandeira.SelectedValue) > 0) { cmbCredParcelas.DataSource = null; cmbCredParcelas.Items.Clear(); ParcelaNegocios Parcela_N = new ParcelaNegocios(); ParcelaController Retorno = Parcela_N.ParcelaPagamento(TB016_id); cmbCredParcelas.DataSource = Parcela_N.ListaParcelamentoPossivelPorBandeira(Convert.ToInt64(cmbCredBandeira.SelectedValue), Convert.ToInt64(lblCredUnidade.Text)); cmbCredParcelas.DisplayMember = "TB031_NParcelas"; cmbCredParcelas.ValueMember = "TB031_Id"; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro ao executar operação", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSolicitarBoleto_Click(object sender, EventArgs e) { try { if (lblContrato.Text.Trim() == string.Empty) { MessageBox.Show("Selecione uma parcela", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } btnSolicitarBoleto.Enabled = false; ParcelaNegocios Parcela_N = new ParcelaNegocios(); ParcelaController Parcela = Parcela_N.ParcelaId(Convert.ToInt64(lblExpParcela.Text)); if (Parcela.TB016_id > 0) { if (Parcela_N.EmitirBoletoAvulsto(Parcela, ParametrosInterface.objUsuarioLogado.TB011_Id, Convert.ToInt64(lblExpParcela.Text))) { dgwParcelas.AutoGenerateColumns = false; dgwParcelas.DataSource = Parcela_N.ParcelasListarAtivasPorContrato(Convert.ToInt64(lblContrato.Text), Convert.ToInt32(cmbExportarCiclo.Text)); dgwParcelas.Refresh(); lblExpParcela.Text = ""; lblExpNossoNumero.Text = ""; } } btnSolicitarBoleto.Enabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro ao executar operação", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void dtgBoletos_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex > -1 && e.ColumnIndex > -1) { switch (dtgBoletos.Columns[e.ColumnIndex].HeaderText) { case "Parcela": ParcelaNegocios Parcela_N = new ParcelaNegocios(); ParcelaController Parcela = Parcela_N.ParcelaPesquisaId(Convert.ToInt64(dtgBoletos.Rows[e.RowIndex].Cells["TB016_id"].Value)); lblConfirmacaoManualParcela.Text = Parcela.TB016_id.ToString(); lblConfirmacaoManualCPFCNPJ.Text = Parcela.TB016_CPFCNPJ.ToString(); lblConfirmacaoManualNomeCompleto.Text = Parcela.TB016_Pagador.ToString(); lblConfirmacaoManualContrato.Text = Parcela.TB012_id.ToString(); lblConfirmacaoManualEmissao.Text = Parcela.TB016_Emissao.ToString("dd/MM/yyyy"); lblConfirmacaoManualValorParcela.Text = "R$ " + Parcela.TB016_Valor.ToString("#,##0.00"); lblConfirmacaoManualVencimento.Text = Parcela.TB016_Vencimento.ToString("dd/MM/yyyy"); lblConfirmacaoManualStatusPagamento.Text = Parcela.TB016_StatusS; lblConfirmacaoManualPagadorID.Text = Parcela.Titular.TB013_id.ToString(); tabPrincipal.TabPages.Add(tbConfirmacaoManual); tabPrincipal.TabPages.Remove(tbLista); //FiltrarContrato(Convert.ToInt64(dtgBoletos.Rows[e.RowIndex].Cells["TB016_id"].Value)); break; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro ao executar operação", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CarregarDadosParcela() { try { ParcelaNegocios Parcela_N = new ParcelaNegocios(); ParcelaController Retorno = Parcela_N.ParcelaPagamento(TB016_id); lblCredUnidade.Text = Retorno.Empresa.TB001_id.ToString(); lblCredContrato.Text = Retorno.TB012_id.ToString(); lblCredCPFCNPJ.Text = Retorno.TB016_CPFCNPJ; mskCredCPFTitularCartao.Text = Retorno.TB016_CPFCNPJ; lblCredNomeCompleto.Text = Retorno.TB016_Pagador; txtCredNomeCompletoTitularCartao.Text = Retorno.TB016_Pagador; lblCredPlano.Text = Retorno.Plano.TB015_Plano; lblCredParcelaId.Text = Retorno.TB016_id.ToString(); lblCredParcela.Text = Retorno.TB016_Parcela.ToString(); lblCredEmissao.Text = Retorno.TB016_Emissao.ToString("dd/MM/yyyy"); lblCredVencimento.Text = Retorno.TB016_Vencimento.ToString("dd/MM/yyyy"); lblCredValorTotal.Text = double.Parse(Retorno.TB016_Valor.ToString()).ToString("C2"); if (Retorno.TB016_FormaPagamentoS == "6") { tbPrincipal.TabPages.Add(tbpCredito); cmbCredBandeira.DataSource = null; cmbCredBandeira.Items.Clear(); cmbCredBandeira.DataSource = Parcela_N.ListarBandeiraCartao(); cmbCredBandeira.DisplayMember = "TB032_BandeiraCartao"; cmbCredBandeira.ValueMember = "TB032_Id"; txtCredNCartao.Focus(); mnuCreditoEmitir.Visible = true; } else { if (Retorno.TB016_FormaPagamentoS == "3") { tbPrincipal.TabPages.Add(tbpDebito); lblDebValorParcela.Text = double.Parse(Retorno.TB016_Valor.ToString()).ToString("C2"); //cmbDebBanco /**/ ParcelaController FormaPagamento = Parcela_N.SelectFormaParamento(3); lblDebDescricaoFormaPagamento.Text = FormaPagamento.TB031_Descricao; lblDebVencimento.Text = FormaPagamento.TB031_TipoVencimento.ToString(); DateTime VencimentoCartao = DateTime.Now.AddDays(FormaPagamento.TB031_DVencimento); lblDebVencimentoCartao.Text = VencimentoCartao.ToString("dd/MM/yyyy"); lblDebTaxas.Text = double.Parse(FormaPagamento.TB031_Taxa.ToString()).ToString("C2"); double ValorCredito = Convert.ToDouble(lblDebValorParcela.Text.ToString().Replace("R$", "")) - Convert.ToDouble(lblDebTaxas.Text.ToString().Replace("R$", "")); lblDebValorCredito.Text = double.Parse(ValorCredito.ToString()).ToString("C2"); /**/ mnuCreditoDebito.Visible = true; txtCredNCartao.Focus(); } else { if (Retorno.TB016_FormaPagamentoS == "2") { mnuCreditoDinheiro.Visible = true; txtCredNCartao.Enabled = false; mskCredCPFTitularCartao.Enabled = false; txtCredNomeCompletoTitularCartao.Enabled = false; tbPrincipal.TabPages.Add(tbpDinheiro); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro ao executar operação", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void RenovarPlanoFamiliar() { try { txtMensagens.Focus(); txtMensagens.Text = "Iniciando processo de renovação."; for (int y = 0; y < dgwLista.RowCount; y++) { if (Convert.ToBoolean(dgwLista.Rows[y].Cells["Renovar"].Value) == true) { List <ParcelaController> Parcelas = new List <ParcelaController>(); /*Dados da Ultima Parcela*/ ParcelaNegocios Parcela_N = new ParcelaNegocios(); ParcelaController UltimaParcela = new ParcelaController(); UltimaParcela = Parcela_N.UltimaParcelaRenovacao(Convert.ToInt64(dgwLista.Rows[y].Cells["TB012_id"].Value.ToString())); /****************************************************/ try { for (int i = 0; i < 12; i++) { ParcelaController Parcela = new ParcelaController(); PlanoController objPlano = new PlanoController(); Parcela.Plano = objPlano; if (cnkExportarArquivo.Checked == true) { Parcela.TB016_LoteExportacao = 0; } else { Parcela.TB016_LoteExportacao = -1; } List <ParcelaProdutosController> ParcelaItens_L = new List <ParcelaProdutosController>(); //Recuperar Empresa Pelo Local de Cadastro PontoDeVendaNegocios PontoDeVenda_N = new PontoDeVendaNegocios(); EmpresaNegocios Empresa_N = new EmpresaNegocios(); PontoDeVendaController Ponto = new PontoDeVendaNegocios().PontoDeVendaEmpresa(Convert.ToInt64(dgwLista.Rows[y].Cells["TB002_id"].Value.ToString())); Parcela.Empresa = new EmpresaNegocios().Empresa(Ponto.Empresa.TB001_id); PessoaNegocios Titular_N = new PessoaNegocios(); Parcela.Pessoa = Titular_N.pessoaSelectId(Convert.ToInt64(dgwLista.Rows[y].Cells["TB013_id"].Value.ToString())); Parcela.Pessoa.Municipio.TB006_Municipio = Parcela.Pessoa.Municipio.TB006_Municipio; Parcela.Pessoa.Municipio.Estado.TB005_Estado = Parcela.Pessoa.Municipio.Estado.TB005_Estado; Parcela.Pessoa.TB013_CPFCNPJ = dgwLista.Rows[y].Cells["TB013_CPFCNPJ"].Value.ToString().Replace(".", "").Replace(",", "").Replace("/", "").Replace("-", "").Trim(); Parcela.TB012_id = Convert.ToInt64(dgwLista.Rows[y].Cells["TB012_id"].Value.ToString()); Parcela.TB016_Parcela = i + 1; Parcela.TB016_Emissao = DateTime.Now; Int32 Ano = Convert.ToInt32(cmbPesquisaCiclo.Text.Substring(cmbPesquisaCiclo.Text.Length - 4, 4)); Int16 Mes = Convert.ToInt16(cmbPesquisaCiclo.Text.Replace(Ano.ToString(), "")); Ano++; string Ciclo = Mes.ToString() + Ano.ToString(); Parcela.TB012_CicloContrato = Convert.ToInt32(Ciclo); Parcela.TB016_FormaPagamentoS = "1"; Parcela.TB016_EmitirBoleto = 1; if (i == 0) { Parcela.TB016_Vencimento = Convert.ToDateTime(UltimaParcela.TB016_Vencimento.Day + "/" + UltimaParcela.TB016_Vencimento.Month + "/" + UltimaParcela.TB016_Vencimento.Year).AddMonths(1); } else { Parcela.TB016_Vencimento = Convert.ToDateTime(Parcelas[i - 1].TB016_Vencimento.Day + "/" + Parcelas[i - 1].TB016_Vencimento.Month + "/" + Parcelas[i - 1].TB016_Vencimento.Year).AddMonths(1); } Parcela.TB016_StatusS = "1"; //Filtrar Distribuição de major, menor e isento PessoaNegocios Participantes_N = new PessoaNegocios(); List <CategoriaIdadeControler> Participantes_L = Participantes_N.MembrosAtivosDoConrato(Convert.ToInt64(dgwLista.Rows[y].Cells["TB012_id"].Value.ToString()), Parcela.TB016_Vencimento); CategoriaIdadeNegocios CategoriaIdade_N = new CategoriaIdadeNegocios(); CategoriaIdadeControler DadosFiltroIdade = CategoriaIdade_N.DistribuicaoIsencaoIdade(Participantes_L); //Localiar Plano's conforme itens de filtro PlanoController filtro = new PlanoController(); PontoDeVendaController ObjPontoDeVenda = new PontoDeVendaController(); filtro.PontoDeVenda = ObjPontoDeVenda; filtro.TB015_Maiores = DadosFiltroIdade.Maior; filtro.TB015_Menores = DadosFiltroIdade.Menor; filtro.TB015_Isentos = DadosFiltroIdade.Isento; filtro.PontoDeVenda.TB002_id = Convert.ToInt64(Convert.ToInt64(dgwLista.Rows[y].Cells["TB002_id"].Value.ToString())); PlanoNegocios Plano_N = new PlanoNegocios(); DataSet Plano = new DataSet(); Plano = Plano_N.PlanoVendaContezino(filtro, 1, 0, 1); Parcela.Plano.TB015_Maiores = filtro.TB015_Maiores; Parcela.Plano.TB015_Menores = filtro.TB015_Menores; Parcela.Plano.TB015_Isentos = filtro.TB015_Isentos; Parcela.Plano.TB015_IOF = Convert.ToDouble(Plano.Tables[0].Rows[0]["TB015_IOF"].ToString()); Parcela.Plano.TB015_TipoVencimento = Convert.ToInt16(Plano.Tables[0].Rows[0]["TB015_TipoVencimento"].ToString()); Parcela.Plano.TB015_EspecieDocumento = Plano.Tables[0].Rows[0]["TB015_EspecieDocumento"].ToString(); Parcela.Plano.TB015_BoletoDesc1 = Plano.Tables[0].Rows[0]["TB015_BoletoDesc1"].ToString(); Parcela.Plano.TB015_BoletoDesc2 = Plano.Tables[0].Rows[0]["TB015_BoletoDesc2"].ToString(); Parcela.Plano.TB015_BoletoDesc3 = Plano.Tables[0].Rows[0]["TB015_BoletoDesc3"].ToString(); Parcela.Plano.TB015_BoletoDesc4 = Plano.Tables[0].Rows[0]["TB015_BoletoDesc4"].ToString(); Parcela.Plano.TB015_BoletoDesc5 = Plano.Tables[0].Rows[0]["TB015_BoletoDesc5"].ToString(); Parcela.TB016_Juros = Convert.ToDouble(Plano.Tables[0].Rows[0]["TB015_Juros"].ToString()); Parcela.TB016_Multa = Convert.ToDouble(Plano.Tables[0].Rows[0]["TB015_Multa"].ToString()); Parcela.TB016_DiaVencimento = Parcela.TB016_Vencimento.Day; //Incluir Planos Possiveis para cada Parcela Parcela.TB016_Valor = Convert.ToDouble(Plano.Tables[0].Rows[0]["ValorPlano"].ToString()); Parcela.TB015_id = Convert.ToInt64(Plano.Tables[0].Rows[0]["TB015_id"].ToString()); Parcela.TB015_Plano = Plano.Tables[0].Rows[0]["TB015_Plano"].ToString(); Parcela.TB016_Entrada = 0; Parcela.TB016_ValorAdesao = 0; ProdutoNegocios PlanoProduto_N = new ProdutoNegocios(); List <ProdutoController> PlanoProduto_L = PlanoProduto_N.ProdutoPlano(Parcela.TB015_id); //*******************Inserir Parcela foreach (ProdutoController Produto in PlanoProduto_L) { ParcelaProdutosController ParcelaItem = new ParcelaProdutosController(); ParcelaItem.TB017_id = Produto.TB014_id; ParcelaItem.TB017_IdProteus = Produto.TB014_IdProtheus; ParcelaItem.TB017_Item = Produto.TB014_Produto; ParcelaItem.TB017_Maior = Produto.TB014_Maiores; ParcelaItem.TB017_Menor = Produto.TB014_Menores; ParcelaItem.TB017_Isento = Produto.TB014_Isentos; if (Produto.TB014_Menores > 0) { Produto.TB014_ValorUnitario = Produto.TB014_ValorUnitario * filtro.TB015_Menores; ParcelaItem.TB017_Item = ParcelaItem.TB017_Item + "( * " + filtro.TB015_Menores + ")"; } if (Produto.TB014_Isentos > 0) { ParcelaItem.TB017_Item = ParcelaItem.TB017_Item + "( * " + filtro.TB015_Isentos + ")"; Produto.TB014_ValorUnitario = Produto.TB014_ValorUnitario * filtro.TB015_Isentos; } ParcelaItem.TB017_ValorUnitario = Produto.TB014_ValorUnitario; if (Produto.TB014_ValorMultiplo == 1) { ParcelaItem.TB017_ValorUnitario = (ParcelaItem.TB017_ValorUnitario * ParcelaItem.TB017_Maior) + (ParcelaItem.TB017_ValorUnitario * ParcelaItem.TB017_Menor); Produto.TB014_ValorUnitario = (Produto.TB014_ValorUnitario * ParcelaItem.TB017_Maior) + (Produto.TB014_ValorUnitario * ParcelaItem.TB017_Menor); } ParcelaItem.TB017_ValorDesconto = 0; ParcelaItem.TB017_ValorFinal = Produto.TB014_ValorUnitario - ParcelaItem.TB017_ValorDesconto; string[] vValor = ParcelaItem.TB017_ValorFinal.ToString().Split(','); string v1 = vValor[0]; string v2 = "0"; if (ParcelaItem.TB017_ValorFinal > 0.01) { if (vValor[1].Length > 1) { v2 = vValor[1].Substring(0, 2); } else { v2 = vValor[1]; } } ParcelaItem.TB017_ValorFinal = Convert.ToDouble(v1 + "," + v2); ParcelaItens_L.Add(ParcelaItem); } double Valor = 0; for (int p = 0; p < ParcelaItens_L.Count; p++) { Valor = Valor + ParcelaItens_L[p].TB017_ValorFinal; } Parcela.TB016_Valor = Valor; /*Inserir Produto da Parcela*/ Parcela.ParcelaProduto_L = ParcelaItens_L; Parcelas.Add(Parcela); } Parcela_N.GerarCobrancasParcela(Parcelas, ParametrosInterface.objUsuarioLogado.TB011_Id); /*Alterar Ciclo do contrato*/ ContratoNegocios Contrato_N = new ContratoNegocios(); Contrato_N.CicloContratoAtualizar(Convert.ToInt64(dgwLista.Rows[y].Cells["TB012_id"].Value.ToString()), Parcelas[0].TB012_CicloContrato, ParametrosInterface.objUsuarioLogado.TB011_Id, UltimaParcela.TB016_Vencimento.AddYears(1)); /*Gerar Boletos*/ List <ParcelaController> BoletosEmitidos = Parcela_N.ParcelasParaEmissaoBoleto(Convert.ToInt64(dgwLista.Rows[y].Cells["TB012_id"].Value.ToString()), ParametrosInterface.objUsuarioLogado.TB011_Id, 0); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro ao executar operação", MessageBoxButtons.OK, MessageBoxIcon.Error); } /*****************************************************/ } } /*Atualizar List*/ PopularListaParaRenovacao(); lblExportarTotalDeContratos.Text = "Boletos emitidos, pronto para exportar aquivo"; mnuListaRenovar.Enabled = true; MessageBox.Show("Operação Concluida", "Renovação", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro ao executar operação", MessageBoxButtons.OK, MessageBoxIcon.Error); } }