//Retorna HTML da Confirmação de Recebimento public string ConfirmaRecebimento(List <BL_Boleta> Boletas) { Dictionary <long, BL_Cotista> Cotistas = new BL_Cotista().DadosCompleto().ToDictionary(key => key.CODCOT, value => value); string HTMLTEXTO = "<span style='color: #1f497d; font-family: calibri, sans-serif;'>Prezados,<br> <br> Movimentações Recebidas.<br>As confirmações serão enviadas após o processamento.<br><br></span>" + "<span style='font-family: calibri, sans-serif;'><span style='color: #1f497d;'>ID ORDEM (" + Boletas[0].IDORDEM + ")</span></span>"; if (Boletas.Exists(x => x.STATUS == "TCR Pendente" || x.STATUS == "Cadastro Pendente")) { HTMLTEXTO = "<span style='color: #1f497d; font-family: calibri, sans-serif;'>Prezados,<br> <br> Movimentações Recebidas.<br>Favor regularizar a situação cadastral para aporte.<br><br></span>" + "<span style='font-family: calibri, sans-serif;'><span style='color: #1f497d;'>ID ORDEM (" + Boletas[0].IDORDEM + ")</span></span>"; } string HTMLTSITUACAOHEAD = "<br><br><table style='width: 665.75pt; margin-left: .1pt; border-collapse: collapse;' width='0'><tbody><tr style='height: 15.75pt;'>" + "<td style='width: 665.75pt; border: solid #B7B7B7 1.0pt; background: #EAEAEA; padding: 0cm 3.5pt 0cm 3.5pt; height: 15.75pt;' colspan='6' width='878'><p style='text-align: center;'><span style='font-family: calibri, sans-serif;'><strong><span style='color: black;'>Situação Cotistas para Aplicação</span></strong></span></p></td></tr>" + "<tr style='height: 15.75pt;'><td style='width: 211.75pt; border: solid #B7B7B7 1.0pt; border-top: none; background: white; padding: 0cm 3.5pt 0cm 3.5pt; height: 15.75pt;' width='282'>" + "<p style='text-align: center;'><span style='color: #222222; font-family: calibri, sans-serif;'>Nome</span></p></td><td style='width: 130.35pt; border-top: none; border-left: none; border-bottom: solid #B7B7B7 1.0pt; border-right: solid #B7B7B7 1.0pt; background: white; padding: 0cm 3.5pt 0cm 3.5pt; height: 15.75pt;' width='174'>" + "<p style='text-align: center;'><span style='color: #222222; font-family: calibri, sans-serif;'>CPF / CNPJ</span></p></td><td style='width: 130.55pt; border-top: none; border-left: none; border-bottom: solid #B7B7B7 1.0pt; border-right: solid #B7B7B7 1.0pt; background: white; padding: 0cm 3.5pt 0cm 3.5pt; height: 15.75pt;' colspan='2' width='157'>" + "<p style='text-align: center;'><span style='color: #222222; font-family: calibri, sans-serif;'>Fundo</span></p></td><td style='width: 72.6pt; border: none; border-bottom: solid #B7B7B7 1.0pt; background: white; padding: 0cm 3.5pt 0cm 3.5pt; height: 15.75pt;' width='104'>" + "<p style='text-align: center;'><span style='color: #222222; font-family: calibri, sans-serif;'>Vencimento</span></p></td><td style='width: 120.5pt; border: solid #B7B7B7 1.0pt; border-top: none; background: white; padding: 0cm 3.5pt 0cm 3.5pt; height: 15.75pt;' width='161'>" + "<p style='text-align: center;'><span style='color: #222222; font-family: calibri, sans-serif;'>Situação</span></p></td></tr>"; string HTMLSITUACAOBODY = "<tr style='height: 15.75pt;'>" + "<td style='width: 211.75pt; border: solid #B7B7B7 1.0pt; border-top: none; background: white; padding: 0cm 3.5pt 0cm 3.5pt; height: 15.75pt;' width='282'>" + "<p style='text-align: center;'><span style='color: #222222; font-family: calibri, sans-serif;'>{0}</span></p></td><td style='width: 130.35pt; border-top: none; border-left: none; border-bottom: solid #B7B7B7 1.0pt; border-right: solid #B7B7B7 1.0pt; background: white; padding: 0cm 3.5pt 0cm 3.5pt; height: 15.75pt;' width='174'>" + "<p style='text-align: center;'><span style='color: #222222; font-family: calibri, sans-serif;'>{1}</span></p></td><td style='width: 130.55pt; border-top: none; border-left: none; border-bottom: solid #B7B7B7 1.0pt; border-right: solid #B7B7B7 1.0pt; background: white; padding: 0cm 3.5pt 0cm 3.5pt; height: 15.75pt;' colspan='2' width='157'>" + "<p style='text-align: center;'><span style='color: #222222; font-family: calibri, sans-serif;'>{2}</span></p></td><td style='width: 72.6pt; border: none; border-bottom: solid #B7B7B7 1.0pt; background: white; padding: 0cm 3.5pt 0cm 3.5pt; height: 15.75pt;' width='104'>" + "<p style='text-align: center;'><span style='color: #222222; font-family: calibri, sans-serif;'>{3}</span></p></td><td style='width: 120.5pt; border: solid #B7B7B7 1.0pt; border-top: none; background: {4}; padding: 0cm 3.5pt 0cm 3.5pt; height: 15.75pt;' width='161'>" + "<p style='text-align: center;'><span style='color: #222222; font-family: calibri, sans-serif;'>{5}</span></p></td></tr>"; //Retorna texto sem situação cadastral quando não tem aplicação if (Boletas.Where(x => x.OPERACAO == "AP").Count() == 0) { return("<HTML><BODY>" + HTMLTEXTO + "</BODY></HTML>"); } //Situação dos Cotistas foreach (BL_Boleta Boleta in Boletas.Where(x => x.OPERACAO == "AP")) { string Cor() { if (Boleta.STATUS == "Liberado") { return("#E2EFDA"); } else if (Boleta.STATUS == "Pendente") { return("#F8CBAD"); } else { return("#FFB3B3"); } } HTMLTSITUACAOHEAD = HTMLTSITUACAOHEAD + String.Format(HTMLSITUACAOBODY, Boleta.NOME, Boleta.CPFCNPJ, Boleta.FUNDO, Cotistas[Boleta.CODCOT].VENCIMENTO.ToShortDateString(), Cor(), Boleta.STATUS); } return("<HTML><BODY>" + HTMLTEXTO + HTMLTSITUACAOHEAD + "</BODY></HTML>"); }
//Verifica se o CODCOT já existe private void BtnVerificar_Click(object sender, EventArgs e) { if (textboxcodext.Text.Length != 14) { MessageBox.Show("O código do cotista deve possuir 14 digitos."); return; } CadastroCotistaLoad(); if (Int64.TryParse(textboxcodext.Text, out Int64 CODCOT)) { BL_Cotista Cotista = new BL_Cotista().DadosCompleto().FirstOrDefault(x => x.CODCOT == CODCOT); //Carrega informações caso cotista seja encontrado if (Cotista != null) { textboxcpfcnpj.Text = Cotista.CPFCNPJ.ToString(); textboxnome.Text = Cotista.NOME; cmbdistribuidor.SelectedValue = Cotista.CODDIST; cmbalocador.SelectedValue = Cotista.CODALOCADOR; textboxvalidade.Text = Cotista.VENCIMENTO.ToShortDateString(); } else //Busca informações na Intrag caso o cotista não esteja na base { Usuario = new BL_Usuario().DadosNome(WINDOWSNAME); if (Usuario != null && Usuario.USUARIO != "" && Usuario.SENHA != "") { Cotista = new BL_Cotista().ConsultarCotista(Usuario.USUARIO, Usuario.SENHA, CODCOT.ToString()); if (Cotista != null) { textboxcpfcnpj.Text = Cotista.CPFCNPJ.ToString(); textboxnome.Text = Cotista.NOME; } } else { MessageBox.Show("Favor verificar usuário e senha nas Configurações."); } } //Altera Configurações da Página textboxcodext.Enabled = false; BtnVerificar.Enabled = false; PainelCotista.Enabled = true; } }
private void BtnCheckCotista_Click(object sender, EventArgs e) { if (new BL_Validador().CNPJ(TextBoxCpfCnpj.Text) || new BL_Validador().CPF(TextBoxCpfCnpj.Text)) { List <BL_Cotista> Cotistas = new BL_Cotista().DadosPorCPFCNPJ(Convert.ToInt64(TextBoxCpfCnpj.Text)); if (Cotistas.Count > 0) { TextBoxCpfCnpj.Enabled = false; BtnCheckCotista.Enabled = false; cmbCotista.DataSource = Cotistas; cmbCotista.DisplayMember = "NOME"; cmbCotista.ValueMember = "CODCOT"; cmbCotista.Enabled = true; ComboBoxLiquida.Enabled = true; } else { MessageBox.Show("CPF / CNPJ não encontrado"); } } }
//List<long> CODFUNDSRAPTOR = new List<long>(); //Clicks Botoes #region private void BtnIncluir_Click(object sender, EventArgs e) { if (CmbCotista.SelectedIndex == -1) { MessageBox.Show("Nenhum Cotistas Selecionado!"); } else if (CmbBoxOp.SelectedIndex == -1) { MessageBox.Show("Nenhum tipo de Operação Selecionada!"); CmbBoxOp.Focus(); } else if (CmbBoxLiquida.SelectedIndex == -1) { MessageBox.Show("Nenhum tipo de liquidação Selecionada!"); CmbBoxLiquida.Focus(); } else if (CmbBoxConta.SelectedIndex == -1 && !(LabelOp.Text == "Aplicação" && CmbBoxLiquida.Text == "TED")) { MessageBox.Show("Nenhuma conta selecionada!"); CmbBoxConta.Focus(); } else if (TextBoxValor.Text.Length == 0) { MessageBox.Show("Favor preencher o valor da operação!"); TextBoxValor.Focus(); } else if (CheckPorCautela.Checked == true && ComboBoxCautela.SelectedIndex == -1) { MessageBox.Show("Favor selecionar uma cautela!"); } //else if (LabelOp.Text != "Aplicação" && CODFUNDSRAPTOR.Contains(Convert.ToInt64(CmbBoxFIQ.SelectedValue))) { Limpar(); MessageBox.Show("Resgates do Raptor devem ser feitos manualmente!"); } else {//Conversor string Op() { if (LabelOp.Text == "Aplicação") { return("AP"); } else if (CmbBoxOp.Text == "Por Cotas") { return("RC"); } else if (CmbBoxOp.Text == "Total") { return("RT"); } else { return("R"); } } //Variaveis long CODCOT = Convert.ToInt64(CmbCotista.SelectedValue); long CODFUND = Convert.ToInt64(CmbBoxFIQ.SelectedValue); string OPERACAO = Op(); decimal VALOR = Convert.ToDecimal(TextBoxValor.Text); string CONTA = CmbBoxConta.Text; if (CONTA == "") { CONTA = "VIA TED"; } List <BL_Boleta> Boletas = new List <BL_Boleta>(); BL_FIQ Fundo = new BL_FIQ().DadosPorCODFUND(CODFUND); BL_Cotista Cotista = new BL_Cotista().DadosPorCODCOT(CODCOT); if (Op() == "R" && CheckPorCautela.Checked) { MessageBox.Show("Não é possível realizar resgates financeiros por cautela!"); } else if (Op() == "R" && Fundo.LOCKUP != 0) { MessageBox.Show("Não é possível resgatar por financeiro em fundos com lockup!"); } else if (Op() != "AP" && Fundo.LOCKUP != 0 && !CheckPorCautela.Checked) { if (VALOR > new BL_Saldo().DadosPorCODCOTeCODFUND(Cotista.CODCOT, Fundo.CODFUND).QNTCOTAS) { MessageBox.Show("O valor solicitado é maior que o saldo disponível!"); } else { Boletas = new BL_Boleta().BoletaPorCautela(Cotista, Fundo, VALOR, DateTime.Today, Op(), CONTA); } } else if (CheckPorCautela.Checked) { DataGridBoletas.Columns["Cautela"].Visible = true; long CAUTELA = Convert.ToInt64(ComboBoxCautela.SelectedValue); BL_Saldo Cautela = new BL_Saldo().CautelasPorCODCOTeCODFUND(Cotista.CODCOT, Fundo.CODFUND).FirstOrDefault(x => x.CAUTELA == CAUTELA); if (VALOR > Cautela.QNTCOTAS) { MessageBox.Show("O valor solicitado é maior que a quantidade de cotas disponível na cautela!"); } else { Boletas.Add(new BL_Boleta().GeraBoleta(Cotista, Fundo, VALOR, DateTime.Today, Op(), CONTA, CAUTELA)); } } else { Boletas.Add(new BL_Boleta().GeraBoleta(Cotista, Fundo, VALOR, DateTime.Today, Op(), CONTA)); if (Op() == "AP") { Boletas[0].STATUS = new BL_Boleta().VerificarCotista(CODCOT, CODFUND, Properties.Settings.Default.Usuario, Properties.Settings.Default.Senha); } } Boletas.OrderBy(x => x.COTIZACAO).ToList(); foreach (BL_Boleta Boleta in Boletas) { DataGridBoletas.Rows.Add(Boleta.CODCOT, Boleta.CODFUND, Boleta.CPFCNPJ, Boleta.NOME, Boleta.FUNDO, Boleta.OPERACAO, Boleta.STATUS, Boleta.VALOR, Boleta.CONTA, Boleta.COTIZACAO.ToShortDateString(), Boleta.IMPACTO.ToShortDateString(), Boleta.CAUTELA); } Limpar(); } }
private void BtnVerificar_Click(object sender, EventArgs e) { //Valida CPF CNPJ e se tem fundo selecionado if ((new BL_Validador().CNPJ(TextBoxCpfCnpj.Text) || new BL_Validador().CPF(TextBoxCpfCnpj.Text)) && CmbBoxFIQ.SelectedIndex > -1) { FIQ = new BL_FIQ().DadosPorCODFUND(Convert.ToInt64(CmbBoxFIQ.SelectedValue)); List <BL_Cotista> Cotistas = new List <BL_Cotista>(); //Valida se o fundo foi encontrado if (FIQ == null) { MessageBox.Show("Fundo não encontrado!"); return; } //Se for resgate, busca cotistas que possuem saldo no fundo if (LabelOp.Text == "Resgate") { if (FIQ.LOCKUP != 0) { DataGridBoletas.Columns["Cautela"].Visible = true; } Cotistas = new BL_Cotista().DadosPorCPFCNPJeSALDO(Convert.ToInt64(TextBoxCpfCnpj.Text), Convert.ToInt64(CmbBoxFIQ.SelectedValue.ToString())); } else { Cotistas = new BL_Cotista().DadosPorCPFCNPJ(Convert.ToInt64(TextBoxCpfCnpj.Text)); } if (Cotistas.Count > 0) { //Inclui Cotistas na Lista CmbCotista.Enabled = true; BtnVerificar.Enabled = false; TextBoxCpfCnpj.Enabled = false; CmbBoxFIQ.Enabled = false; CmbBoxLiquida.Enabled = true; CmbCotista.DataSource = Cotistas; if (LabelOp.Text == "Resgate") { CmbBoxOp.Enabled = true; TextBoxValor.Enabled = true; } else { TextBoxValor.Enabled = true; } if (Cotistas.Count == 1) { CmbCotista.Enabled = false; } else { CmbCotista.Enabled = true; } } else { if (LabelOp.Text == "Resgate") { MessageBox.Show("CPF / CNPJ não possui saldo no " + CmbBoxFIQ.Text); } else { MessageBox.Show("CPF / CNPJ não retornou cotistas!"); } } } else if (CmbBoxFIQ.SelectedIndex > -1) { MessageBox.Show("CPF ou CNPJ Inválido!"); } else { MessageBox.Show("Favor Selecionar um Fundo!"); } }
private void Btnsalvar_Click(object sender, EventArgs e) { //Valida Código Externo if (textboxcodext.Text.Length != 14) { MessageBox.Show("O código do cotista deve possuir 14 digitos!"); return; } //Valida Nome if (textboxnome.Text.Length == 0) { MessageBox.Show("Favor informar o nome do cotista"); return; } //Valida CPF if (!Int64.TryParse(textboxcpfcnpj.Text, out long CPFCNPJ)) { MessageBox.Show("Erro ao converter CPF/CNPJ, favor verificar!"); return; } //Valida Distribuidor if (cmbdistribuidor.SelectedIndex == -1) { MessageBox.Show("Favor selecionar um Distribuidor!"); return; } //Valida Alocador if (cmbalocador.SelectedIndex == -1) { MessageBox.Show("Favor selecionar um Alocador!"); return; } //Valida Validade if (!DateTime.TryParse(textboxvalidade.Text, out DateTime Data)) { MessageBox.Show("Erro ao converter a data de validade, favor verificar!"); return; } string Nome = textboxnome.Text; long Codcot = Convert.ToInt64(textboxcodext.Text); long Cpfcnpj = CPFCNPJ; long Coddist = Convert.ToInt64(cmbdistribuidor.SelectedValue.ToString()); long Codalocador = Convert.ToInt64(cmbalocador.SelectedValue.ToString()); DateTime Vencimento = Data; BL_Cotista Cotista = new BL_Cotista().DadosCompleto().FirstOrDefault(x => x.CODCOT == Codcot); if (Cotista != null) { if (Cotista.NOME == Nome && Cotista.CODCOT == Codcot && Cotista.CPFCNPJ == Cpfcnpj && Cotista.CODDIST == Coddist && Cotista.CODALOCADOR == Codalocador && Cotista.VENCIMENTO == Vencimento) { MessageBox.Show("Cotista já cadastrado na base!"); } else { new BL_Cotista().Editar(Codcot, Nome, Cpfcnpj, Coddist, Codalocador, Vencimento); MessageBox.Show("Cadastro alterado com sucesso!"); } } else { new BL_Cotista().Inserir(Codcot, Nome, Cpfcnpj, Coddist, Codalocador, Vencimento); MessageBox.Show("Cotista Salvo Com Sucesso!"); } textboxcodext.Text = ""; textboxcpfcnpj.Text = ""; textboxnome.Text = ""; textboxvalidade.Text = ""; cmbalocador.SelectedIndex = -1; cmbdistribuidor.SelectedIndex = -1; textboxcodext.Enabled = true; BtnVerificar.Enabled = true; PainelCotista.Enabled = false; }
private void ProcessarDataGrid() { //Carrega Base de Cotistas Cotistas = new BL_Cotista().DadosPorCPFCNPJ(Convert.ToInt64(CmbBoxDistribuidor.SelectedValue.ToString())); //Carrega Saldos Saldos = new BL_Saldo().DadosPorCPFCNPJ(Convert.ToInt64(CmbBoxDistribuidor.SelectedValue.ToString())); //Contas Contas = new BL_ContaCredito().DadosPorCPFCNPJ(Convert.ToInt64(CmbBoxDistribuidor.SelectedValue.ToString())); //Percorre todas Boletas foreach (DataGridViewRow DR in DataGridBoletas.Rows) { BL_FIQ FundoAux = Fundos.FirstOrDefault(x => x.CODFUND == Convert.ToInt64(DR.Cells[5].Value)); if (FundoAux == null) { MessageBox.Show("Fundo não encontrado!"); continue; } //Seleciona o cotista pelo nome e cnpj BL_Cotista CotistaAux = Cotistas.FirstOrDefault(x => x.NOME == DR.Cells[0].Value.ToString() && x.CPFCNPJ == Convert.ToInt64(DR.Cells[1].Value)); if (CotistaAux != null) { DR.Cells[2].Value = CotistaAux.CODCOT; DR.Cells[8].Value = "Cadastrado"; } //Aplicação if (DR.Cells[3].Value.ToString() == "AP" && DR.Cells[2].Value.ToString().Length == 14) { DR.Cells[8].Value = "Liberado"; } //Contas Cadastradas if (DR.Cells[3].Value.ToString() != "AP" && DR.Cells[2].Value.ToString().Length == 14) { long BANCO = Convert.ToInt64(DR.Cells[7].Value.ToString().Split('-')[0]); long AGENCIA = Convert.ToInt64(DR.Cells[7].Value.ToString().Split('-')[1]); long CONTA = Convert.ToInt64(DR.Cells[7].Value.ToString().Split('-')[2]); long DIGITO = Convert.ToInt64(DR.Cells[7].Value.ToString().Split('-')[3]); if (Contas.Where(x => x.CODCOT == Convert.ToInt64(DR.Cells[2].Value) && BANCO == x.BANCO && AGENCIA == x.AGENCIA && CONTA == Convert.ToInt64(x.CONTA) && DIGITO == x.DIGITO).ToList().Count > 0) { DR.Cells[8].Value = "Conta Cadastrada"; } else { DR.Cells[8].Value = "Conta Pendente"; } } //Saldo Para cotistas com status Conta Cadastrada if (DR.Cells[3].Value.ToString() != "AP" && DR.Cells[8].Value.ToString() == "Conta Cadastrada") { //Saldo Auxiliar BL_Saldo SaldoAux = Saldos.FirstOrDefault(x => x.CODCOT == Convert.ToInt64(DR.Cells[2].Value) && x.CODFUND == Convert.ToInt64(DR.Cells[5].Value) && x.TIPOREGISTRO == "Total"); if (SaldoAux == null) { continue; } if (DR.Cells[3].Value.ToString() == "RT") { DR.Cells[6].Value = Convert.ToDecimal(SaldoAux.QNTCOTAS).ToString(); DR.Cells[8].Value = "Liberado"; } else if (DR.Cells[3].Value.ToString() == "R") { decimal Cota = new BL_Cota().UltimaCota(FundoAux.CODFUND).COTA; //Valida se vai ferir saldo minimo if (SaldoAux.QNTCOTAS * Cota - Convert.ToDecimal(DR.Cells[6].Value) >= FundoAux.Valorsaldominimo && Convert.ToDecimal(DR.Cells[6].Value) >= FundoAux.VALORMINRES) { DR.Cells[8].Value = "Liberado"; } } else if (DR.Cells[3].Value.ToString() == "RC") { decimal Cota = new BL_Cota().UltimaCota(FundoAux.CODFUND).COTA; //Valida se vai ferir saldo minimo if ((SaldoAux.QNTCOTAS - Convert.ToDecimal(DR.Cells[6].Value)) * Cota >= FundoAux.Valorsaldominimo && Convert.ToDecimal(DR.Cells[6].Value) * Cota >= FundoAux.VALORMINRES) { DR.Cells[8].Value = "Liberado"; } } } } }