//Macros Ativadas por variações no formulário #region private void CmbCotista_SelectedIndexChanged(object sender, EventArgs e) { //Encontra Saldo para CODCOT + CODFUND if (CmbCotista.SelectedIndex < 0) { return; } Saldo = new BL_Saldo().DadosPorCODCOTeCODFUND(Convert.ToInt64(CmbCotista.SelectedValue.ToString()), Convert.ToInt64(CmbBoxFIQ.SelectedValue.ToString())); if (CmbCotista.SelectedIndex > -1) { LabelCodigo.Text = CmbCotista.SelectedValue.ToString(); LabelCota.Text = Saldo.COTA.ToString(); LabelCotas.Text = Saldo.QNTCOTAS.ToString(); LabelFin.Text = string.Format("{0:N}", Saldo.VLPATLIQ); } else { LabelCodigo.Text = "-"; LabelCota.Text = "-"; LabelCotas.Text = "-"; LabelFin.Text = "-"; } CmbBoxOp.SelectedIndex = -1; CmbBoxLiquida.SelectedIndex = -1; CmbBoxConta.SelectedIndex = -1; TextBoxValor.Text = ""; }
//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 BackData_DoWork(object sender, DoWorkEventArgs e) { string[] lines = File.ReadAllLines(TextBoxLocal.Text.Replace(@"\", @"\\"), Encoding.Default); if (FILE == "CADCOTI") { int step = lines.Length / 100; int contline = 0; foreach (string linha in lines) { if (linha.Length == 1264) { string CODEXT = linha.Substring(6, 4) + linha.Substring(12, 8); string Nome = linha.Substring(20, 30).Trim(); string CNPJ = linha.Substring(60, 14).Trim(); string Data = linha.Substring(1241, 2) + "/" + linha.Substring(1239, 2) + "/" + linha.Substring(1235, 4); if (linha.Substring(58, 1) == "F") { CNPJ = linha.Substring(63, 11).Trim(); } //DCTA.ADD(Convert.ToDouble(CODEXT), Nome, CNPJ, Data); } contline++; if (contline % step == 0) { int steps = contline / step; BackData.ReportProgress(steps); } } } else if (FILE == "ARQSDFD0") { BL_Saldo ObjSaldo = new BL_Saldo(); ObjSaldo.Deletar(); int step = lines.Length / 100; int contline = 0; foreach (string linha in lines) { if (linha.Length == 600) { long CODCOT = Convert.ToInt64(linha.Substring(17, 14)); long CODFUND = Convert.ToInt64(linha.Substring(6, 5)); string TIPOREGISTRO = linha.Substring(48, 2) == "20"? "Simples":"Total"; long CAUTELA = Convert.ToInt64(linha.Substring(50, 10)); decimal QNTCOTAS = Convert.ToDecimal(linha.Substring(111, 15)) / 100000; DateTime DATACOTA = DateTime.ParseExact(linha.Substring(139, 8), "yyyyMMdd", null); decimal COTA = Convert.ToDecimal(linha.Substring(147, 15)) / 10000000; ObjSaldo.Inserir(CODCOT, CODFUND, TIPOREGISTRO, CAUTELA, QNTCOTAS, DATACOTA, COTA); } contline++; if (contline % step == 0) { int steps = contline / step; BackData.ReportProgress(steps); } } } }
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"; } } } } }